FalcoGer
Posts: 37
Joined: Mon Jul 09, 2018 6:35 am

Raspbian - Network unreachable after hotplug

Fri Jul 20, 2018 7:48 am

I use the raspberry pi 3b with raspbian stretch
I must have a static ip address.
I changed /etc/dhcpcd.conf in this way:

Code: Select all

# this stuff was here already
hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routers
option ntp_servers
option interface_mtu

require dhcp_server_identifier
slaac private

#i added this line
allow hotplug eth0

# this was set up by the graphical configuration tool
interface eth0
inform 192.168.115.31
static routers=192.168.115.1
static domain_name_servers=192.168.115.1 8.8.8.8 8.8.4.4
noipv6
the issue is, when I turn off the switch or unplug the cable, and then reconnect the raspberry, it no longer connects to anything.
trying to ping 8.8.8.8 gives 'network is unreachable'

WiFi is disabled

I have seen some people using a bash script that checks connection and then use ifup --force eth0, but that command yields me
ifup: unknown interface eth0

also ifconfig still shows me the static ip I assigned (on eth0), despite the pi being physically unplugged

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 21500
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspbian - Network unreachable after hotplug

Fri Jul 20, 2018 8:28 am

There have been some *very* recent changes to the driver that may help here.

The latest fix should be in rpi-update. I think it woudl be worth trying it, to see if it helps. That shoudl give you kernel version 4.14.56 I think.

EDIT: Ah, hold on, do you mean the 3B+ or the original 3B? The fix is for the 3B+.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

FalcoGer
Posts: 37
Joined: Mon Jul 09, 2018 6:35 am

Re: Raspbian - Network unreachable after hotplug

Fri Jul 20, 2018 8:59 am

It's the 3B V1.2

Update:

I've been trying to manually restart without having to reboot the pi, so i was hoping i could use a script as well to reinitialize the networking if ping to the gateway doesn't work.
I'm not sure how to do that.
I tried

Code: Select all

sudo ifconfig eth0 down
sudo service networking stop
sudo service dhcpcd stop
sudo service dhcpcd start
sudo service networking start
sudo ifconfig eth0 up
problem persists

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 21500
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspbian - Network unreachable after hotplug

Fri Jul 20, 2018 9:11 am

FalcoGer wrote:
Fri Jul 20, 2018 8:59 am
It's the 3B V1.2
OK, so won't be affected by the driver change, that was 3b+ only.

Not sure then. It's not been repported elsewhere, so cannot be common.

Just tried unplugging the ethernet cable of a 3B+ here, eth0 didn't disapear, but lost IP address. Pluggin back in, renegotiated the IP address, all worked fine. So presumably, this is a problem with your setup.

Using kernel 4.14.50
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

FalcoGer
Posts: 37
Joined: Mon Jul 09, 2018 6:35 am

Re: Raspbian - Network unreachable after hotplug

Fri Jul 20, 2018 11:35 am

As I said, I'm using a static IP.
It doesn't seem to unassign the ip when I remove the cable.

I have just rebooted with the cable not connected, same setup.
the icon in the taskbar shows no connection
ifconfig shows eth0 without IP

after plugging in the cable ifconfig showed the correct ip address after about 5 seconds
ping to google works fine.

after dis- and reconnect the problem appears again.
it seems to be a problem with the adapter maintaining the ip after the connection is interrupted and then not talking to the router afterwards.


epoch1970
Posts: 2414
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Raspbian - Network unreachable after hotplug

Wed Jul 25, 2018 9:36 pm

Code: Select all

allow hotplug eth0
inform 192.168.115.31
I don't know where you found the inspiration for these options, but probably not in the documentation under "man dhcpcd.conf"
Perhaps doing without them would help.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

FalcoGer
Posts: 37
Joined: Mon Jul 09, 2018 6:35 am

Re: Raspbian - Network unreachable after hotplug

Sat Jul 28, 2018 11:07 pm

I didn't put the inform there thing there. that was the gui thing you get in network settings.
also they are in the doc, try

man dhcpcd.conf
does list inform as an option on the pi, although not anywhere else curiously.
at least I'm pretty sure it does, I don't have the pi handy right now.

