Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I had installed Ubuntu server and had the router setup to assign the same IP Address (192.168.0.10) every time the machine powered on. Recently, I did a clean install of Ubuntu Server and now my machine won't connect to the Internet. I think this is because I mistakenly set it up with a static IP Address in the install process. How can I configure Ubuntu to always ask for an IP Address from the router?

While researching this, it seems like I need to configure my machine to use DHCP. My /etc/networking/interfaces file has this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static # This is why I think it's setup as a static IP
  address 192.168.0.10
  netmask 255.255.255.0
  network 192.168.0.0
  broadcast 192.168.0.255
  gateway 192.168.0.1
  # I'm pretty sure I typed these in during setup; they have nothing to do with a DNS
  dns-nameservers 192.168.0.1
  dns-search ironjack.spacetechnology.net

I tried to change the static to dhcp and restart the networking script (like this question suggested), but that didn't work.

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted
  1. Make sure all dhclient processes are killed:

    sudo killall dhclient
    

    See below for why I think this is needed on your system in the state it's in.

  2. Leave the interfaces file alone for the moment.

  3. Bring the interface down.

    sudo ifdown eth0
    
  4. Reconfigure the interfaces file to this:

    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet dhcp
    
  5. Bring the interface up again:

    sudo ifup eth0
    

Done.

The networking "service" seems to be an outdated way to reconfigure the network. It's important not to change the order of doing the above when changing the configuration for an interface. One of the issues that can occur is that a dhclient process is started when bringing the interface with dhcp up, but when you change the configuration to static or something else, that process will not be taken down anymore, ever! The result is that your interface configuration is being managed by a split brain. So, please: ifdown, edit, ifup.

share|improve this answer
    
Thank you. This was a great answer that helped me find my problem (in the end I realized that I was actually plugged in to eth1 instead of eth0; DOH!) –  RustyTheBoyRobot Feb 5 '13 at 1:58
    
'sudo killall dhclient' was the missing piece that solved my problem. –  richj May 5 at 22:41
add comment

Your Answer

 
discard

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

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