Ethernet Connection

Issues related to configuring your network
stzanos
Posts: 6
Joined: 2018/11/15 09:24:36

Ethernet Connection

Post by stzanos » 2018/11/15 09:46:12

Hello there, I just registered in the forums so I hope my topic is not already answered somewhere.

I have a Raspberry Pi 3 and my goal is to successfully connect it with Ethernet cable with my Centos 7 machine. The RPI is headless since I don't have an HDMI monitor so I just need to be able to SSH through the Centos machine to access the command line of the RPI. RPI is booting normally and all. So the problem is:

- I open the Network tab in Centos and there are the two Ethernet connections available in the machine. The first one is connected to my router for Internet connection, no problem. The second one is the other Ethernet port I'm trying to use. Says Ethernet (enp3s0) and 1000MB/s but when I hit ON, it tries to connect forever and eventually goes down to OFF again. Is there some way to configure this connection somehow?

- Comparing with the Internet Ethernet connection it says:
IPv4 Address: ...
IPv6 Address: ...
Hardware Address: ...
Default Route: ...
DNS: ...
The other Ethernet connection I'm trying to use says:
Hardware Address: ...
Last used: Never


- I've tried to also connect my Windows laptop with the Centos machine, again using the same Ethernet port just to get going somehow. Also in windows, I get the:
IPv4 Connectivity: No network access
IPv6 Connectivity: No network access

Is there some way to configure these IPv4 or IPv6 addresses and make this connection possible? I'm sorry if I'm missing something obvious but I'm not a computer guy, I just need the RPI for a physics application.

Thanks a lot and sorry for the long post :shock:

User avatar
jlehtone
Posts: 2045
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Ethernet Connection

Post by jlehtone » 2018/11/15 14:08:45

stzanos wrote:
2018/11/15 09:46:12
Is there some way to configure these IPv4 or IPv6 addresses and make this connection possible?
Yes, but ...

You have:
* Router
* Windows
* RPI
* CentOS

CentOS has two physical network ports. First connects to Router.
Second has been connected point-to-point to RPI or Windows.

Router has DHCP server. If/when you connect Windows, CentOS, or RPI to it, they get IP address and "just work".

Neither in the pair of directly connected machines has DHCP server, so neither gets network config via DHCP. Both will need config, not just the CentOS.


The trivial thing would be to connect the RPI to the router just like the CentOS and Windows do. No need for second port on the CentOS. No hassle.

stzanos
Posts: 6
Joined: 2018/11/15 09:24:36

Re: Ethernet Connection

Post by stzanos » 2018/11/15 19:46:01

I see. I understood quite a lot from that answer. So, for every Ethernet connection there must be a DHCP server?
I tried connecting RPI on the router but the problem is the network has restrictions and refuses the connection when I try to ssh. I ran some nmap thing? And then found the IP. But I can't connect to it, thats why I'm trying to do it directly.

Can I somehow configure another DHCP server for the Centos - RPI connection? Are two servers simultaneously possible?

User avatar
fdisk
Posts: 39
Joined: 2017/11/04 00:59:56

Re: Ethernet Connection

Post by fdisk » 2018/11/15 20:52:38

stzanos wrote:
2018/11/15 19:46:01
I tried connecting RPI on the router but the problem is the network has restrictions and refuses the connection when I try to ssh.
Are you running rasbian? Since some time ssh is disabled by default. Look here how to enable it (section 3): https://www.raspberrypi.org/documentati ... ccess/ssh/

stzanos
Posts: 6
Joined: 2018/11/15 09:24:36

Re: Ethernet Connection

Post by stzanos » 2018/11/15 20:59:26

I've already enabled ssh in raspbian from a screen but now the RPI is completely headless. I pretty sure that's the network. Thanks for this though!

User avatar
jlehtone
Posts: 2045
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Ethernet Connection

Post by jlehtone » 2018/11/16 07:40:16

stzanos wrote:
2018/11/15 20:59:26
I've already enabled ssh in raspbian from a screen but now the RPI is completely headless.
You had a display attached. You did enable sshd.
You had RPI on network? You did test that ssh-access was functional?
You had to remove the display.
You had to transfer the RPI to different network?

