我有 Ubuntu 20.04,我將所有網路功能都交給了 ifupdown。
我的介面的 1 個通過 dhclient 獲取網路引數:
#/etc/network/interfaces
allow-hotplug enp2s0
auto enp2s0
iface enp2s0 inet dhcp
Dhclient 以這樣的引數開始:
#ps -Af | grep dhclient
/sbin/dhclient -1 -4 -v -i -pf /run/dhclient.enp2s0.pid -lf /var/lib/dhcp/dhclient.enp2s0.leases -I -df /var/lib/dhcp/dhclient6.enp2s0.leases enp2s0
客戶端版本:
# dhclient --version
isc-dhclient-4.4.1
客戶端配置:
# cat /etc/dhcp/dhclient.conf
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;
timeout 60;
retry 60;
reboot 10;
reject 10.100.0.2;
厭倦了谷歌如何更改 dhclient 啟動的引數(我想在沒有 -1 和守護程式模式的情況下啟動它),如下所示:
/sbin/dhclient -nw -4 -v -pf /run/dhclient.enp2s0.pid -lf /var/lib/dhcp/dhclient.enp2s0.leases -I -df /var/lib/dhcp/dhclient6.enp2s0.leases enp2s0
我該怎么做?
謝謝!
uj5u.com熱心網友回復:
dhclient 運行引數在 ifupdown 中硬編碼,您無法從其他地方更改它。
但我找到了解決方案:
- 將介面設定為靜態以防止通過 ifup 命令啟動 dhclient
- 通過 pre-up hook 使用您想要的任何引數運行 dhclient
allow-hotplug enp2s0
auto enp2s0
iface enp2s0 inet static
address 192.168.1.1
netmask 255.255.255.255
pre-up /sbin/dhclient -4 -v -pf /run/dhclient.enp2s0.pid -lf /var/lib/dhcp/dhclient.enp2s0.leases -I -df /var/lib/dhcp/dhclient6.enp2s0.leases enp2s0
pre-down /sbin/dhclient -4 -v -r -pf /run/dhclient.enp2s0.pid -lf /var/lib/dhcp/dhclient.enp2s0.leases -I -df /var/lib/dhcp/dhclient6.enp2s0.leases enp2s0
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/459786.html
上一篇:Docker內部的Pip和Powershell:standard_init_linux.go:228:exec用戶行程導致:exec格式錯誤
