1

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

0

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

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

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.