4

I use eth0 interface on RPI 3B+ with DHCP and when cable is disconnected then IP address is lost and when cable is reconnected then IP is usually not renewed. I tried to set static address in /etc/dhcpd.conf but the issue is similar (+ debug option). I see in ip addr link goes DOWN and UP but seems no trigger is fired to get DHCP lease. I cannot see eth0 event in dmesg and /var/log/syslog.log. Also wicd.log provides no helpful message.

I found debian related question https://askubuntu.com/questions/576636/maintain-ip-address-alive-even-when-cable-not-plugged. Surprisingly allow-hotplug keep eth0 UP even cable disconnected.

But when I start Raspi without cable then I have no IP (no static address), when connect cable I got IP once, unplug it and plug and I see IPv6 lease followed by zero conf, i.e. I'm back in the same trouble.

I tried fallback interface in /etc/dhcpd.conf which worked once when booted unplugged but I cannot reproduce.

Also manual ifup won't help. I can get IP manually via sudo dhclient eth0.

I suspect there is dependency among networking, dhcpcd, wicd,... and some hooks should bring stuff up. Any idea how to debug it or potentially how make hard static address or hook somewhere to force dhcp lease (or static IP) ? Might be related to unwanted IPv6 ?

Note I see in syslog

IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link is not ready
8021q: adding VLAN 0 to HW filter on device eth0
Failed to connect to non-global ctrlifname: eth0 error: No such file or directory
IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

But it seems it is related to first plug, it won't repeat.

EDIT:

Raspberian OS

uname -a
Linux hass 4.19.118-v7+ #1311 SMP Mon Apr 27 14:21:24 BST 2020 armv7l GNU/Linux
cat /etc/debian_version
10.4

/etc/dhcpcd.conf

# 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.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
#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
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# Most distributions have NTP support.
#option ntp_servers

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate SLAAC address using the Hardware Address of the interface
#slaac hwaddr
# OR generate Stable Private IPv6 Addresses based from the DUID
slaac private

# Example static IP configuration:
# NO EFFECT !
#interface eth0
#static ip_address=192.168.0.113/24
#static ip6_address=fd51:42f8:caae:d92e::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 fd51:42f8:caae:d92e::1

# fallback to static profile on eth0
#fallback static_eth0

# It is possible to fall back to a static IP if DHCP fails:
# WORKED WHEN CABLE DISCONNECTED DURING BOOT BUT WITHOUT Allow-hotplug eth0
# define static profile
#profile static_eth0
#static ip_address=192.168.0.113/24
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8

debug

In case of /etc/network/interfaces.

auto eth0
allow-hotplug eth0
source-directory /etc/network/interfaces.d

Booted with plugged cable:

I see in /var/log/syslog regardless cable state:

Jun  8 08:35:26 hass dhcpcd[357]: eth0: Router Advertisement from fe80::9ada:c4ff:feba:6c02
Jun  8 08:35:26 hass dhcpcd[357]: eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' ROUTERADVERT

ifconfig

    eth0: flags=4163<AKTIVOVÁNO,VŠESMĚR,BĚŽÍ,MULTICAST>  mtu 1500
    inet 192.168.0.113 síťová_maska 255.255.0.0  všesměr 192.168.255.255
    inet6 fe80::1503:cf85:201b:34e2  délka_prefixu 64  scopeid 0x20<linka>
    ether b8:27:eb:59:34:88 délka_odchozí_fronty 1000  (Ethernet)
    RX packetů 5714  bajtů 4209972 (4,0 MiB)
    RX chyb 0  zahozeno 0  přetečení 0  rámců 0
    TX packetů 3956  bajtů 418911 (409,0 KiB)
    TX chyb 0  zahozeno 0  přetečení 0  přenos 0  kolizí 0

ip addr

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:59:34:88 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.113/16 brd 192.168.255.255 scope global dynamic noprefixroute eth0
       valid_lft 142957sec preferred_lft 124957sec
    inet6 fe80::1503:cf85:201b:34e2/64 scope link 
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether b8:27:eb:0c:61:dd brd ff:ff:ff:ff:ff:ff

/var/log/wicd/wicd.log

