Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I had statically set my ip in Linux using:

sudo ifconfig eth0 192.168.blah.blah

Now I want it to go back to using DHCP to assign the IP. How do I do that?

This is what I see when I run dhclient

Internet Systems Consortium DHCP Client V3.1.2
Copyright 2004-2008 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

Listening on LPF/eth0/08:00:27:9b:43:09
Sending on   LPF/eth0/08:00:27:9b:43:09
Sending on   Socket/fallback
DHCPREQUEST of 192.168.56.104 on eth0 to 255.255.255.255 port 67
share|improve this question
    
Regarding your own answer to this question: Are you using a VMWare Linux VM (on a Windows XP host)? That should be stated in the question as well then. I found that not few people have this problem, too, but I could not find a general solution to it yet. –  foraidt May 15 '10 at 10:25
add comment

migrated from stackoverflow.com May 15 '10 at 10:05

This question came from our site for professional and enthusiast programmers.

4 Answers

Take a look at pump or dhclient

share|improve this answer
    
I've been trying dhclient but to no avail. When I restart it still tries to keep the ip address I had given it :/ –  Markus Orreilly May 15 '10 at 9:35
add comment

DHCP will ask for the same address as before as it's first preference, and if the DHCP server hasn't assigned it to someone else, then it will be happy to confirm that address.

Have you tried editing or erasing /var/lib/dhcp3/dhclient.leases? Then DHCP won't have a preference, and the server will allocate a new address.

share|improve this answer
add comment

Depending on your distribution, the DHCP client is run with dhclient, dhcpcd, pump or maybe other commands.

The command you wrote is temporary: it does not write anything in any configuration file. This means that after rebooting the system, it will use the same configuration it used before.

It's very improbable to me that the system after reboot will keep using that static IP instead of DHCP. Are you sure it is not using DHCP? And are you sure it used DHCP before?

Specifying your linux distribution would definitely help us.

share|improve this answer
    
I'm using ubuntu 9.10 as a VirtualBox guest on a Windows 7 host. I had assigned the ip address when using the HostOnly network adapter. I switched it over to Bridged, and ran dhclient, but it keeps requesting the ip address I had assigned to it. Yeah, I thought it should go away on a restart as well. –  Markus Orreilly May 15 '10 at 9:53
    
(had pasted some code here, but it doesn't like that in comments) –  Markus Orreilly May 15 '10 at 9:54
    
Mmh sorry I can't help you.. I have little experience with virtual box. Anyway ask this on superuser.com . That is the proper place –  Dom De Felice May 15 '10 at 9:57
add comment

I hate answering my own question, but a "somewhat" fix was to run it with the NAT network adapter instead of bridged. For some reason that one worked, while Bridged didn't :/ - still not quite what I want, but closer.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.