Question Details

Browse

How do I change from DHCP to a Static IP Address on Ubuntu Server

By Richard Carmody - Oct. 30, 2009

Hi - I just inherited an Ubuntu Server box. How do i change the IP address to a static IP address? It is currently set up to use DHCP.

I have normally used GUI tools on GNOME, but Ubuntu Server, as expected, has no GUI!


Answers

Add Answer
  1. By Randy Clark on Oct. 31, 2009

    In Ubuntu 9, you can convert from a DHCP dynamic IP address to a static IP address as follows: (Remember, you will need to use sudo to do this!)


    1) sudo vi /etc/network/interfaces


    For your primary ethernet interface (usually eth0), you will see the following:


    auto eth0

    iface eth0 inet dhcp


    You will need to remove the dhcp and add the following (assuming static IP address is 192.168.1.100):


    iface eth0 inet statc

    address 192.168.1.100

    network 192.168.1.0

    netmask 255.255.255.0

    broadcast 192.168.1.255

    gateway 192.168.1.1


    Of course, you will need to put in your values for the IP address.


    Next, you will need to set your nameserver in /etc/resolv.conf


    >>> sudo vi /etc/resolv.conf


    nameserver X.X.X.X


    Replace the "X.X.X.X" with your name server from your service provider.


    You will also need to remove your DHCP client, though in my boxes, these are not installed.


    >>> sudo apt-get remove dhcp-client


    Note - this may also be dhcp-client3


    Hope this helps.


    0 Votes
  2. By George Murphy on Oct. 31, 2009

    Do not forget to restart the network! You can, of course, restart your server, but you can run "/etc/init.d/networking restart" to do the trick.


    Run ifconfig to check your new IP and then wget www.yahoo.com or ping it to make sure everything is in order.


    0 Votes
Share your knowledge