49

I know there is a simple command for this, but how do I tell my Ubuntu server instance to request a new IP address from the DHCP server on eth0?

5 Answers5

50
dhclient eth0

man page: dhclient

47

To release the current IP address:

$ sudo dhclient -r

To obtain a fresh lease:

$ sudo dhclient 
LukeR
  • 3,176
18

Another issue I ran in to was that dhclient kept requesting the same IP from the DHCP server. Running the command dhclient -r did not resolve this. Therefore, after reading the man pages more thoroughly, I found that if I edited the file /var/lib/dhcp3/dhclient.leases to remove all lease references to the specific adaptor, in my case eth0. Then running sudo dhclient eth0 worked as expected and assigned me a new/different IP.

My situation was perhaps unique, but it required that my server pull an address from a higher range than was previously issued. The DHCP server was configured to do this, unless a specific IP address was requested regardless of the range. Since dhclient was specifically requesting the old IP address, based on the information in the dhclient.leases file, the DHCP server was always returning the same address.

1

If anyone stumbles upon this old thread. The dhclient is not used in all distros (anymore):

    sudo netplan apply

helped me using a newer Ubuntu (I used 24.04)

-3

When you run "sudo /etc/init.d/dhcp3-server restart" does it give something like:

Stopping DHCP server: dhcpd3. Starting DHCP server:dhcpd3.

If not, it's not running...

Then just be sure, check if your client sends out a request for a lease, take a look at your /var/logs/deamon.log file. There should be a bunch of DHCP requests in there. If not, the problem is with your client (and we will take it from there).

If your client is ok, just forget about firestarter for the moment and let's try to get it working without it. To make sure your DHCP server is up and running. Type "sudo /etc/init.d/dhcp3-server stop" and then "sudo /etc/init.d/dhcp3-server start". Then it should be running, assuming it's properly installed on your box.

I have included a copy of my dhcpd.conf file.

Finally, take a look at your server's /var/log/messages file if it gets the requests and replies to it with a valid lease. It also might give you an idea what's wrong with your configuration file (if there's something wrong with it ofcourse). If you can't make anything of this, post your messages file and I will take a look lateron.

goodluck

Rajat

Rajat
  • 3,349