sron
Posts: 24
Joined: Mon Apr 20, 2015 9:11 am

can't connect with SSH when using 2 network adapters

Thu Apr 14, 2016 11:05 am

Hello,
I'm using Pi B+ with Raspbian.
I need Raspberry pi to work with 2 networks so i use usb to ethernet adapter.

I have a problem that when the usb2Ethernet adapter is connected to the pi, I can't ssh the pi via the buidIn network inteface but only via the usb adapter ip address. If I disconnect the usb adapter and restart pi, ssh to the buildin interface ip address working fine.

The buildin ethernet interface is eth0 and the usb adapter is eth1; both with static ip, no more network adapters.
I'm chacked with:

Code: Select all

netstat -tulpn
command, and it seem that ssh (port 22) listen to all interfaces (0.0.0.0)
can somebody give me advice?
Output of netstat -tulpn

Code: Select all

[email protected]:~# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1933/apache2
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2141/sshd
udp        0      0 192.168.2.127:123       0.0.0.0:*                           2095/ntpd
udp        0      0 127.0.0.1:123           0.0.0.0:*                           2095/ntpd
udp        0      0 0.0.0.0:123             0.0.0.0:*                           2095/ntpd
/etc/network/interfaces file:

Code: Select all

[email protected]:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet static
        address 192.168.2.127
        network 192.168.2.0
        netmask 255.255.0.0
        gateway 192.168.2.1

iface eth1 inet static
        address 192.0.0.70
        network 192.0.0.0
        netmask 255.255.255.0
        gateway 192.0.0.1

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Thanks :)

MattF
Posts: 55
Joined: Tue Feb 12, 2013 10:01 am

Re: can't connect with SSH when using 2 network adapters

Thu Apr 14, 2016 11:04 pm

That's a slightly strange choice of subnet for the 2nd NIC. Where are you trying to SSH in from, and what does its routing table look like?

The pi configuration itself seems OK.

You must might want to check RFC1918, and perhaps use something like 10.10.20.0/24 for the 2nd NIC as a subnet.

sron
Posts: 24
Joined: Mon Apr 20, 2015 9:11 am

Re: can't connect with SSH when using 2 network adapters

Tue Apr 19, 2016 2:05 pm

Sorry for late response, the Pi was not available for me for few days.
Indeed, seems the problem was with the netmask of eth0 (first NIC).
It was set to 255.255.0.0
I set it to 255.255.255.0 and its working OK now.

Thanks! really appriciatte

Return to “Advanced users”