我希望 systemd-networkd 忽略一个接口上由 DHCP 推送的默认路由。
我的工作设置有 3 个网络接口。每个接口都有一个 .network 文件:
eth0:互联网
[Match]
Name=eth0
[Network]
DHCP=yes
DNS=127.0.0.1
eth1:本地测试网络
[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 路由器连接到主站点。
[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:不与虚拟机实际接口连接的桥接接口
[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
如您所见,UseRoutes=false
已设置完毕,并且在 eth2 网络上仍然有默认路由:
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
我也尝试过,UseRoutes=no
但没有任何区别。有人知道我做错了什么吗?
版本和软件包:
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