2020/06/08 08:22:02 :: Daemon going down, killing wicd-monitor...
2020/06/08 08:22:02 :: Removing PID file...
2020/06/08 08:22:02 :: Shutting down...
2020/06/08 08:22:02 :: Exception KeyError: KeyError(1995468816,) in <module 'threading' from '/usr/lib/python2.7/threading.pyo'> ignored
2020/06/08 08:22:09 :: ---------------------------
2020/06/08 08:22:09 :: wicd initializing...
2020/06/08 08:22:09 :: ---------------------------
2020/06/08 08:22:09 :: wicd is version 1.7.4 961
2020/06/08 08:22:09 :: setting backend to external
2020/06/08 08:22:09 :: trying to load backend external
2020/06/08 08:22:09 :: successfully loaded backend external
2020/06/08 08:22:10 :: trying to load backend external
2020/06/08 08:22:10 :: successfully loaded backend external
2020/06/08 08:22:10 :: Automatically detected wireless interface wlan0
2020/06/08 08:22:10 :: setting wireless interface wlan0
2020/06/08 08:22:10 :: automatically detected wired interface eth0
2020/06/08 08:22:10 :: setting wired interface eth0
2020/06/08 08:22:10 :: setting wpa driver wext
2020/06/08 08:22:10 :: setting use global dns to False
2020/06/08 08:22:10 :: setting global dns
2020/06/08 08:22:10 :: global dns servers are None None None
2020/06/08 08:22:10 :: domain is None
2020/06/08 08:22:10 :: search domain is None
2020/06/08 08:22:10 :: setting automatically reconnect when connection drops True
2020/06/08 08:22:10 :: Setting dhcp client to 0
2020/06/08 08:22:10 :: Wireless configuration file found...
2020/06/08 08:22:10 :: Wired configuration file found...
2020/06/08 08:22:10 :: chmoding configuration files 0600...
2020/06/08 08:22:10 :: chowning configuration files root:root...
2020/06/08 08:22:10 :: Using wireless interface...wlan0
2020/06/08 08:22:10 :: Using wired interface...eth0

Booted with cable unplugged

ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether b8:27:eb:59:34:88 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether b8:27:eb:0c:61:dd brd ff:ff:ff:ff:ff:ff

ifconfig
eth0: flags=4099<AKTIVOVÁNO,VŠESMĚR,MULTICAST>  mtu 1500
        ether b8:27:eb:59:34:88 délka_odchozí_fronty 1000  (Ethernet)
        RX packetů 0  bajtů 0 (0,0 B)
        RX chyb 0  zahozeno 0  přetečení 0  rámců 0
        TX packetů 0  bajtů 0 (0,0 B)
        TX chyb 0  zahozeno 0  přetečení 0  přenos 0  kolizí 0

lo: flags=73<AKTIVOVÁNO,SMYČKA,BĚŽÍ>  mtu 65536
        inet 127.0.0.1 síťová_maska 255.0.0.0
        inet6 ::1  délka_prefixu 128  scopeid 0x10<stroj>
        loop délka_odchozí_fronty 1000  (Místní smyčka)
        RX packetů 40  bajtů 2617 (2,5 KiB)
        RX chyb 0  zahozeno 0  přetečení 0  rámců 0
        TX packetů 40  bajtů 2617 (2,5 KiB)
        TX chyb 0  zahozeno 0  přetečení 0  přenos 0  kolizí 0

wicd.log

