[SOLVED] Ubuntu 24.04-2 template not picking up default gateway

karypid

Active Member
Mar 7, 2021
38
10
28
47
Apologies for the really basic question, but after setting up an LXC using ubuntu-24.04-2 template I have noticed that it is not picking up the default gateway. The only change to defaults was basically choosing DHCP instead of static for IPv4. I noticed proxmox seems to know how the distro manages networking and generates some files:

Code:
root@try1:~# cat /etc/systemd/network/eth0.network
[Match]
Name = eth0

[Network]
Description = Interface eth0 autoconfigured by PVE
DHCP = ipv4
IPv6AcceptRA = false

root@try1:~# cat /etc/resolv.conf
# --- BEGIN PVE ---
search ad.home.lan
nameserver 192.168.9.201
# --- END PVE ---

I can ping the internal network and lookup works, but cannot get to the internet due to missing default route:

Code:
root@try1:~# nslookup www.proxmox.com
Server:        192.168.9.201
Address:    192.168.9.201#53

Non-authoritative answer:
Name:    www.proxmox.com
Address: 212.224.123.69
Name:    www.proxmox.com
Address: 2a01:7e0:0:424::12

root@try1:~# ping www.proxmox.com
ping: connect: Network is unreachable

root@try1:~# ip route
192.168.9.0/24 dev eth0 proto kernel scope link src 192.168.9.187 metric 1024
192.168.9.10 dev eth0 proto dhcp scope link src 192.168.9.187 metric 1024
192.168.9.253 dev eth0 proto dhcp scope link src 192.168.9.187 metric 1024
192.168.42.0/24 via 192.168.9.10 dev eth0 proto dhcp src 192.168.9.187 metric 1024
192.168.43.0/24 via 192.168.9.10 dev eth0 proto dhcp src 192.168.9.187 metric 1024

Note that 192.168.9.253 is the gateway running OPNSense. I use DNSMasq and have option 121 set for the internal routes, but nothing to specify the default route. I expect this is provided by default as other devices seem to be able to configure themselves properly.

What other network configuration does Proxmox generate and what should I look at?

EDIT: I am now sure it is not OPNSense as I noticed in the log:

Code:
Oct 06 11:19:01 systemd-networkd[117]: eth0: DHCPv4 address 192.168.9.187/24, gateway 192.168.9.253 acquired from 192.168.9.253
 
Last edited:
In the systemd manual page, seems like this is expected behavior (guess NetworkManager does not follow this as my laptop / PC works without it):

UseGateway=
When true, and the DHCP server provides a Router option, the default gateway based on the router address will be configured.
Defaults to unset, and the value specified with UseRoutes= will be used.

Note, when the server provides both the Router and Classless Static Routes option, and UseRoutes= is enabled, the Router
option is always ignored regardless of this setting.
See RFC 3442[26].

I edited the option 121 in OPNSense to add the default route there and now it is picked up properly by the LXC. So turns out not a proxmox issue, but leaving this here just in case someone runs into it...