You are not logged in.

#1 2023-09-29 21:44:28

regexaurus
Member
Registered: 2021-09-14
Posts: 7

[SOLVED] DHCP client | no default gateway set

I have an up-to-date Arch VM that receives network configuration by DHCP reservation (the reservation includes a router option, which specifies the default gateway). At some point, the VM would no longer have a default gateway upon startup / after reboot. I can manually set a default route (e.g. ip route add default 192.168.1.1), but I would like to understand why the default gateway isn't being set automatically, and how to correct it.

Thanks in advance for advice/suggestions you can offer!

Last edited by regexaurus (2023-10-03 12:33:29)

Offline

#2 2023-09-30 06:43:46

seth
Member
Registered: 2012-09-03
Posts: 52,462

Re: [SOLVED] DHCP client | no default gateway set

https://bbs.archlinux.org/viewtopic.php?id=57855
http://www.catb.org/~esr/faqs/smart-questions.html

Specifically what is supposed to configure the network?
Please post the output of

find /etc/systemd -type l -exec test -f {} \; -print | awk -F'/' '{ printf ("%-40s | %s\n", $(NF-0), $(NF-1)) }' | sort -f

And otherwise if you want to know what fails I'd start by looking into your system journal.

Online

#3 2023-10-02 14:47:49

regexaurus
Member
Registered: 2021-09-14
Posts: 7

Re: [SOLVED] DHCP client | no default gateway set

dbus-org.freedesktop.network1.service		|	system
dhcpcd@enp0s10f0.service			|	multi-user.target.wants
getty@tty1.service				|	getty.target.wants
httpd.service					|	multi-user.target.wants
p11-kit-server.socket				|	sockets.target.wants
remote-fs.target				|	multi-user.target.wants
sshd.service					|	multi-user.target.wants
systemd-networkd.service			|	multi-user.target.wants
systemd-networkd.socket				|	sockets.target.wants
systemd-networkd-wait-online.service		|	network-online.target.wants

I'm checking journal entries...

Last edited by regexaurus (2023-10-02 15:11:18)

Offline

#4 2023-10-02 15:10:22

seth
Member
Registered: 2012-09-03
Posts: 52,462

Re: [SOLVED] DHCP client | no default gateway set

Please use [code][/code] tags. Edit your post in this regard.

You've systemd-network and dhcpcd enabled, they'lll both try to configure enp0s10f0 - pick one, disable the other.

Online

#5 2023-10-02 15:43:29

regexaurus
Member
Registered: 2021-09-14
Posts: 7

Re: [SOLVED] DHCP client | no default gateway set

Output for: systemctl status dhcpcd

○ dhcpcd.service - DHCP/ IPv4LL/ IPv6RA/ DHCPv6 client on all interfaces
     Loaded: loaded (/usr/lib/systemd/system/dhcpcd.service; disabled; preset: disabled)
     Active: inactive (dead)

...and systemctl status systemd-networkd

● systemd-networkd.service - Network Configuration
     Loaded: loaded (/usr/lib/systemd/system/systemd-networkd.service; enabled; preset: enabled)
     Active: active (running) since Fri 2023-09-29 17:39:09 EDT; 2 days ago
TriggeredBy: ● systemd-networkd.socket

Offline

#6 2023-10-02 15:45:43

seth
Member
Registered: 2012-09-03
Posts: 52,462

Re: [SOLVED] DHCP client | no default gateway set

systemctl status dhcpcd@enp0s10f0.service

You've it enbaled for that NIC only.

Online

#7 2023-10-02 18:15:37

regexaurus
Member
Registered: 2021-09-14
Posts: 7

Re: [SOLVED] DHCP client | no default gateway set

Thank you! I stopped and disabled dhcpcd@enp0s10f0.service

sudo systemctl disable dhcpcd@enp0s10f0.service
sudo systemctl stop dhcpcd@enp0s10f0.service

created /etc/systemd/network/20-wired.network

[Match]
Name=enp0s10f0

[Network]
DHCP=ipv4

[DHCP]
ClientIdentifier=mac

and restarted systemd-networkd

sudo systemctl restart systemd-networkd

Now, in output for systemctl status systemd-networkd, I see

enp0s10f0: DHCPv4 address 192.168.1.59/24, gateway 192.168.1.1 acquired from 192.168.1.1

But ip route still doesn't show a default route for that gateway, and an attempt to ping a public IP address results in: "connect: Network is unreachable." I've tried adding DefaultRouteOnDevice=true to the [Network] section of 20-wired.network. After making this change and restarting systemd-networkd, I see an additional route entry

default dev enp0s10f0 proto static scope link

and a different error when attempting to ping a public IP address

From 192.168.1.59 icmp_seq=1 Destination Host Unreachable

If I manually add the default route as before, I can ping a public IP address

sudo ip route add default via 192.168.1.1

Not sure what I'm missing...

Offline

#8 2023-10-02 18:30:32

seth
Member
Registered: 2012-09-03
Posts: 52,462

Re: [SOLVED] DHCP client | no default gateway set

Stop/disable systemd-networkd  and dhcpcd*, then run

sudo dhcpcd -dB

which will launch dhcpcd for all NICs in non-forking debug mode.
Post the output and obviously check "ip a; ip r"

Online

#9 2023-10-02 19:42:38

regexaurus
Member
Registered: 2021-09-14
Posts: 7

Re: [SOLVED] DHCP client | no default gateway set

OK, seeing output for that command made me suspect a static route option (DHCP server). The static route doesn't cause apparent problems for other DHCP clients, but the route isn't needed for this Arch system. Overriding static routes (no static routes) for the DHCP reservation for this system seemed to work. After re-enabling/starting systemd-networkd, a default route is created as expected.

Thank you, Seth!

Offline

#10 2023-10-02 19:54:56

seth
Member
Registered: 2012-09-03
Posts: 52,462

Re: [SOLVED] DHCP client | no default gateway set

\o/
Please always remember to mark resolved threads by editing your initial posts subject - so others will know that there's no task left, but maybe a solution to find.
Thanks.

Online

Board footer

Powered by FluxBB