Tuesday, April 27, 2010

How to Set a Static IP in Linux Ubuntu Debian

We may require to configute a static IP address in our linux system. It is the easiest if you arterunning Ubuntu / debian distro.

Open up terminal and edit the 'interfaces' file in sudo mode
sudo nano /etc/network/interfaces

You would see the following lines
auto lo
iface lo inet loopback

replace the contents with the following:
auto lo eth0
iface lo inet loopback

iface eth0 inet static
address xxx.xxx.xxx.xxx(your static ip address)
netmask xxx.xxx.xxx.xxx(your network netmask)
gateway xxx.xxx.xxx.xxx(the gateway ip)

Save the file (Ctrl+O) and exit (Ctrl+X)

The ethusually the default network adapter. In a few cases it may be eth1.

I usually also change the nameservers to OpenDNS nameservers
sudo nano /etc/resolv.conf

replacing the contents with:
nameserver 208.67.222.222
nameserver 208.67.220.220

After that it is time to restart networking
sudo /etc/init.d/networking restart

Reboot your PC and check the ip with the command
ifconfig

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.