I did it without the hotplug option, I found that on some posts about wifi not reconnecting and figured it'd help with wired, too. in any case with or without it, it doesn't currently work for me.
if I don't use those things, the pi would request an ip from the router, which is what I specifically don't want.

Polka091
Posts: 5
Joined: Wed Apr 06, 2016 4:18 pm

Re: Raspbian - Network unreachable after hotplug

Sat Jul 28, 2018 11:52 pm

I am also experiencing this after upgrading from Jessie to Stretch. This is with a Raspberry Pi 3 Model B, not the B+.

I use my Pi as a dhcp/dns server (pihole), and this causes a problem, that if my router or switch ever reboot, the Raspberry Pi can ping itself (loop back and private static IP), but has no routes or default gateway, even though a gateway is specified in dhcpcd. This is problematic for obvious reasons.

Code: Select all

 cat ~/hotplug-eth0-issue.txt
Linux pihole 4.14.52-v7+ #1123 SMP Wed Jun 27 17:35:49 BST 2018 armv7l GNU/Linux


Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface


eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.2.2  netmask 255.255.255.0  broadcast 192.168.2.255
        inet6 fe80::ee9a:5ccd:4ce8:fab9  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:87:2c:f0  txqueuelen 1000  (Ethernet)
        RX packets 12436  bytes 1387262 (1.3 MiB)
        RX errors 0  dropped 42  overruns 0  frame 0
        TX packets 2039  bytes 261759 (255.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2199  bytes 663719 (648.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2199  bytes 663719 (648.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
#clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU.
# Some interface drivers reset when changing the MTU so disabled by default.
#option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private

# A hook script is provided to lookup the hostname if not set by the DHCP
# server, but it should not be run by default.
nohook lookup-hostname

interface eth0
static routers=192.168.2.1
static domain_name_servers=192.168.2.2
static domain_search=localnet
static ip_address=192.168.2.2/24
static routers=192.168.2.1
inform 192.168.2.2/24
# Generated by resolvconf
nameserver 127.0.0.1
# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

#auto lo
#iface lo inet loopback

#iface eth0 inet static
#       address 192.168.2.2
#       netmask 255.255.255.0
#       network 192.168.2.1
#       broadcast 192.168.2.255
#       gateway 192.168.2.1
#       dns-nameservers 192.168.2.2 8.8.8.8
#       dns-domain local
#       dns-search local

#allow-hotplug wlan0
#iface wlan0 inet manual
#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
#
#allow-hotplug wlan1
#iface wlan1 inet manual
#    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.097 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.116 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.115 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.099 ms
64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.106 ms

--- 127.0.0.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4175ms
rtt min/avg/max/mdev = 0.097/0.106/0.116/0.013 ms
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.112 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.099 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.091 ms
64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.105 ms

--- 127.0.0.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3129ms
rtt min/avg/max/mdev = 0.091/0.101/0.112/0.014 ms
PING 192.168.2.2 (192.168.2.2) 56(84) bytes of data.
64 bytes from 192.168.2.2: icmp_seq=1 ttl=64 time=0.104 ms
64 bytes from 192.168.2.2: icmp_seq=2 ttl=64 time=0.121 ms
64 bytes from 192.168.2.2: icmp_seq=3 ttl=64 time=0.106 ms
64 bytes from 192.168.2.2: icmp_seq=4 ttl=64 time=0.098 ms

--- 192.168.2.2 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3156ms
rtt min/avg/max/mdev = 0.098/0.107/0.121/0.011 ms

Polka091
Posts: 5
Joined: Wed Apr 06, 2016 4:18 pm

Re: Raspbian - Network unreachable after hotplug

Sat Aug 11, 2018 6:34 am

Would like to bump this... this is still a problem.

Polka091
Posts: 5
Joined: Wed Apr 06, 2016 4:18 pm

Re: Raspbian - Network unreachable after hotplug

Tue Oct 02, 2018 11:21 am

Bump - still experiencing this. Is there any resolution/fix for this?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 21500
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspbian - Network unreachable after hotplug

Tue Oct 02, 2018 12:31 pm

It's a bit difficult to determine what going on here, I've tried but it all works fine on my system, so presumably, it's something to do with your setup.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
"My grief counseller just died, luckily, he was so good, I didn't care."

Return to “Troubleshooting”