Comment 28 for bug 1867375

Dan Streetman (ddstreet) wrote :

bionic:

root@lp1867375-b:~# cat /etc/systemd/network/10.network
[Match]
Name=eth0

[Network]
DHCP=ipv4
LinkLocalAddressing=ipv6

[DHCP]
RouteMetric=100
UseMTU=true
UseRoutes=false
UseGateway=true

root@lp1867375-b:~# dpkg -l systemd|grep systemd
ii systemd 237-3ubuntu10.40 amd64 system and service manager
root@lp1867375-b:~# systemctl restart systemd-networkd
root@lp1867375-b:~# ip a show eth0
102: eth0@if103: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:16:3e:f8:cb:57 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.202.51.83/24 brd 10.202.51.255 scope global dynamic eth0
       valid_lft 3598sec preferred_lft 3598sec
    inet6 fe80::216:3eff:fef8:cb57/64 scope link
       valid_lft forever preferred_lft forever
root@lp1867375-b:~# ip r
10.202.51.0/24 dev eth0 proto kernel scope link src 10.202.51.83

root@lp1867375-b:~# dpkg -l systemd|grep systemd
ii systemd 237-3ubuntu10.41 amd64 system and service manager
root@lp1867375-b:~# systemctl restart systemd-networkd
root@lp1867375-b:~# ip a show eth0
102: eth0@if103: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:16:3e:f8:cb:57 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.202.51.83/24 brd 10.202.51.255 scope global dynamic eth0
       valid_lft 3598sec preferred_lft 3598sec
    inet6 fe80::216:3eff:fef8:cb57/64 scope link
       valid_lft forever preferred_lft forever
root@lp1867375-b:~# ip r
default via 10.202.51.1 dev eth0 proto dhcp src 10.202.51.83 metric 100
10.202.51.0/24 dev eth0 proto kernel scope link src 10.202.51.83
10.202.51.1 dev eth0 proto dhcp scope link src 10.202.51.83 metric 100

and to verify UseRoutes still works:

root@lp1867375-b:~# cat /etc/systemd/network/10.network
[Match]
Name=eth0

[Network]
DHCP=ipv4
LinkLocalAddressing=ipv6

[DHCP]
RouteMetric=100
UseMTU=true
UseRoutes=false
#UseGateway=true

root@lp1867375-b:~# systemctl restart systemd-networkd
root@lp1867375-b:~# ip r
10.202.51.0/24 dev eth0 proto kernel scope link src 10.202.51.83