2020/06/08 08:55:37 :: ---------------------------
2020/06/08 08:55:37 :: wicd initializing...
2020/06/08 08:55:37 :: ---------------------------
2020/06/08 08:55:37 :: wicd is version 1.7.4 961
2020/06/08 08:55:37 :: setting backend to external
2020/06/08 08:55:37 :: trying to load backend external
2020/06/08 08:55:37 :: successfully loaded backend external
2020/06/08 08:55:37 :: trying to load backend external
2020/06/08 08:55:37 :: successfully loaded backend external
2020/06/08 08:55:38 :: Automatically detected wireless interface wlan0
2020/06/08 08:55:38 :: setting wireless interface wlan0
2020/06/08 08:55:38 :: automatically detected wired interface eth0
2020/06/08 08:55:38 :: setting wired interface eth0
2020/06/08 08:55:38 :: setting wpa driver wext
2020/06/08 08:55:38 :: setting use global dns to False
2020/06/08 08:55:38 :: setting global dns
2020/06/08 08:55:38 :: global dns servers are None None None
2020/06/08 08:55:38 :: domain is None
2020/06/08 08:55:38 :: search domain is None
2020/06/08 08:55:38 :: setting automatically reconnect when connection drops True
2020/06/08 08:55:38 :: Setting dhcp client to 0
2020/06/08 08:55:38 :: Wireless configuration file found...
2020/06/08 08:55:38 :: Wired configuration file found...
2020/06/08 08:55:38 :: chmoding configuration files 0600...
2020/06/08 08:55:38 :: chowning configuration files root:root...
2020/06/08 08:55:38 :: Using wireless interface...wlan0
2020/06/08 08:55:38 :: Using wired interface...eth0
2020/06/08 08:55:43 :: Autoconnecting...
2020/06/08 08:55:43 :: No wired connection present, attempting to autoconnect to wireless network
2020/06/08 08:55:43 :: Unable to autoconnect, you'll have to manually connect
2020/06/08 08:55:48 :: Autoconnecting...
2020/06/08 08:55:48 :: No wired connection present, attempting to autoconnect to wireless network
2020/06/08 08:55:48 :: Unable to autoconnect, you'll have to manually connect
2020/06/08 08:55:53 :: Autoconnecting...
2020/06/08 08:55:53 :: No wired connection present, attempting to autoconnect to wireless network
2020/06/08 08:55:48 :: Unable to autoconnect, you'll have to manually connect
2020/06/08 08:55:53 :: Autoconnecting...
2020/06/08 08:55:53 :: No wired connection present, attempting to autoconnect to wireless network
2020/06/08 08:55:53 :: Unable to autoconnect, you'll have to manually connect
2020/06/08 08:55:58 :: Autoconnecting...
2020/06/08 08:55:58 :: No wired connection present, attempting to autoconnect to wireless network
2020/06/08 08:55:58 :: Unable to autoconnect, you'll have to manually connect

Cable plugged

ifconfig
eth0: flags=4163<AKTIVOVÁNO,VŠESMĚR,BĚŽÍ,MULTICAST>  mtu 1500
        inet 192.168.0.113 síťová_maska 255.255.0.0  všesměr 192.168.255.255
        inet6 fe80::1503:cf85:201b:34e2  délka_prefixu 64  scopeid 0x20<linka>
        ether b8:27:eb:59:34:88 délka_odchozí_fronty 1000  (Ethernet)
        RX packetů 43  bajtů 4501 (4,3 KiB)
        RX chyb 0  zahozeno 0  přetečení 0  rámců 0
        TX packetů 25  bajtů 3196 (3,1 KiB)
        TX chyb 0  zahozeno 0  přetečení 0  přenos 0  kolizí 0

ifconfig
eth0: flags=4163<AKTIVOVÁNO,VŠESMĚR,BĚŽÍ,MULTICAST>  mtu 1500
        inet 192.168.0.113 síťová_maska 255.255.0.0  všesměr 192.168.255.255
        inet6 fe80::1503:cf85:201b:34e2  délka_prefixu 64  scopeid 0x20<linka>
        ether b8:27:eb:59:34:88 délka_odchozí_fronty 1000  (Ethernet)
        RX packetů 102  bajtů 9948 (9,7 KiB)
        RX chyb 0  zahozeno 0  přetečení 0  rámců 0
        TX packetů 49  bajtů 5242 (5,1 KiB)
        TX chyb 0  zahozeno 0  přetečení 0  přenos 0  kolizí 0

wicdlog no new entry

syslog

