14

I am running an Ubuntu 10.04 server installation and I recently had to switch it from DHCP to static ip. I edited /etc/network/interfaces file and switched

iface eth0 inet dhcp

to

iface eth0 inet static  
address 192.168.1.167  
netmask 255.255.255.240  
network 192.168.1.160  
broadcast 192.168.1.175  
gateway 192.168.1.161

You'll notice the IPs are a little strange. This is because the sever is now on a special subnet dedicated to isolating specific servers. I also edited the resolv.conf file to include the proper DNS servers (including one of Google's just in case all hell broke lose).

The problem is that, seemingly randomly, the machine will lose the ability to talk to the outside world. I know the machine is still up, but it acts like it has no networking at all. I think part of the issue is that there is no DHCP running to this subnet (nor will there be) and the dhclient seems to still be running on occasion which causes some sort of conflict (no idea what) which causes networking to die. I cannot, however, remove the dhcp3-client package as it also causes the ubuntu-minimal package to be removed and that would be bad.

So, any ideas? What might be calling the dhclient and what can I do to stop it from running?

3
  • 1
    please run sudo dhcpclient eth0 and comment if the network was broken afterwards. And the last lines of /var/log/syslog if possible
    – aatdark
    Sep 27, 2010 at 22:14
  • UPDATE You may try sudo ifdown eth0 according to art.ubuntuforums.org/showthread.php?t=1419803
    – aatdark
    Sep 27, 2010 at 22:23
  • @aatdark If you run ps auxf | less, you should be able to see a list of processes, organized in a tree-like structure. You can then see what process spwaned dhclient (just go up the branch); for instance, on my PC dhclient is a son of the NetworkManager process. Sep 30, 2010 at 12:28

2 Answers 2

14

If you haven't rebooted the machine since, that behavior is normal. Changing from dhcp to static ip should be:

  • sudo ifdown eth0
  • change the configuration
  • sudo ifup eth0

The reason is that if you do the ifdown after changing the configuration, it behaves as if it's taking down a static interface and doesn't kill the dhclient process that will keep just screwing up your configuration. In that case, just kill the dhclient process with

sudo killall dhclient

and it should all work out.

2

As mentioned by jneves, it is probably the DHCP client messing things up for you.

As an alternative to sudo ifdown eth0-edit-sudo ifup eth0, you can just run /etc/init.d/networking restart after you edited the file. It also has the advantage, that you can do it remotely...

(Not having enough points on askubuntu, I am not allowed to just comment on jneves' answer, so please do consider this a comment...)

Edit: Completely forgot; as the above command doesn't disconnect you at any time, your SSH-session should actually survive the re-loading of the configuration. It is quite nice to be able to change the network settings while being connected to said machine...

2
  • It's perfectly fine (and encouraged) for you to add your own answer with more information that builds on another! (Nice job linking to the prior answer too) Nov 24, 2010 at 13:52
  • I was using /etc/init.d/networking restart (in 10.04 server) after editing the configuration file - the dhclient was still running. I had to manually kill the dhclient process (and then I did a reboot just to make sure that it wouldn't come back on after a restart)
    – HorusKol
    May 3, 2012 at 0:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .