You are not logged in.

#1 2021-09-11 01:10:37

bbus
Member
Registered: 2019-03-14
Posts: 49

dhcpcd.conf with fallback to static IP

I am trying to setup DHCP with a fallback to a static ip address on a wired port.

For starters,
a) the situation: I'm connecting to my friend's SUSE machine with an ethernet cable, and his side is configured properly with a static IP (i.e. he can directly plug into a zedboard which also has a static IP and the two machines talk as expected)
aa) I'm running native arch linux
b) if I manually run

$ sudo ip addr add local 169.254.8.201/24 dev eth0

"ip addr" shows the address has been applied and the link is up, and I can ping, ssh, et cetera into my friend's machine.

c) "$ sudo systemctl start dhcpcd@eth0.service" works as expected when I plug the ethernet cable into a router running a dhcp server
d) I have verified that I have no other network daemons enabled/started/running
e) I've replaced the really long "enp..." nic name from systemd with eth0 herein for simplicity

Now for the broken part:

I am using the default "dhcpcd.conf", with these next few lines added to the end of it:

profile static_eth0
static ip_address=169.254.8.201/24

interface eth0
fallback static_eth0

After I "sudo systemctl start dhcpcd@eth0.service" (while connected to my friend's machine), I get the following output from "systemctl status dhcpcd@eth0.servie":

$ sudo systemctl status dhcpcd@eth0.service
● dhcpcd@eth0.service - dhcpcd on eth0
     Loaded: loaded (/usr/lib/systemd/system/dhcpcd@.service; disabled; vendor preset: disabled)
     Active: active (running) since Fri 2021-09-10 14:39:01 MDT; 6s ago
    Process: 1236934 ExecStart=/usr/bin/dhcpcd -q -w eth0 (code=exited, status=0/SUCCESS)
   Main PID: 1236936 (dhcpcd)
      Tasks: 5 (limit: 38191)
     Memory: 1.3M
        CPU: 53ms
     CGroup: /system.slice/system-dhcpcd.slice/dhcpcd@eth0.service
             ├─1236936 "dhcpcd: eth0 [ip4] [ip6]" "" ""
             ├─1236937 "dhcpcd: [privileged actioneer] eth0 [ip4] [ip6]"
             ├─1236938 "dhcpcd: [network proxy] eth0 [ip4] [ip6]"
             ├─1236939 "dhcpcd: [control proxy] eth0 [ip4] [ip6]"
             └─1236944 "dhcpcd: [network proxy] fe80::a2ce:c8ff:fed4:b45b"

Sep 10 14:38:56 myhostname dhcpcd[1236937]: eth0: probing address 169.254.8.201/24
Sep 10 14:38:57 myhostname dhcpcd[1236937]: eth0: soliciting an IPv6 router
Sep 10 14:39:01 myhostname dhcpcd[1236937]: eth0: using static address 169.254.8.201/24
Sep 10 14:39:01 myhostname dhcpcd[1236937]: eth0: adding route to 169.254.8.0/24
Sep 10 14:39:01 myhostname dhcpcd[1236937]: eth0: adding default route via 169.254.8.1
Sep 10 14:39:01 myhostname dhcpcd[1236937]: eth0: deleting route to 169.254.8.0/24
Sep 10 14:39:01 myhostname dhcpcd[1237977]: ps_inet_listenin: Cannot assign requested address
Sep 10 14:39:01 myhostname dhcpcd[1237977]: ps_root_recvmsg: Cannot assign requested address
Sep 10 14:39:01 myhostname systemd[1]: Started dhcpcd on eth0.
Sep 10 14:39:01 myhostname dhcpcd[1236937]: eth0: deleting default route via 169.254.8.1

and "ip addr" also shows the nic has not received an ip address.

I've tried adding various forms of "static routers=169.254.8.1" among other things, but haven't been able to get the service to work. Any tips on where I could look for more clues as to the issue? Is it required I add a static route in the exit-hook? It doesn't seem like that should be required, from my understanding.

Offline

#2 2021-09-11 04:54:34

solskog
Member
Registered: 2020-09-05
Posts: 462

Re: dhcpcd.conf with fallback to static IP

please output your entire /etc/dhcpcd.conf

Offline

#3 2021-09-11 05:06:16

bbus
Member
Registered: 2019-03-14
Posts: 49

Re: dhcpcd.conf with fallback to static IP

/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

# vendorclassid is set to blank to avoid sending the default of
# dhcpcd-<version>:<os>:<machine>:<platform>
vendorclassid

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# Request a hostname from the network
option host_name

# Most distributions have NTP support.
#option ntp_servers

# 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 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
noipv4ll

# ======================================
# default above, my custom additions below

# define static profile
profile static_eth0

# static ip_address=192.168.1.23/24
# static routers=192.168.1.1
# static domain_name_servers=192.168.1.1

static ip_address=169.254.8.201/24
# static routers=169.254.8.1
# static domain_name_servers=169.254.8.1
# static routers=0.0.0.0
# static domain_name_servers=0.0.0.0

# ---

# fallback to static profile on <nic>

# all the various names given for the various adapters
# and ports on this machine. I will only ever have one
# plugged in at a time.

interface enp0s20f0u1u4
fallback static_eth0

# interface enp0s20f0u3
# fallback static_eth0

# interface enp0s20f0u4
# fallback static_eth0

# interface enp0s20f0u5u4
# fallback static_eth0

# interface enp56s0u1u4
# fallback static_eth0

# interface enp56s0u2
# fallback static_eth0

# interface enp56s0u2u4
# fallback static_eth0

# ======================================

edit: comment out "static routers" to reflect the state the config was in when the output printed in the first post was generated.

Last edited by bbus (2021-09-11 05:08:15)

Offline

#4 2021-09-11 06:08:13

solskog
Member
Registered: 2020-09-05
Posts: 462

Re: dhcpcd.conf with fallback to static IP

With almost identical dhcpcd.conf, in my own testbed setup, I disabled dhcpcd.service and enable/start dhcpcd@enp0s1.service and it works as expected. I notices in your systemctl status dhcpcd@eth0.service there were neither "DHCP lease" nor "selected profile"

# dhcpcd --version
dhcpcd 9.4.0
# uname -a
Linux tree 5.14.2-arch1-2 #1 SMP PREEMPT Thu, 09 Sep 2021 09:42:35 +0000 x86_64 GNU/Linux

# systemctl status dhcpcd@enp0s1.service
Sep 11 07:14:01 solskog dhcpcd[279]: enp0s1: adding address fe80::c11f:aa44:aaa2:73d5
Sep 11 07:14:02 solskog dhcpcd[279]: enp0s1: soliciting an IPv6 router
Sep 11 07:14:03 solskog dhcpcd[279]: enp0s1: rebinding lease of 192.168.40.37
Sep 11 07:14:08 solskog dhcpcd[279]: enp0s1: DHCP lease expired
Sep 11 07:14:08 solskog dhcpcd[279]: enp0s1: soliciting a DHCP lease
Sep 11 07:14:13 solskog dhcpcd[279]: enp0s1: selected profile egress
Sep 11 07:14:13 solskog dhcpcd[279]: enp0s1: IAID 4c:68:0c:49
Sep 11 07:14:13 solskog dhcpcd[279]: enp0s1: using static address 169.254.8.201/24
Sep 11 07:14:13 solskog dhcpcd[279]: enp0s1: adding route to 169.254.8.0/24
Sep 11 07:14:14 solskog dhcpcd[279]: enp0s1: soliciting an IPv6 router

What is output from your

# dhcpcd --version
# systemctl status dhcpcd
# dhcpcd -4

Last edited by solskog (2021-09-11 07:30:27)

Offline

#5 2021-09-12 00:40:04

bbus
Member
Registered: 2019-03-14
Posts: 49

Re: dhcpcd.conf with fallback to static IP

Note, I've using a different adapter today, so it is using a different enp* compared to yesterday. Further, I don't have access to my friend's machine, so I was only able to connect my primary laptop to an old one I have around the house. The second machine is also running Arch, and I put the identical /etc/dhcpcd.conf on it, with the only thing being altered is the name of the nic.

I just rebooted again, so it was fresh. I powered off my wireless card, and stopped iwd.service.
I then plugged in the cable, waited a few seconds, then ran "start dhcpcd@interface.service":

Is it required to have the "static routers=<169.254.8.1>" line? Without it:

~ » sudo systemctl start dhcpcd@enp56s0u2u4.service

~ » dhcpcd --version
dhcpcd 9.4.0
Copyright (c) 2006-2020 Roy Marples
Compiled in features: INET ARP ARPing IPv4LL INET6 DHCPv6 AUTH PRIVSEP

~ » sudo systemctl start dhcpcd@enp56s0u2u4.service

~ » sudo systemctl status dhcpcd@enp56s0u2u4.service
● dhcpcd@enp56s0u2u4.service - dhcpcd on enp56s0u2u4
     Loaded: loaded (/usr/lib/systemd/system/dhcpcd@.service; disabled; vendor preset: disabled)
     Active: active (running) since Sat 2021-09-11 18:50:57 MDT; 6s ago
    Process: 36218 ExecStart=/usr/bin/dhcpcd -q -w enp56s0u2u4 (code=exited, status=0/SUCCESS)
   Main PID: 36220 (dhcpcd)
      Tasks: 5 (limit: 38191)
     Memory: 1.9M
        CPU: 44ms
     CGroup: /system.slice/system-dhcpcd.slice/dhcpcd@enp56s0u2u4.service
             ├─36220 "dhcpcd: enp56s0u2u4 [ip4] [ip6]" "" ""
             ├─36221 "dhcpcd: [privileged actioneer] enp56s0u2u4 [ip4] [ip6]"
             ├─36222 "dhcpcd: [network proxy] enp56s0u2u4 [ip4] [ip6]"
             ├─36223 "dhcpcd: [control proxy] enp56s0u2u4 [ip4] [ip6]"
             └─36225 "dhcpcd: [network proxy] fe80::a2ce:c8ff:fed4:b45b"

Sep 11 18:50:52 myhostname dhcpcd[36221]: enp56s0u2u4: selected profile static_eth0
Sep 11 18:50:52 myhostname dhcpcd[36221]: enp56s0u2u4: IAID c8:d4:b4:5b
Sep 11 18:50:52 myhostname dhcpcd[36221]: enp56s0u2u4: probing address 169.254.8.201/24
Sep 11 18:50:52 myhostname dhcpcd[36221]: enp56s0u2u4: soliciting an IPv6 router
Sep 11 18:50:57 myhostname dhcpcd[36221]: enp56s0u2u4: using static address 169.254.8.201/24
Sep 11 18:50:57 myhostname dhcpcd[36221]: enp56s0u2u4: adding route to 169.254.8.0/24
Sep 11 18:50:57 myhostname dhcpcd[37291]: ps_inet_listenin: Cannot assign requested address
Sep 11 18:50:57 myhostname dhcpcd[37291]: ps_root_recvmsg: Cannot assign requested address
Sep 11 18:50:57 myhostname systemd[1]: Started dhcpcd on enp56s0u2u4.
Sep 11 18:50:57 myhostname dhcpcd[36221]: enp56s0u2u4: deleting route to 169.254.8.0/24

~ » sudo dhcpcd -4
dhcpcd-9.4.0 starting
dev: loaded udev
DUID 00:04:4c:4c:45:44:00:4a:37:10:80:53:c2:c0:4f:34:35:33
enp56s0u2u4: IAID c8:d4:b4:5b
enp56s0u2u4: soliciting a DHCP lease
enp56s0u2u4: selected profile static_eth0
enp56s0u2u4: IAID c8:d4:b4:5b
enp56s0u2u4: probing address 169.254.8.201/24
enp56s0u2u4: using static address 169.254.8.201/24
enp56s0u2u4: adding route to 169.254.8.0/24
forked to background, child pid 40981

~ » 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: enp56s0u2u4: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether a0:ce:c8:d4:b4:5b brd ff:ff:ff:ff:ff:ff
    inet6 fe80::a2ce:c8ff:fed4:b45b/64 scope link 
       valid_lft forever preferred_lft forever

~ » uname -a 
Linux myhostname 5.14.2-arch1-2 #1 SMP PREEMPT Thu, 09 Sep 2021 09:42:35 +0000 x86_64 GNU/Linux

That time "dhcpcd -4" seemed to assign a static ip, but "ip addr" reports that it still doesn't have that IP.

edit: realized at some point this morning I had added a bogus line by accident in "/etc/dhcpcd.conf". I also realized that changes via "sudoedit" don't take effect until after I exit (is this right?). In my testing yesterday, I was ":w" but not exiting, So most of my tests yesterday probably were never running on different versions that I thought I was. Either way, the info above was created with the following conf, I "cat"ed it this time, after exiting "sudoedit" and this is the direct copy, unaltered,that the above results were genereated with:

~ » cat /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

# vendorclassid is set to blank to avoid sending the default of
# dhcpcd-<version>:<os>:<machine>:<platform>
vendorclassid

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search
option classless_static_routes
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# Request a hostname from the network
option host_name

# Most distributions have NTP support.
#option ntp_servers

# 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 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
noipv4ll

# ======================================

# define static profile
profile static_eth0

# static ip_address=192.168.1.23/24
# static routers=192.168.1.1
# static domain_name_servers=192.168.1.1

static ip_address=169.254.8.201/24
# static routers=169.254.8.1
# static domain_name_servers=169.254.8.1
# static routers=0.0.0.0
# static domain_name_servers=0.0.0.0

# fallback to static profile on eth0
# interface eth0


# interface enp0s20f0u1u4
# fallback static_eth0
# 
# interface enp0s20f0u3
# fallback static_eth0
# 
# interface enp0s20f0u4
# fallback static_eth0
# 
# interface enp0s20f0u5u4
# fallback static_eth0
# 
# interface enp56s0u1u4
# fallback static_eth0
# 
# interface enp56s0u2
# fallback static_eth0

interface enp56s0u2u4
fallback static_eth0

# ======================================

edit 2:
just realized you wanted the raw "status dhcpcd.service" so here is the output of this boot from journalctl:

~ » sudo journalctl -b0 -u dhcpcd@enp56s0u2u4.service
-- Journal begins at Tue 2020-11-10 16:57:12 MST, ends at Sat 2021-09-11 19:03:52 MDT. --
Sep 11 18:50:46 myhostname systemd[1]: Starting dhcpcd on enp56s0u2u4...
Sep 11 18:50:46 myhostname dhcpcd[36218]: dhcpcd-9.4.0 starting
Sep 11 18:50:46 myhostname dhcpcd[36221]: DUID 00:04:4c:4c:45:44:00:4a:37:10:80:53:c2:c0:4f:34:35:33
Sep 11 18:50:46 myhostname dhcpcd[36221]: enp56s0u2u4: IAID c8:d4:b4:5b
Sep 11 18:50:46 myhostname dhcpcd[36221]: enp56s0u2u4: soliciting an IPv6 router
Sep 11 18:50:47 myhostname dhcpcd[36221]: enp56s0u2u4: soliciting a DHCP lease
Sep 11 18:50:52 myhostname dhcpcd[36221]: enp56s0u2u4: selected profile static_eth0
Sep 11 18:50:52 myhostname dhcpcd[36221]: enp56s0u2u4: IAID c8:d4:b4:5b
Sep 11 18:50:52 myhostname dhcpcd[36221]: enp56s0u2u4: probing address 169.254.8.201/24
Sep 11 18:50:52 myhostname dhcpcd[36221]: enp56s0u2u4: soliciting an IPv6 router
Sep 11 18:50:57 myhostname dhcpcd[36221]: enp56s0u2u4: using static address 169.254.8.201/24
Sep 11 18:50:57 myhostname dhcpcd[36221]: enp56s0u2u4: adding route to 169.254.8.0/24
Sep 11 18:50:57 myhostname dhcpcd[37291]: ps_inet_listenin: Cannot assign requested address
Sep 11 18:50:57 myhostname dhcpcd[37291]: ps_root_recvmsg: Cannot assign requested address
Sep 11 18:50:57 myhostname systemd[1]: Started dhcpcd on enp56s0u2u4.
Sep 11 18:50:57 myhostname dhcpcd[36221]: enp56s0u2u4: deleting route to 169.254.8.0/24
Sep 11 18:51:04 myhostname dhcpcd[36221]: enp56s0u2u4: no IPv6 Routers available

~ » sudo journalctl -b0 -u dhcpcd.service
-- Journal begins at Tue 2020-11-10 16:57:12 MST, ends at Sat 2021-09-11 19:03:58 MDT. --
-- No entries --

Last edited by bbus (2021-09-12 01:06:47)

Offline

#6 2021-09-12 02:44:16

solskog
Member
Registered: 2020-09-05
Posts: 462

Re: dhcpcd.conf with fallback to static IP

bbus wrote:

Is it required to have the "static routers=<169.254.8.1>" line?

No I don't have a router defined for Link-local address range. Your dhcpcd.conf is correct.

bbus wrote:

Sep 10 14:39:01 myhostname dhcpcd[1237977]: ps_inet_listenin: Cannot assign requested address
Sep 10 14:39:01 myhostname dhcpcd[1237977]: ps_root_recvmsg: Cannot assign requested address

These two lines indicate something prevent the adapter been assigned. So I suspect the problem is NOT your dhcpcd service. Are you still be able to manually add ip address to this adapter? And you are positive no other network services running e.g: systemd-networkd, networkManager etc?

Last edited by solskog (2021-09-12 03:17:52)

Offline

#7 2021-09-14 04:30:14

bbus
Member
Registered: 2019-03-14
Posts: 49

Re: dhcpcd.conf with fallback to static IP

I haven't yet looked extensively into those error messages, beyond the first few google results. But I did some more testing today, and when I replace "169.254.8.201" with "192.168.1.201" everything just works.

Here is the journalctl from a fresh boot:

~ » sudo journalctl -b0 -u dhcpcd@enp56s0u2u4.service
-- Journal begins at Tue 2020-11-10 16:57:12 MST, ends at Mon 2021-09-13 22:23:42 MDT. --
Sep 13 22:22:56 myhostname systemd[1]: Starting dhcpcd on enp56s0u2u4...
Sep 13 22:22:56 myhostname dhcpcd[18848]: dhcpcd-9.4.0 starting
Sep 13 22:22:56 myhostname dhcpcd[18851]: DUID 00:04:4c:4c:45:44:00:4a:37:10:80:53:c2:c0:4f:34:35:33
Sep 13 22:22:58 myhostname dhcpcd[18851]: enp56s0u2u4: waiting for carrier
Sep 13 22:22:58 myhostname dhcpcd[18851]: enp56s0u2u4: carrier acquired
Sep 13 22:22:58 myhostname dhcpcd[18851]: enp56s0u2u4: IAID c8:d4:b4:5b
Sep 13 22:22:58 myhostname dhcpcd[18851]: enp56s0u2u4: adding address fe80::11fe:8f6f:a8d0:bc6a
Sep 13 22:22:58 myhostname dhcpcd[18851]: enp56s0u2u4: carrier lost
Sep 13 22:22:58 myhostname dhcpcd[18851]: enp56s0u2u4: deleting address fe80::11fe:8f6f:a8d0:bc6a
Sep 13 22:22:58 myhostname dhcpcd[18851]: enp56s0u2u4: carrier acquired
Sep 13 22:22:58 myhostname dhcpcd[18851]: enp56s0u2u4: IAID c8:d4:b4:5b
Sep 13 22:22:58 myhostname dhcpcd[18851]: enp56s0u2u4: adding address fe80::11fe:8f6f:a8d0:bc6a
Sep 13 22:22:59 myhostname dhcpcd[18851]: enp56s0u2u4: soliciting an IPv6 router
Sep 13 22:22:59 myhostname dhcpcd[18851]: enp56s0u2u4: soliciting a DHCP lease
Sep 13 22:23:04 myhostname dhcpcd[18851]: enp56s0u2u4: selected profile static_eth0
Sep 13 22:23:04 myhostname dhcpcd[18851]: enp56s0u2u4: IAID c8:d4:b4:5b
Sep 13 22:23:04 myhostname dhcpcd[18851]: enp56s0u2u4: probing address 192.168.1.201/24
Sep 13 22:23:05 myhostname dhcpcd[18851]: enp56s0u2u4: soliciting an IPv6 router
Sep 13 22:23:09 myhostname dhcpcd[18851]: enp56s0u2u4: using static address 192.168.1.201/24
Sep 13 22:23:09 myhostname dhcpcd[18851]: enp56s0u2u4: adding route to 192.168.1.0/24
Sep 13 22:23:09 myhostname systemd[1]: Started dhcpcd on enp56s0u2u4.
Sep 13 22:23:17 myhostname dhcpcd[18851]: enp56s0u2u4: no IPv6 Routers available

Is there something about dhcpcd that blocks any static assignment outside of 192.168/16? Do I understand from your comment that maybe it has something to do with the hardware of my adapter?

Offline

#8 2021-09-14 05:50:08

solskog
Member
Registered: 2020-09-05
Posts: 462

Re: dhcpcd.conf with fallback to static IP

bbus wrote:

Is there something about dhcpcd that blocks any static assignment outside of 192.168/16? Do I understand from your comment that maybe it has something to do with the hardware of my adapter?

It shouldn't matter which address you assigned, they all should work.
I guess you use a USB to RJ45 adapter? It's all right, I have tested with both these adapters and real network adapters, all works.
No, the problem seems software/configuration related.
You can try with archiso install image with disabled systemd-networkd and install/configure dhcpcd on it. Or try fresh install arch into an external USB3.0 drive and test from there instead.

Last edited by solskog (2021-09-14 09:48:20)

Offline

#9 2021-09-15 07:54:09

bbus
Member
Registered: 2019-03-14
Posts: 49

Re: dhcpcd.conf with fallback to static IP

I created a new archiso usb (from the stock, Sept 01 image), and booted from it. I ran "systemctl stop systemd-networkd.socket", "systemctl stop systemd-networkd.service", and "systemctl stop systemd-networkd-wait-online.service". I added the fallback in "/etc/dhcpcd.conf" for 192.168.1.201/24 and started "dhcpcd@<nic>.service" and it worked. So I stopped the "dhcpcd@<nic>.service", flushed the ip addresses and ip routes ("ip addr flush dev <nic>" and "ip route flush dev <nic>") and changed the "dhcpcd.conf" to use the fallback 169.254.8.201/24, and again, the dhcpcd template unit failed, just as before.

I did all of this attached to a different adapter (completely different brand), to be sure it isn't something wonky with my original adapter. All the errors show the same as above, i.e. "ps_inet_listenin" and "ps_root_recvmesg".

This is very strange. Seems like it shouldn't be this difficult to assign whatever IP I want as a static fallback.

Should this be moved to "networking, server, and protection"?

Offline

#10 2021-09-15 08:50:34

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,256

Re: dhcpcd.conf with fallback to static IP

* Did you try "noipv6"?
* Can you enforce the static IP w/o the fallback?
* How many NICs are there actually in that system, are others in the 192.168.1.0/24 subnet? Are there bridges?

ip a

* How many NICs are in your friends system? Is there a rogue dhcp server in his subnet?

sudo nmap --script broadcast-dhcp-discover

Offline

#11 2021-09-15 20:55:43

bbus
Member
Registered: 2019-03-14
Posts: 49

Re: dhcpcd.conf with fallback to static IP

No, my friend's laptop wasn't connected to any other network on a different nic.
To avoid any potential doubt, I have now made two archiso usb drives.
I booted two separate towers (both the same model, hp elitedesk 800 g4, with 8th-gen, i7 processors) on the archiso.
These towers do not have any wireless nic, and only have one (intel) ethernet nic, each.

Upon booting both of them, I ran the following, and got almost identical results from both.

When

# systemctl stop systemd-networkd.socket
# systemctl stop systemd-networkd.service
# systemctl stop systemd-networkd-wait-online.service
# vim /etc/dhcpcd.conf <-- :wq (see file below)-->
# ip link
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: eno1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether c8:d9:d2:16:c1:df brd ff:ff:ff:ff:ff:ff
    altname enp0s31f6
# systemctl start dhcpcd@eno1.service
# <--connect both towers to each other directly with ethernet cable-->
# <--wait some-odd 30 seconds-->
# ip link
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: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether c8:d9:d2:16:c1:df brd ff:ff:ff:ff:ff:ff
    altname enp0s31f6
    inet6 fe80::cad9:d2ff:fe16:c1df/64 scope link
       valid_lft forever preferred_lft forever
# systemctl status dhcpcd@eno1.service
● dhcpcd@eno1.service - dhcpcd on eno1
     Loaded: loaded (/usr/lib/systemd/system/dhcpcd@.service; disabled; vendor preset: disabled)
     Active: active (running) since Wed 2021-09-15 18:42:11 UTC; 26s ago
    Process: 1245 ExecStart=/usr/bin/dhcpcd -q -w eno1 (code=exited, status=0/SUCCESS)
   Main PID: 1247 (dhcpcd)
      Tasks: 3 (limit: 38159)
     Memory: 1.6M
        CPU: 86ms
     CGroup: /system.slice/system-dhcpcd.slice/dhcpcd@eno1.service
             ├─1247 "dhcpcd: eno1 [ip4]" "" "" "" "" "" "" "" ""
             ├─1248 "dhcpcd: [privileged actioneer] eno1 [ip4]"
             └─1249 "dhcpcd: [control proxy] eno1 [ip4]"

Sep 15 18:42:00 archiso dhcpcd[1248]: eno1: soliciting a DHCP lease
Sep 15 18:42:05 archiso dhcpcd[1248]: eno1: selected profile static_eno1
Sep 15 18:42:05 archiso dhcpcd[1248]: eno1: IAID d2:16:c1:df
Sep 15 18:42:05 archiso dhcpcd[1248]: eno1: probing address 169.254.8.202/24
Sep 15 18:42:11 archiso dhcpcd[1248]: eno1: using static address 169.254.8.202/24
Sep 15 18:42:11 archiso dhcpcd[1248]: eno1: adding route to 169.254.8.0/24
Sep 15 18:42:11 archiso dhcpcd[1264]: ps_inet_listenin: Cannot assign requested address
Sep 15 18:42:11 archiso dhcpcd[1264]: ps_root_recvmsg: Cannot assign requested address
Sep 15 18:42:11 archiso systemd[1]: Started dhcpcd on eno1.
Sep 15 18:42:11 archiso dhcpcd[1248]: eno1: deleting route to 169.254.8.0/24

The "dhcpcd.conf" file I used for the results was the stock archiso version with certain things attached at the end, as before.
For space, I will only delineate the final lines that I added:

For the results above, I used:

# ======================================
noipv6rs
noipv6

profile static_eno1
static ip_address=169.254.8.202/24

interface eno1
fallback static_eno1

I also tried setting the static ip, without any fallback, both with and without including the "noipv6{rs}" options.
I would always boot fresh into the archiso, to ensure no configuration got in the way of the next.
Each time I booted, I would always run those first three commands separately (condensed here) "systemctl stop systemd-networkd{.socket,.service,-wait-online.service}"
I got very similar results each time I try to use 169.254.x.x/24.

{noipv6rs
noipv6} # <-- once with, and once without

interface eno1
static ip_address=169.254.8.202/24

With the above described configurations, there is no possible way for there to be a rogue dhcp server on any subnet of the machines.

On each of these configurations, I always got the same two errors.

Offline

#12 2021-09-15 21:52:23

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,256

Re: dhcpcd.conf with fallback to static IP

It's probably because of dhcpcd and the link local range (169.254.0.0/16 is not like 192.168.0.0/16) then.
This might be a bug (the static config as corner case catching some restriction for the non-routable IP) or config issue.
rsmarples is on the forum and posted last on 9/7 - and he'll most likely know. hmm

Offline

#13 2021-09-15 22:03:21

bbus
Member
Registered: 2019-03-14
Posts: 49

Re: dhcpcd.conf with fallback to static IP

Sounds good, thanks for looking into it. After all that testing, I hope it still doesn't turn out to be some oversight on my part. Should I make an issue on GitHub? I just found his mailing list from March announcing he has cancer, and he's looking for a new maintainer. I'd feel bad trying to contact him on Twitter or irc or something. Hope he's been able to enjoy what it sounds like may be his last bit of summer.

Offline

#14 2021-09-16 00:45:12

solskog
Member
Registered: 2020-09-05
Posts: 462

Re: dhcpcd.conf with fallback to static IP

bbus wrote:

I hope it still doesn't turn out to be some oversight on my part.

So far my tests didn't have any issue to assign any address range as fallback. Let me reproduce this.
Default dhcpcd.conf include noipv4ll, which prevent assignment of Link local address range.

man dhcpcd.conf
noipv4ll
Don't attempt to obtain an IPv4LL address if we failed to get one via DHCP.See RFC 3927.

But what really makes it to work is this option "noarp".

man dhcpcd.conf
noarp   Don't send any ARP requests.  This also disables IPv4LL.

0:systemd.status dhcpcd
● dhcpcd.service - dhcpcd on all interfaces
     Loaded: loaded (/usr/lib/systemd/system/dhcpcd.service; enabled; vendor preset:
     disabled)
     Active: active (running) since Thu 2021-09-16 03:30:29 UTC; 4min 33s ago
    Process: 2651 ExecStart=/usr/bin/dhcpcd -q -b (code=exited, status=0/SUCCESS)
   Main PID: 2653 (dhcpcd)
      Tasks: 5 (limit: 1137)
     Memory: 1.6M
        CPU: 132ms
     CGroup: /system.slice/dhcpcd.service
             ├─2653 "dhcpcd: [master] [ip4] [ip6]"
             ├─2654 "dhcpcd: [privileged actioneer]"
             ├─2655 "dhcpcd: [network proxy]"
             ├─2656 "dhcpcd: [control proxy]"
             └─2677 "dhcpcd: [BPF BOOTP]"

Sep 16 03:30:36 tree dhcpcd[2654]: enp0s4: adding route to 169.254.8.0/24
Sep 16 03:34:43 tree dhcpcd[2654]: enp0s4: carrier lost
Sep 16 03:34:43 tree dhcpcd[2654]: enp0s4: deleting route to 169.254.8.0/24
Sep 16 03:34:48 tree dhcpcd[2654]: enp0s4: carrier acquired
Sep 16 03:34:48 tree dhcpcd[2654]: enp0s4: IAID 00:d1:79:6f
Sep 16 03:34:50 tree dhcpcd[2654]: enp0s4: soliciting a DHCP lease
Sep 16 03:34:51 tree dhcpcd[2654]: enp0s4: offered 192.168.40.2 from 192.168.40.1
Sep 16 03:34:51 tree dhcpcd[2654]: enp0s4: leased 192.168.40.2 for 7200 seconds
Sep 16 03:34:51 tree dhcpcd[2654]: enp0s4: adding route to 192.168.40.0/24
Sep 16 03:34:51 tree dhcpcd[2654]: enp0s4: adding default route via 192.168.40.1
=================================================================================
0:systemd.status dhcpcd
● dhcpcd.service - dhcpcd on all interfaces
     Loaded: loaded (/usr/lib/systemd/system/dhcpcd.service; enabled; vendor preset:
     disabled)
     Active: active (running) since Thu 2021-09-16 03:30:29 UTC; 9min ago
    Process: 2651 ExecStart=/usr/bin/dhcpcd -q -b (code=exited, status=0/SUCCESS)
   Main PID: 2653 (dhcpcd)
      Tasks: 6 (limit: 1137)
     Memory: 1.8M
        CPU: 190ms
     CGroup: /system.slice/dhcpcd.service
             ├─2653 "dhcpcd: [master] [ip4] [ip6]"
             ├─2654 "dhcpcd: [privileged actioneer]"
             ├─2655 "dhcpcd: [network proxy]"
             ├─2656 "dhcpcd: [control proxy]"
             ├─2677 "dhcpcd: [BPF BOOTP]"
             └─3225 "dhcpcd: [BPF ARP] enp0s4 192.168.40.2"

Sep 16 03:37:58 tree dhcpcd[2654]: enp0s4: deleting default route via 192.168.40.1
Sep 16 03:38:01 tree dhcpcd[2654]: enp0s4: carrier acquired
Sep 16 03:38:01 tree dhcpcd[2654]: enp0s4: IAID 00:d1:79:6f
Sep 16 03:38:01 tree dhcpcd[2654]: enp0s4: rebinding lease of 192.168.40.2
Sep 16 03:38:06 tree dhcpcd[2654]: enp0s4: DHCP lease expired
Sep 16 03:38:06 tree dhcpcd[2654]: enp0s4: soliciting a DHCP lease
Sep 16 03:38:11 tree dhcpcd[2654]: enp0s4: selected profile egress
Sep 16 03:38:11 tree dhcpcd[2654]: enp0s4: IAID 00:d1:79:6f
Sep 16 03:38:11 tree dhcpcd[2654]: enp0s4: using static address 169.254.8.201/24
Sep 16 03:38:11 tree dhcpcd[2654]: enp0s4: adding route to 169.254.8.0/24

Last edited by solskog (2021-09-16 04:12:25)

Offline

#15 2021-09-16 20:19:22

bbus
Member
Registered: 2019-03-14
Posts: 49

Re: dhcpcd.conf with fallback to static IP

Confirmed, that did work. Now I know that the "LL" stands for link local. I should have known that.
So I tried it with both, (a) replacing "noipv4ll" with "noarp" and (b) including both options. They both work, as the documentation suggests that "noarp" supersedes "noipv4ll".

My question is, if "noarp" "also disables IPv4LL" how am I allowed to acquire a link local address? And another, what is ARP doing that blocks it from working when I comment out "noipv4ll" and do not include "noarp"?

Offline

#16 2021-09-16 22:32:32

solskog
Member
Registered: 2020-09-05
Posts: 462

Re: dhcpcd.conf with fallback to static IP

bbus wrote:

My question is, if "noarp" "also disables IPv4LL" how am I allowed to acquire a link local address? And another, what is ARP doing that blocks it from working when I comment out "noipv4ll" and do not include "noarp"?

This looks like to me as an "undocumented behavior".

Last edited by solskog (2021-09-16 22:43:05)

Offline

Board footer

Powered by FluxBB