Search This Blog

Sunday 14 March 2010

Static IP in Ubuntu

From http://www.prash-babu.com/2008/11/how-to-setup-static-ip-address-in-linux.html


This tutorial would help you configure a static ip address for your linux machine.Static ips are used for a lot of purposes like port forwarding etc . Especially in the case of Ubuntu intrepid , this can be helpful as there seem to be some bug while setting up static ip via the Network Manager (GUI).So you could setup static ip by manually editing the /etc/network/interfaces file.Here's how you go about doing this :

Firstly, You need to know which interface you are dealing with, i.e.for which interface you need to create a static ip.So lets say you want to setup a static ip 192.168.1.10 and your gateway would be your router ip which is 192.168.1.1 .. Now say you want to apply this static ip to the interface eth0 . So here's what you do :

Step 1 : Go to the Terminal(Applications->Accessories->Terminal)
Step 2 : Then type sudo gedit /etc/network/interfaces
Step 3 : Now the interfaces file should open on gedit.
Step 4 : Now look for the line
iface eth0 inet dhcp

and replace it with

iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1


Step 5 : Save changes and close the file
Step 6 : Now Back in your terminal type sudo /etc/init.d/networking restart
Step 7 : Then type sudo ifdown eth0
Step 8 : Then type sudo ifup eth0
Step 9 : You should now have the static ip 192.168.1.10 for your interface eth0.