Jun  8 08:59:00 hass dhcpcd[378]: eth0: Router Advertisement from fe80::9ada:c4ff:feba:6c02
Jun  8 08:59:00 hass dhcpcd[378]: eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' ROUTERADVERT
Jun  8 08:59:00 hass dhcpcd[378]: eth0: broadcasting SOLICIT6 (xid 0xe49eff), next in 7.2 seconds
Jun  8 08:59:00 hass dhcpcd[378]: eth0: DHCPv6 REPLY: No Addresses Available
Jun  8 08:59:07 hass dhcpcd[378]: eth0: broadcasting SOLICIT6 (xid 0xe49eff), next in 14.2 seconds
Jun  8 08:59:07 hass dhcpcd[378]: eth0: DHCPv6 REPLY: No Addresses Available
Jun  8 08:59:09 hass dhcpcd[378]: eth0: Router Advertisement from fe80::9ada:c4ff:feba:6c02
Jun  8 08:59:09 hass dhcpcd[378]: eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' ROUTERADVERT
Jun  8 08:59:12 hass dhcpcd[378]: eth0: Router Advertisement from fe80::9ada:c4ff:feba:6c02
Jun  8 08:59:12 hass dhcpcd[378]: eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' ROUTERADVERT
Jun  8 08:59:21 hass dhcpcd[378]: eth0: Router Advertisement from fe80::9ada:c4ff:feba:6c02
Jun  8 08:59:21 hass dhcpcd[378]: eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' ROUTERADVERT
Jun  8 08:59:22 hass dhcpcd[378]: eth0: broadcasting SOLICIT6 (xid 0xe49eff), next in 28.2 seconds
Jun  8 08:59:22 hass dhcpcd[378]: eth0: DHCPv6 REPLY: No Addresses Available
Jun  8 08:59:25 hass dhcpcd[378]: eth0: Router Advertisement from fe80::9ada:c4ff:feba:6c02
Jun  8 08:59:25 hass dhcpcd[378]: eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' ROUTERADVERT
Jun  8 08:59:33 hass dhcpcd[378]: eth0: Router Advertisement from fe80::9ada:c4ff:feba:6c02
Jun  8 08:59:33 hass dhcpcd[378]: eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' ROUTERADVERT
Jun  8 08:59:35 hass hass[429]: 2020-06-08 08:59:35 INFO (MainThread) [homeassistant.components.sensor] Setting up sens>
Jun  8 08:59:38 hass dhcpcd[378]: eth0: Router Advertisement from fe80::9ada:c4ff:feba:6c02
Jun  8 08:59:38 hass dhcpcd[378]: eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' ROUTERADVERT
Jun  8 08:59:44 hass dhcpcd[378]: eth0: Router Advertisement from fe80::9ada:c4ff:feba:6c02
Jun  8 08:59:44 hass dhcpcd[378]: eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' ROUTERADVERT
Jun  8 08:59:50 hass dhcpcd[378]: eth0: broadcasting SOLICIT6 (xid 0xe49eff), next in 55.5 seconds
Jun  8 08:59:50 hass dhcpcd[378]: eth0: DHCPv6 REPLY: No Addresses Available
Jun  8 08:59:52 hass dhcpcd[378]: eth0: Router Advertisement from fe80::9ada:c4ff:feba:6c02
Jun  8 08:59:52 hass dhcpcd[378]: eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' ROUTERADVERT

cable unplugged

ip addr
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN group default qlen 1000
    link/ether b8:27:eb:59:34:88 brd ff:ff:ff:ff:ff:ff

ifconfig
eth0: flags=4099<AKTIVOVÁNO,VŠESMĚR,MULTICAST>  mtu 1500
        ether b8:27:eb:59:34:88 délka_odchozí_fronty 1000  (Ethernet)
        RX packetů 515  bajtů 83720 (81,7 KiB)
        RX chyb 0  zahozeno 0  přetečení 0  rámců 0
        TX packetů 414  bajtů 43337 (42,3 KiB)
        TX chyb 0  zahozeno 0  přetečení 0  přenos 0  kolizí 0

wicd.log woke up

2020/06/08 09:01:22 :: Autoconnecting...
2020/06/08 09:01:22 :: No wired connection present, attempting to autoconnect to wireless network
2020/06/08 09:01:22 :: Unable to autoconnect, you'll have to manually connect

syslog

