3

I had some trouble getting the static ip configuration right for Ubuntu 12.04 Server. Every time I would restart the server the nameserver settings in /etc/resolv.conf would get overwritten by dhcp client. Many tutorials suggest doing an apt-get remove for dhcp-client but this didn't work for me either.

I found this page that documents how to do this in 12.04.

Answer:

You basically need to add your nameserver settings in the /etc/network/interfaces file like so:

iface eth0 inet static
        address xx.xx.xx.xx
        netmask xx.xx.xx.xx
        network xx.xx.xx.xx
        broadcast xx.xx.xx.xx
        gateway xx.xx.xx.xx
        dns-nameservers xx.xx.xx.xx xx.xx.xx.xx

Note that dns-nameservers is where you add your DNS nameservers (they didn't get creative with the name, heh!)

Khaled
  • 35,688
  • 8
  • 69
  • 98
programmer
  • 155
  • 7
  • And it's not documented in `man interfaces` or `man resolv.conf`. The only way I found out is the note they left in resolv.conf "DO NOT EDIT THIS FILE BY HAND" – charlesbridge Jun 08 '12 at 18:55

1 Answers1

1

Unless they changed a lot in the latest version of Ubuntu static IPs should work just fine with the dhcp-client. Also I'd leave it on the machine in case you have to get a new dynamic IP.

But to answer your question :

If you read the package description (http://packages.ubuntu.com/precise/dhcp-client) it says :

Packages providing dhcp-client

dhcpcd5
    RFC2131 compliant DHCP client with IPv4LL support
pump
    BOOTP and DHCP client for automatic IP configuration 

Which means that dhcp-client is in fact one of those packages. Usually it is dhcpd5. So you only have to :

sudo apt-get remove dhcpcd5
cete3
  • 146
  • 1
  • 6
  • Thanks for the help. Since that tutorial I was using was so old I scoured google for the proper way to set a static ip for Ubuntu 12.04. I'm going to edit my post to help others. – programmer Jun 08 '12 at 18:16
  • Glad to see you found your way round. You should accept an answer so that the topic is closed ! – cete3 Jun 09 '12 at 00:00