4

On fresh installs of Debian Jessie, after I set a static ip address, the DHCP client is still active. It even revert back to the dhcp ip address when the lease is renewed.

step 1: I modify /etc/network/interfaces:

source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet static
        address   192.168.0.8
        netmask   255.255.255.0
        network   192.168.0.0
        broadcast 192.168.0.255
        gateway   192.168.0.5

step 2: I restart the network systemctl restart networking.service (no error message)

step 3: check if dhclient is running: ps x | grep [d]hclient
--> dhclient -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases eth0

If I reboot, dhclient is still launched.
I have this behavior on every Debian Jessie I install with static ip address.

I don't find were dhclient is launched: find and grep didn't found anything into /etc and /usr/lib
I'm not accustomed with systemd, and I don't understand dhclient is launched by systemd or not.

The running processes are (I removed my Bash session):

/sbin/init
/lib/systemd/systemd-udevd
/lib/systemd/systemd-journald
/usr/sbin/cron -f
/usr/sbin/atd -f
/lib/systemd/systemd-logind
/usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation
/usr/sbin/rsyslogd -n
/usr/sbin/acpid
/bin/login --
/usr/sbin/exim4 -bd -q30m
dhclient -v -pf /run/dhclient.eth0.pid -lf /var/lib/dhcp/dhclient.eth0.leases eth0
/usr/sbin/sshd -D
/usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 108:113

Question 1: how dhclient is launched ?
Question 2: what is the "official" way to prevent it to run ? (except with apt-get remove/purge)

Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
Gregory MOUSSAT
  • 1,673
  • 2
  • 25
  • 50

2 Answers2

3

Simple explanation:

  • You reconfigure eth0 to manual
  • networking restart will do:
    • disabling eth0 (down)
    • enabling eth0 (up)
    • setting your static ip address

Since the interface wasn't set to "dhcp" on stop the dhclient wasn't stopped.

Proper way would be:

  • stop/ifdown
  • reconfigure
  • start/ifup

Or taking care about dhclient manually. And it shouldn't start after a reboot for sure.

lazyfrosch
  • 790
  • 4
  • 10
1

The dhcp client is just unable to detect someone configured another ip address. So you have to kill it when you set a static address.

The only mystery is: why when I rebooted a test server, the dhcp client was still there ?
I just did the test again on another server and no problem. So I guess it was just me. I missed or forgot something.

Gregory MOUSSAT
  • 1,673
  • 2
  • 25
  • 50