Jun  8 09:01:20 hass dhcpcd[378]: eth0: carrier lost
Jun  8 09:01:20 hass dhcpcd[378]: eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' NOCARRIER
Jun  8 09:01:20 hass dhcpcd[378]: eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' ROUTERADVERT
Jun  8 09:01:20 hass dhcpcd[378]: eth0: deleting address fe80::1503:cf85:201b:34e2
Jun  8 09:01:20 hass avahi-daemon[333]: Withdrawing address record for fe80::1503:cf85:201b:34e2 on eth0.
Jun  8 09:01:20 hass avahi-daemon[333]: Leaving mDNS multicast group on interface eth0.IPv6 with address fe80::1503:cf85
:201b:34e2.
Jun  8 09:01:20 hass avahi-daemon[333]: Interface eth0.IPv6 no longer relevant for mDNS.
Jun  8 09:01:20 hass dhcpcd[378]: eth0: deleting IP address 192.168.0.113/16
Jun  8 09:01:20 hass avahi-daemon[333]: Withdrawing address record for 192.168.0.113 on eth0.
Jun  8 09:01:20 hass avahi-daemon[333]: Leaving mDNS multicast group on interface eth0.IPv4 with address 192.168.0.113.
Jun  8 09:01:20 hass avahi-daemon[333]: Interface eth0.IPv4 no longer relevant for mDNS.
Jun  8 09:01:20 hass dhcpcd[378]: eth0: deleting route to 192.168.0.0/16
Jun  8 09:01:20 hass dhcpcd[378]: eth0: deleting default route via 192.168.0.1
Jun  8 09:01:20 hass dhcpcd[378]: eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' EXPIRE
Jun  8 09:01:22 hass wicd[363]: SIOCSIFFLAGS: Operation not possible due to RF-kill
Jun  8 09:01:22 hass wicd[363]: wlan0     Interface doesn't support scanning : Network is down
Jun  8 09:01:22 hass wicd[363]: sending commands to master dhcpcd process
Jun  8 09:01:22 hass dhcpcd[1634]: sending commands to master dhcpcd process
Jun  8 09:01:22 hass dhcpcd[378]: control command: /sbin/dhcpcd -k wlan0
Jun  8 09:01:22 hass wicd[363]: send OK
Jun  8 09:01:22 hass dhcpcd[378]: wlan0: removing interface
Jun  8 09:01:22 hass dhcpcd[378]: wlan0: executing `/lib/dhcpcd/dhcpcd-run-hooks' STOPPED
Jun  8 09:01:22 hass dhcpcd[1634]: send OK
Jun  8 09:01:22 hass wicd[363]: SIOCSIFFLAGS: Operation not possible due to RF-kill
Jun  8 09:01:22 hass wicd[363]: SIOCSIFFLAGS: Operation not possible due to RF-kill
Jun  8 09:01:22 hass wicd[363]: sending commands to master dhcpcd process
Jun  8 09:01:22 hass wicd[363]: send OK
Jun  8 09:01:22 hass dhcpcd[1661]: sending commands to master dhcpcd process
Jun  8 09:01:22 hass dhcpcd[1661]: send OK
Jun  8 09:01:22 hass dhcpcd[378]: control command: /sbin/dhcpcd -k eth0
Jun  8 09:01:22 hass dhcpcd[378]: eth0: removing interface
Jun  8 09:01:22 hass dhcpcd[378]: eth0: executing `/lib/dhcpcd/dhcpcd-run-hooks' STOPPED
Jun  8 09:01:22 hass kernel: [  331.666115] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
Jun  8 09:01:22 hass kernel: [  331.666124] 8021q: adding VLAN 0 to HW filter on device eth0
Jun  8 09:01:22 hass wicd[363]: Failed to connect to non-global ctrl_ifname: eth0  error: No such file or directory
Jun  8 09:01:27 hass wicd[363]: SIOCSIFFLAGS: Operation not possible due to RF-kill
Jun  8 09:01:27 hass wicd[363]: wlan0     Interface doesn't support scanning : Network is down
Jun  8 09:01:32 hass wicd[363]: SIOCSIFFLAGS: Operation not possible due to RF-kill
Jun  8 09:01:32 hass wicd[363]: wlan0     Interface doesn't support scanning : Network is down
Jun  8 09:01:35 hass hass[429]: 2020-06-08 09:01:35 ERROR (MainThread) [homeassistant.components.upnp] Error requesting>
Jun  8 09:01:37 hass wicd[363]: SIOCSIFFLAGS: Operation not possible due to RF-kill
Jun  8 09:01:37 hass wicd[363]: wlan0     Interface doesn't support scanning : Network is down

