Home > Mobile >  ifupdown change parameters dhclient
ifupdown change parameters dhclient

Time:04-20

I have Ubuntu 20.04 where I gave all network functions to ifupdown.

1 of my interface got network parameters by dhclient:

#/etc/network/interfaces
allow-hotplug enp2s0
auto enp2s0
iface enp2s0 inet dhcp

Dhclient starts with such parameters:

#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:

# dhclient --version
isc-dhclient-4.4.1

Client config:

# 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;

Tired to google how to change parameters for dhclient start(I want to start it without -1 and in daemon mode), like this:

/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

How I can do it?

Thank you!

CodePudding user response:

dhclient run parameters hardcoded inside ifupdown, you can't change it from elsewhere.

But I found a solution:

  1. set interface as static to prevent start dhclient by ifup command
  2. run dhclient with whatever parameters you want by pre-up 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
  • Related