Router's UI should show the current DHCP clients.

Router's DHCP config should allow setting some clients "static". Binding specific MAC-address always to same IP-address. That way you would know the address of the RPI.

stzanos
Posts: 6
Joined: 2018/11/15 09:24:36

Re: Ethernet Connection

Post by stzanos » 2018/11/16 21:27:19

I'm sorry if I've confused you guys, here's what I've done so far in time order:

1. First, I plugged an Ethernet cable to the RPI from the router at my office. This is where the CentOS machine also gets Internet from, so tried to SSH through this network from the CentOS machine.
fdisk wrote:
2018/11/15 20:52:38
Are you running rasbian? Since some time ssh is disabled by default. Look here how to enable it (section 3): https://www.raspberrypi.org/documentati ... ccess/ssh/
I indeed found out that SSH is disabled for this version of the RPI and that's why I couldn't SSH.

2.
jlehtone wrote:
2018/11/16 07:40:16
You had a display attached. You did enable sshd.
Yes, I did. I actually then carried the RPI with me to another institute and booted it through a screen with HDMI (I don't have a screen with HDMI neither at home nor at my office) and enabled SSH.

3.
jlehtone wrote:
2018/11/16 07:40:16
You had RPI on network? You did test that ssh-access was functional?
It didn't work when I booted it because the network of the institute had restrictions, it did work at home, where I used PuTTY from my windows laptop. I used an IP scanner and found RPI's IP at my home's network, I entered it's command line and I was able to shut it down, reboot, create folders, open applications, whatever.

4. Then, I tried the same, again, at my office with the CentOS (repeated step 1). Since it was already possible and connection was again refused, I am forced to believe that my office's network also has restrictions.

5. And here's where I am now. I'm using the Ethernet cable, directly from the RPI to the CentOS, but somehow the connection is not possible.
jlehtone wrote:
2018/11/16 07:40:16
Router's DHCP config should allow setting some clients "static". Binding specific MAC-address always to same IP-address. That way you would know the address of the RPI.

At step 4, I could find RPI's IP, I used the command "nmap -sn <network IP>/24" and it showed me all the connected devices' IPs. The problem is not finding RPI's address, it is purely connecting RPI with CentOS through one Ethernet cable. Somehow the connection must be configured, and I've realised this is done with a DHCP. My question now is, will I be able to have two networks in one CentOS machine? Because the CentOS is already plugged in the router for Internet. Can it also have like, another connection just for the RPI ethernet cable, without messing with the Internet connection?

User avatar
fdisk
Posts: 39
Joined: 2017/11/04 00:59:56

Re: Ethernet Connection

Post by fdisk » 2018/11/17 14:32:22

If there are restrictions, there's a reason. So first of all, you should ensure that you are authorized to operate your own device within your employer's IT infrastructure.

To connect your rpi I'd suggest to run an dhcp-server on centos system. This way you won't need to touch the rpi as it is configured as a dhcp client by default.

1) First thing is to manually configure your centos Interface (enp3s0) with a private network address which is not being used at employers net.
Example:
centos IPv4 address: 192.168.42.1
raspberry IPv4 address: 192.168.42.2
Netmask: 255.255.255.0
Gateway/DNS: not set

2) you need to install dhcp on centos system

Code: Select all

yum install dhcp
3) quick and minimal dhcp server setup
Edit /etc/dhcp/dhcpd.conf
Note: this is untested. I just did some copy&paste from dhcpd.conf manual page but it should give you an idea:

Code: Select all

ddns-update-style none;
default-lease-time 6000;
max-lease-time 28800;
authoritative;

subnet 192.168.42.0 netmask 255.255.255.0 {
    range 192.168.42.2 192.168.42.254;
    option broadcast-address 192.168.42.255;
    option subnet-mask 255.255.255.0;
}
enable and restart dhcp-server

Code: Select all

systemctl enable dhcpd

Code: Select all

systemctl restart dhcpd
Connect and boot your rpi. It should be reachable at 192.168.42.2

