How do i make systemd-networkd ignore DHCP pushed default route?

4

I want systemd-networkd ignore the default route/s pushed by DHCP on one interface.

My work setup has 3 network interfaces. I have one .network file for each interface:

eth0) internet

[Match]
Name=eth0
[Network]
DHCP=yes
DNS=127.0.0.1

eth1) local testing network

[Match]
Name=eth1

[Network]
Address=192.168.78.1/24
IPForward=ipv4
IPMasquerade=yes
DHCPServer=yes

[DHCPServer]
PoolOffset=10
PoolSize=100
EmitDNS=yes
DNS=192.168.78.1

eth2) VPN router connection to main site.

[Match]
Name=eth2

[Network]
DHCP=ipv4

[Route]
Gateway=10.3.10.1
Destination=10.100.102.0/24
Metric=0

[Route]
Gateway=10.3.10.1
Destination=10.3.13.0/24
Metric=0

[Route]
Gateway=10.3.10.1
Destination=10.3.14.0/24
Metric=0

[DHCP]
UseDNS=false
SendHostname=true
UseRoutes=false
RouteMetric=2000

vnet0) bridge interface without connection to real interface for VMs

[Match]
Name=vnet0

[Network]
Address=192.168.77.1/24
IPForward=ipv4
IPMasquerade=yes
DHCPServer=yes

[DHCPServer]
PoolOffset=10
PoolSize=100
EmitDNS=yes
DNS=192.168.77.1

As you can see UseRoutes=false is set, and still I have a default route on the eth2 network:

default via 192.168.178.1 dev eth0  proto dhcp  src 192.168.178.52  metric 1024 
default via 10.3.10.1 dev eth2  proto dhcp  src 10.3.10.196  metric 2000 
10.3.10.0/24 dev eth2  proto kernel  scope link  src 10.3.10.196 
10.3.10.1 dev eth2  proto dhcp  scope link  src 10.3.10.196  metric 2000 
192.168.77.0/24 dev vnet0  proto kernel  scope link  src 192.168.77.1 linkdown 
192.168.78.0/24 dev eth1  proto kernel  scope link  src 192.168.78.1 
192.168.178.0/24 dev eth0  proto kernel  scope link  src 192.168.178.52 
192.168.178.1 dev eth0  proto dhcp  scope link  src 192.168.178.52  metric 1024 

I also tried UseRoutes=no which also makes no difference. Does anyone have any ideas what i am doing wrong?

versions and packages:

mavu  ~  uname -a
Linux saaclt0006 4.3.0-1-amd64 #1 SMP Debian 4.3.3-2 (2015-12-17) x86_64 GNU/Linux

mavu  ~  dpkg -l |grep systemd
ii  libpam-systemd:amd64                          228-2+b1                               amd64        system and service manager - PAM module
rc  libsystemd-daemon0:amd64                      215-5+b1                               amd64        systemd utility library (deprecated)
rc  libsystemd-id128-0:amd64                      215-5+b1                               amd64        systemd 128 bit ID utility library (deprecated)
rc  libsystemd-id128-0:i386                       215-5+b1                               i386         systemd 128 bit ID utility library (deprecated)
rc  libsystemd-journal0:amd64                     215-5+b1                               amd64        systemd journal utility library (deprecated)
rc  libsystemd-journal0:i386                      215-5+b1                               i386         systemd journal utility library (deprecated)
rc  libsystemd-login0:amd64                       215-5+b1                               amd64        systemd login utility library (deprecated)
ii  libsystemd0:amd64                             228-2+b1                               amd64        systemd utility library
ii  libsystemd0:i386                              228-2+b1                               i386         systemd utility library
ii  systemd                                       228-2+b1                               amd64        system and service manager
ii  systemd-shim                                  9-1                                    amd64        shim for systemd
ii  systemd-sysv                                  228-2+b1                               amd64        system and service manager - SysV links

grep systemd-networkd /var/log/syslog :

Jan  7 09:00:56 saaclt0006 systemd-networkd[12179]: wlan0: Lost carrier
Jan  7 09:01:03 saaclt0006 systemd-networkd[12179]: eth0: Gained carrier
Jan  7 09:01:05 saaclt0006 systemd-networkd[12179]: eth2: Could not set route: Network is unreachable
Jan  7 09:01:05 saaclt0006 systemd-networkd[12179]: eth2: Could not set route: Network is unreachable
Jan  7 09:01:05 saaclt0006 systemd-networkd[12179]: eth2: Could not set route: Network is unreachable
Jan  7 09:01:05 saaclt0006 systemd-networkd[12179]: eth1: Gained carrier
Jan  7 09:01:06 saaclt0006 systemd-networkd[12179]: eth1: Gained IPv6LL
Jan  7 09:01:06 saaclt0006 systemd-networkd[12179]: eth1: Configured
Jan  7 09:01:06 saaclt0006 systemd-networkd[12179]: eth2: Gained carrier
Jan  7 09:01:06 saaclt0006 systemd-networkd[12179]: eth2: DHCPv4 address 10.3.10.196/24 via 10.3.10.1
Jan  7 09:01:07 saaclt0006 systemd-networkd[12179]: eth0: DHCPv4 address 192.168.178.52/24 via 192.168.178.1
Jan  7 09:01:08 saaclt0006 systemd-networkd[12179]: eth2: Gained IPv6LL
Jan  7 09:01:08 saaclt0006 systemd-networkd[12179]: eth2: Configured
Jan  7 09:01:19 saaclt0006 systemd-networkd[12179]: eth1: Starting DHCPv6 client after NDisc timeout failed: Invalid argument
Jan  7 09:01:21 saaclt0006 systemd-networkd[12179]: eth2: Starting DHCPv6 client after NDisc timeout failed: Invalid argument

mavu

Posted 2016-01-07T08:40:33.773

Reputation: 131

Cross-posted at https://github.com/systemd/systemd/issues/2282

– user1686 – 2016-01-07T14:05:48.447

Answers

0

This issue was indeed a bug and was fixed in systemd version 230.

networkd: respect DHCP UseRoutes option (#3075)

sshow

Posted 2016-01-07T08:40:33.773

Reputation: 1 206