Cable reconnected

syslog

Jun  8 09:04:57 hass wicd[363]: SIOCSIFFLAGS: Operation not possible due to RF-kill
Jun  8 09:04:57 hass wicd[363]: wlan0     Interface doesn't support scanning : Network is down
Jun  8 09:05:06 hass kernel: [  555.901393] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

wicd.log

2020/06/08 09:04:57 :: Autoconnecting...
2020/06/08 09:04:57 :: No wired connection present, attempting to autoconnect to wireless network
2020/06/08 09:04:57 :: Unable to autoconnect, you'll have to manually connect

ip addr

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:59:34:88 brd ff:ff:ff:ff:ff:ff

ifconfig

eth0: flags=4163<AKTIVOVÁNO,VŠESMĚR,BĚŽÍ,MULTICAST>  mtu 1500
        ether b8:27:eb:59:34:88 délka_odchozí_fronty 1000  (Ethernet)
        RX packetů 715  bajtů 100288 (97,9 KiB)
        RX chyb 0  zahozeno 0  přetečení 0  rámců 0
        TX packetů 414  bajtů 43337 (42,3 KiB)
        TX chyb 0  zahozeno 0  přetečení 0  přenos 0  kolizí 0

avahi status

sudo systemctl status avahi-daemon.service 
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
   Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2020-06-09 00:23:55 CEST; 8h ago
 Main PID: 280 (avahi-daemon)
   Status: "avahi-daemon 0.7 starting up."
    Tasks: 2 (limit: 2200)
   Memory: 1.1M
   CGroup: /system.slice/avahi-daemon.service
           ├─280 avahi-daemon: running [hass.local]
           └─361 avahi-daemon: chroot helper

čen 09 00:24:40 hass avahi-daemon[280]: Registering new address record for 192.168.0.113 on eth0.IPv4.
čen 09 00:24:54 hass avahi-daemon[280]: Withdrawing address record for 192.168.0.113 on eth0.
čen 09 00:24:54 hass avahi-daemon[280]: Leaving mDNS multicast group on interface eth0.IPv4 with address 192.168.0.113.
čen 09 00:24:54 hass avahi-daemon[280]: Interface eth0.IPv4 no longer relevant for mDNS.
čen 09 00:25:04 hass avahi-daemon[280]: Joining mDNS multicast group on interface eth0.IPv4 with address 192.168.0.113.
čen 09 00:25:04 hass avahi-daemon[280]: New relevant interface eth0.IPv4 for mDNS.
čen 09 00:25:04 hass avahi-daemon[280]: Registering new address record for 192.168.0.113 on eth0.IPv4.
čen 09 08:29:10 hass avahi-daemon[280]: Withdrawing address record for 192.168.0.113 on eth0.
čen 09 08:29:10 hass avahi-daemon[280]: Leaving mDNS multicast group on interface eth0.IPv4 with address 192.168.0.113.
čen 09 08:29:10 hass avahi-daemon[280]: Interface eth0.IPv4 no longer relevant for mDNS.

Manual IP lease to fix issue

sudo dhclient eth0
Too few arguments.
Too few arguments.
ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:59:34:88 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.113/16 brd 192.168.255.255 scope global dynamic eth0
       valid_lft 143996sec preferred_lft 143996sec

EDIT2:

I disabled dhcpcd.service and leave old (deprecated??) networking.service.

auto eth0
allow-hotplug eth0

#iface eth0 inet dhcp

iface eth0 inet static
    address 192.168.0.113
    netmask 255.255.0.0
    gatevay 192.168.0.1

Modified /etc/wpa_supplicant/ifupdown.sh not to touch wired interfaces

# quit if we're called for the wired interface
if [ "$IFACE" = eth0 ]; then
        exit 0
fi

Disabled avahi-daemon

Set wicd to use dhclient and duplicated static address

