iupdown更改参数dhclient



我有Ubuntu 20.04,我把所有的网络功能都给了iuppdown。

我的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版本:

# 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

我怎么能做到呢?

谢谢!

dhclient运行参数硬编码在iuppdown,你不能从其他地方改变它。

但我找到了一个解决方案:

  1. 设置接口为静态,以防止通过ifup命令启动dhclient
  2. 运行dhclient与任何你想要的参数preup hook
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

相关内容

  • 没有找到相关文章

最新更新