I am running one Ubuntu Server 14.04 with network configuration using /etc/network/interfaces and so ifup/ifdown scripts.

I realised that if I configure one interface in DHCP mode, then I unplug the cable from the interface and the IP address configured via DHCP is maintained until the DHCP lease expires. What I need is dhclient to flush addresses and routes configured via DHCP in the interface when the link goes down immediately.

How can I get dhclient to flush IP addresses and routes when the link status is DOWN?

1 Answer 1


You can use ifplugd to run a command when an Ethernet cable is plugged or unplugged. I'm not sure whether installing ifplugd is necessary — it's possible that there's a built-in way with udev and upstart — but I can't find it in the upstart documentation.

Since you're using ifupdown, call ifdown when the cable is unplugged. In /etc/ifplugd/ifplugd.action, write something like

if [ "$1" = "eth0" ] && [ "$2" = "down" ]; then
  ifdown "$1"
  • Great! You provided me the key point.
    – chrpinedo
    Mar 25, 2015 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.