dhclient 进程弄乱了错误的接口

dhclient 进程弄乱了错误的接口

我使用的是 Debian Buster,并且配置了两个接口:eth0 和 wwan0(宽带调制解调器)。这是我的接口文件的相关部分:

# The primary network interface
auto eth0
iface eth0 inet dhcp

# Do not bring up wwan0 automatically
allow-hotplug wwan0
iface wwan0 inet dhcp
        pre-up until [ -h /dev/ublox00 ]; do sleep 1; done && echo $'AT+UCEDATA=1,0\r\n' > /dev/ublox00 && sleep 2
        post-down echo $'AT+CGACT=0\r\n' > /dev/ublox00

我注意到当我想要关闭 wwan0 时,它也会释放 eth0 的 IP 地址:

$ sudo ifdown -v wwan0
ifdown: configuring interface wwan0=wwan0 (inet)
/bin/run-parts --verbose /etc/network/if-down.d
run-parts: executing /etc/network/if-down.d/wpasupplicant
/sbin/dhclient -4 -v -i -r -pf /run/dhclient.wwan0.pid -lf /var/lib/dhcp/dhclient.wwan0.leases -I -df /var/lib/dhcp/dhclient6.wwan0.leases wwan0
Killed old client process
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/98:f0:7b:98:7a:89
Sending on   LPF/eth0/98:f0:7b:98:7a:89
Listening on LPF/wwan0/ee:bc:6c:be:6d:7c
Sending on   LPF/wwan0/ee:bc:6c:be:6d:7c
Sending on   Socket/fallback
DHCPRELEASE of 192.168.1.101 on eth0 to 192.168.1.1 port 67
DHCPRELEASE of 100.68.214.247 on wwan0 to 100.68.214.248 port 67
/sbin/ip link set dev wwan0 down
/bin/run-parts --verbose /etc/network/if-post-down.d
run-parts: executing /etc/network/if-post-down.d/hostapd
run-parts: executing /etc/network/if-post-down.d/wireless-tools
run-parts: executing /etc/network/if-post-down.d/wpasupplicant
echo $'AT+CGACT=0\r\n' > /dev/ublox00

并在调出界面后再次请求:

$ sudo ifup -v wwan0
ifup: configuring interface wwan0=wwan0 (inet)
until [ -h /dev/ublox00 ]; do sleep 1; done && echo $'AT+UCEDATA=1,0\r\n' > /dev/ublox00 && sleep 2
/bin/run-parts --exit-on-error --verbose /etc/network/if-pre-up.d
run-parts: executing /etc/network/if-pre-up.d/hostapd
run-parts: executing /etc/network/if-pre-up.d/wireless-tools
run-parts: executing /etc/network/if-pre-up.d/wpasupplicant

/sbin/dhclient -4 -v -i -pf /run/dhclient.wwan0.pid -lf /var/lib/dhcp/dhclient.wwan0.leases -I -df /var/lib/dhcp/dhclient6.wwan0.leases wwan0
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/98:f0:7b:98:7a:89
Sending on   LPF/eth0/98:f0:7b:98:7a:89
Listening on LPF/wwan0/ee:bc:6c:be:6d:7c
Sending on   LPF/wwan0/ee:bc:6c:be:6d:7c
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
DHCPDISCOVER on wwan0 to 255.255.255.255 port 67 interval 6
DHCPOFFER of 192.168.1.101 from 192.168.1.1
DHCPREQUEST for 192.168.1.101 on eth0 to 255.255.255.255 port 67
DHCPOFFER of 100.68.214.247 from 100.68.214.248
DHCPREQUEST for 100.68.214.247 on wwan0 to 255.255.255.255 port 67
DHCPACK of 100.68.214.247 from 100.68.214.248
bound to 100.68.214.247 -- renewal in 74796 seconds.
/bin/run-parts --exit-on-error --verbose /etc/network/if-up.d
run-parts: executing /etc/network/if-up.d/wpasupplicant

命令sudo ifdown eth0sudo ifup eth0操作仅按预期在 eth0 上进行。请帮我找出问题所在。

我的ifupdown版本是0.8.35。

答案1

我想我找到了这个问题的原因。

搜索interface "name" { declarations ... }https://linux.die.net/man/5/dhclient.conf:

具有多个网络接口的客户端可能需要不同的行为,具体取决于正在配置的接口。除租约和别名声明之外的所有计时参数和声明都可以包含在接口声明中,然后这些参数将仅用于与指定名称匹配的接口。没有接口声明的接口将使用在任何接口声明之外声明的参数或默认设置。

注意好:ISC dhclient 仅维护一个接口列表,该列表要么在启动时通过命令行参数确定,要么自动检测。如果您在命令行上提供了接口列表,则此配置子句会将指定接口添加到列表中,从而使其由 DHCP 配置。这可能不是您想要的结果。这是一个不良的副作用,将在未来的版本中解决。

我的文件中包含此部分,dhclient.conf因为我想为 eth0 添加特定的 DNS 服务器。如果我删除此部分,问题就会消失。

相关内容