Monday, December 7, 2009

Ubuntu Server : Change ip from DHCP to Static

Since Ubuntu server does not install GUI, so we need to use CLI to change the IP address from DHCP to Static.

Go ahead and open terminal/console for your server.

Edit this file using your favorite editor.

sudo nano /etc/network/interfaces

This is how it looks (using DHCP)

auto eth0
iface eth0 inet dhcp


Now, some editing required. Change it to this :

auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

Save it. Next we need to change some parameters in /etc/resolv.conf

sudo nano /etc/resolv.conf

Change the line 'nameserver xx.xx.xx.xx' to 'nameserver 192.168.1.4' where 192.168.1.4 is your name server.

Now, remove dhcp-client from your server.

sudo apt-get remove dhcp-client

Lastly, we need to restart networking service

sudo /etc/init.d/networking restart

Done. Try and ping any server (yahoo, google etc).

No comments:

Post a Comment