[My network]
afterscript = None
dhcphostname = hass
postdisconnectscript = None
dns_domain = hass
gateway = 192.168.0.1
use_global_dns = 0
lastused = True
ip = 192.168.0.113
beforescript = None
encryption_enabled = 0
broadcast = None
netmask = 255.255.0.0
usedhcphostname = 0
predisconnectscript = None
enctype = None
default = 0
dns2 = 8.8.8.8
search_domain = None
use_static_dns = 1
dns3 = None
profilename = My network
dns1 = 192.168.0.1

It works now as real static address till I switch on WiFi in wicd. It removes eth0 IP address as support only swuitching among interfaces. Seems daemon /usr/share/wicd/daemon/monitor.py won't refresh cable. It just keep logging

2020/06/09 11:12:00 :: ifconfig eth0
2020/06/09 11:12:05 :: ifconfig eth0
2020/06/09 11:12:10 :: ifconfig eth0
2020/06/09 11:12:15 :: ifconfig eth0

When I killed daemon and run from command line I see reconnecting and IP refresh on eth0

sudo /usr/share/wicd/daemon/monitor.py
Starting automatic reconnect process
Starting automatic reconnect process
Starting automatic reconnect process
Starting automatic reconnect process
Starting automatic reconnect process

Seems wicd uses networking and its hooks are raised, wicd itself has no hook configured.

I this state it is not correct but at least seems Raspi can survive eth0 link changes (until I touch wicd in GUI).

5
  • 2
    Without details of what you did to configure networking (or even what OS), no evidence this Question is meaningless
    – Milliways
    Commented Jun 7, 2020 at 22:44
  • Replace the cat5 cable with a known good cable. Reboot your router/switch. Reboot your RPi.
    – Dougie
    Commented Jun 7, 2020 at 23:45
  • @Milliways added config and log dumps
    – TMa
    Commented Jun 8, 2020 at 7:25
  • @Dougie it is not about cable quality but reliability when router is restarted (i.e. the other end of cable is disconnected) or in case of power outage which device boots faster (raspi vs. router)
    – TMa
    Commented Jun 8, 2020 at 7:27
  • I didn't attempt to untangle that mismatch - you have apparently used 3 different network managers, which are mutually incompatible. Pick ONE . Raspberry Pi OS uses dhcpcd (not sure about "Raspberian") - see How to set up networking/WiFi
    – Milliways
    Commented Jun 8, 2020 at 7:33

2 Answers 2

4

Wow, what a mixup of network managers! It is unsurprising that it doesn't work. You are using Debian ifupdown with /etc/network/interaces and dhcpcd and wicd and using two DHCP clients dhclient and dhcpcd. It seems there is one fighting against the other. First you must decide what network manager you want to use and only use this one. For RaspiOS you may have a look at Compare three available networking systems on Raspbian.

To have a working network setup out of the box you should only use Raspberry Pi OS default dhcpcd. It can be configured for the most common use cases. For more sophisticated setups I prefer systemd-networkd. How to use that you can Use systemd-networkd for general networking. I would not use Debians ifupdown, because it is deprecated, at least on Rapberry Pi OS.

So revert /etc/network/interfaces to its initial settings and don't use dhclient and deinstall wicd. Then decide to use either dhcpcd or systemd-networkd. I suggest to start again with a fresh flashed Raspberry Pi OS.

1
  • Yes, seems issue is wicd. It fights with others and supports only one interface in time, i.e. connecting wlan0 disconnects eth0 regardless static adress. Problem is that is required by LXPanel which was default on my Raspi. I'm going edit original post.
    – TMa
    Commented Jun 9, 2020 at 9:26
1

I may be wrong, but it looks like you are running your DHCP server on the same Raspberry Pi client. If it is not the case, please ignore this answer.

A DHCP server must be configured with static IP for its interfaces. A DHCP server cannot serve itself, but only other machines on the network. This is valid for any DHCP server in the world.

Therefore, you need at least for the machines: 1) A DHCP server (a router, another RPI, ...) and 2) A client.

The client does not need a dhcpd server running on it.

1
  • this was exactly my problem, and it went away once I configured a static IP for the RPi that was running the DHCP server. Thank you for a short and sweet solution ! Commented Nov 30, 2021 at 1:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.