![ifupdown이 dhclient 매개변수를 변경합니다.](https://linux55.com/image/204816/ifupdown%EC%9D%B4%20dhclient%20%EB%A7%A4%EA%B0%9C%EB%B3%80%EC%88%98%EB%A5%BC%20%EB%B3%80%EA%B2%BD%ED%95%A9%EB%8B%88%EB%8B%A4..png)
나는 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
DH 클라이언트 버전:
# 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
어떻게 해야 하나요?
감사합니다!
답변1
dhclient 실행 매개변수는 ifupdown 내에 하드 코딩되어 있으며 다른 곳에서 변경할 수 없습니다.
하지만 해결책을 찾았습니다.
- ifup 명령을 통해 dhclient가 시작되는 것을 방지하려면 인터페이스를 정적으로 설정하십시오.
- 원하는 매개변수를 사용하여 사전 후크를 통해 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