Good luck :)

stzanos
Posts: 6
Joined: 2018/11/15 09:24:36

Re: Ethernet Connection

Post by stzanos » 2018/11/18 10:30:11

Thanks alot! Will try it tomorrow !!!

stzanos
Posts: 6
Joined: 2018/11/15 09:24:36

Re: Ethernet Connection

Post by stzanos » 2018/11/19 14:17:15

Hello again and thanks for your reply. I'm following your steps:
fdisk wrote:
2018/11/17 14:32:22
3) quick and minimal dhcp server setup
Edit /etc/dhcp/dhcpd.conf
Note: this is untested. I just did some copy&paste from dhcpd.conf manual page but it should give you an idea:

Code: Select all

ddns-update-style none;
default-lease-time 6000;
max-lease-time 28800;
authoritative;

subnet 192.168.42.0 netmask 255.255.255.0 {
    range 192.168.42.2 192.168.42.254;
    option broadcast-address 192.168.42.255;
    option subnet-mask 255.255.255.0;
}
I guess this example should work as this IP is not used by my network.
fdisk wrote:
2018/11/17 14:32:22
enable and restart dhcp-server

Code: Select all

systemctl enable dhcpd

Code: Select all

systemctl restart dhcpd
Connect and boot your rpi. It should be reachable at 192.168.42.2

Good luck :)
When I hit enable, it seems to work. However, restarting dhcpd give me the following error:

Code: Select all

 
[root@dhcp181-physics-ntua-gr stamos]# systemctl status dhcpd.service -l
● dhcpd.service - DHCPv4 Server Daemon
   Loaded: loaded (/usr/lib/systemd/system/dhcpd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2018-11-19 14:52:56 CET; 3min 51s ago
     Docs: man:dhcpd(8)
           man:dhcpd.conf(5)
  Process: 15100 ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid (code=exited, status=1/FAILURE)
 Main PID: 15100 (code=exited, status=1/FAILURE)

Nov 19 14:52:56 dhcp181-physics-ntua-gr dhcpd[15100]:    in your dhcpd.conf file for the network segment
Nov 19 14:52:56 dhcp181-physics-ntua-gr dhcpd[15100]:    to which interface virbr0 is attached. **
Nov 19 14:52:56 dhcp181-physics-ntua-gr dhcpd[15100]: 
Nov 19 14:52:56 dhcp181-physics-ntua-gr dhcpd[15100]: 
Nov 19 14:52:56 dhcp181-physics-ntua-gr dhcpd[15100]: No subnet declaration for enp3s0 (no IPv4 addresses).
Nov 19 14:52:56 dhcp181-physics-ntua-gr dhcpd[15100]: ** Ignoring requests on enp3s0.  If this is not what
Nov 19 14:52:56 dhcp181-physics-ntua-gr systemd[1]: dhcpd.service: main process exited, code=exited, status=1/FAILURE
Nov 19 14:52:56 dhcp181-physics-ntua-gr systemd[1]: Failed to start DHCPv4 Server Daemon.
Nov 19 14:52:56 dhcp181-physics-ntua-gr systemd[1]: Unit dhcpd.service entered failed state.
Nov 19 14:52:56 dhcp181-physics-ntua-gr systemd[1]: dhcpd.service failed.
I believe the problem is following step 1:
fdisk wrote:
2018/11/17 14:32:22
1) First thing is to manually configure your CentOS Interface (enp3s0) with a private network address which is not being used at employers net.
Example:
centos IPv4 address: 192.168.42.1
raspberry IPv4 address: 192.168.42.2
Netmask: 255.255.255.0
Gateway/DNS: not set
Configuring the raspberry IPv4 address is quite simple, there's a page in raspberrypi.org that explains exactly that.
My problem is configuring the IPv4 address for the CentOS:
Settings: http://prntscr.com/lk95d0
The IPv4 wizard: http://prntscr.com/lk97mx
When I try to use your details, it doesn't let me continue, unless I select a Gateway:
http://prntscr.com/lk98uv

How would the DHCP server know which Ethernet port I'm referring to, anyway?

Post Reply