我有一个基于yocto和systemd的嵌入式系统。 有2个接口eth0和wlan0,它们都使用我的路由器(互联网盒)提供的DHCP(ipv4)配置。
/etc/systemd/network/20-wired.network
[Match]
Name=eth0
[Network]
DHCP=ipv4
[DHCP]
RouteMetric=10
/etc/systemd/network/25-wireless.network
[Match]
Name=wlan0
[Network]
DHCP=ipv4
[DHCP]
RouteMetric=20
这是 ip route 的输出:
default via 192.168.1.1 dev eth0 src 192.168.1.47 metric 10
default via 192.168.1.1 dev wlan0 src 192.168.1.88 metric 20
192.168.1.0/24 dev eth0 scope link src 192.168.1.47
192.168.1.0/24 dev wlan0 scope link src 192.168.1.88
192.168.1.1 dev eth0 scope link src 192.168.1.47 metric 10
192.168.1.1 dev wlan0 scope link src 192.168.1.88 metric 20
因此,从eth0 ping通到网络上的另一台设备(192.168.1.42)时,它只能从eth0正常工作,除非我禁用了eth0。
192.168.1.47 => 192.168.1.42 : OK (eth0)
192.168.1.88 => 192.168.1.42 : KO (wlan0)
192.168.1.42 => 192.168.1.47 : OK (eth0)
192.168.1.42 => 192.168.1.88 : OK (wlan0)
这是 /etc/resolv.conf 的输出(由systemd-resoved处理):
nameserver 192.168.1.1
nameserver fe80::a63e:51ff:fe70:9e16%3
nameserver 2a01:cb08:9049:3200:a63e:51ff:fe70:9e16
如何使两个接口(eth0和wlan0)同时工作而不禁用另一个接口?
致谢