22

I am using ubuntu 14.04 on ec2 instance, I am changing dhcp settings as part of the provisioning process, and I cant find a way to reload the dhclient. Infact, theres no way to restart network on 14.04 cloud instances. Any suggestions?

Ranjib
  • 321
  • 1
  • 2
  • 4

3 Answers3

13

The -r flag explicitly releases the current lease, and once the lease has been released, the client exits. Open a terminal and type the command:

$ sudo dhclient -r

Now obtain fresh IP:

$ sudo dhclient 
Jan
  • 11,856
  • 3
  • 30
  • 38
  • 5
    I don't think this is correct; it doesn't reload the service. I'm in the same situation - needing to change options in `/etc/dhcp/dhclient.conf`, then restarting the service. When `dhclient -r` is run without any options, it can't even locate the proper PID file, as dhclient is configured per interface. – oasisbob Feb 05 '16 at 01:00
  • @oasisbob I got an error message running `sudo dhclient` after `sudo dhclient -r`, however it did correctly reload the file for me. – aradil May 24 '16 at 18:25
  • 1
    As @oasisbob says. Never invoke another instance of dhclient. You will have two processes running on the same interface. – gertvdijk Jul 07 '17 at 21:19
1

Typically I do this by running dhclient as a single command like so:

$ sudo -Es
$ dhclient -r; dhclient

You can use this trick if you've made changes to /etc/dhcp/dhclient.conf:

$ cat /etc/dhcp/dhclient.conf
timeout 300;
retry 60;
supersede domain-search "dom1.mydom.com", "dom2.mydom.com";
prepend domain-name-servers 192.168.7.185,192.168.7.186;

References

slm
  • 2,885
  • 1
  • 26
  • 32
1

Yeah... no. dhclient -x or dhclient -r didn't work for me. What did work was

sudo su
ps fax

then copy the entire command-line that starts with /sbin/dhclient, including all the command-line options, file paths, etc... Then

pkill dhclient

and paste the command-line from ps fax into your terminal and hit enter.

Mr Stock
  • 11
  • 1