How to Set a Static IP address in Ubuntu
Step 1 – Remove the Gnome Network Manager: You need to complete this step first because if left installed this application will overwrite any changes you make to your configuration when the system is rebooted. This is apparently where the bug is located.
To remove the Gnome Network Manager issue the following command in the terminal:
(This command is optional)
sudo update-rc.d -f NetworkManager remove
This will disable and remove the Gnome Network Manager application. Now you will have to edit your configuration manually.
Restart your System
Step 2 – Manual configuration of your network interface: In this step you will manually configure your network interface by editing the following two files using your preferred text editor(nano gedit vi). For the purpose of this example I am using the nano editor.
Step 2.1 – Manually configure your network interface file: You can edit the appropriate file by entering the following command into the terminal:
sudo nano /etc/network/interfaces
If you are using DHCP for your primary network card which is usually eth0, you will see the following lines
auto eth0
iface eth0 inet dhcp (← change this to static)
As you can see, it’s using DHCP right now. We are going to change dhcp to static, and then there are a number of options that should add and here is the example and you can change these settings according to your network settings.
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address xxx.xxx.xxx.xxx(enter your ip here)
netmask 255.255.0.0
gateway 172.21.1.1(enter gateway ip here)
Be sure to save your changes.
Step 2.2 – Manually configure your dns configuration file: You can edit the appropriate file by entering the following command into the terminal:
(This command is optional)
sudo nano /etc/resolv.conf
Once your preferred editor opens the file you want to enter the following information (changing your addresses where necessary):
# Generated by NetworkManager
nameserver 4.2.2.2 (enter your dns server ip)
nameserver 192.168.3.231(enter your alt dns server ip)
nameserver 172.21.1.5
domain urdomianname.com
search urdomianname.com
Be sure to save your changes.
Step 2.3 – Manually restart your network interface with the new settings: Enter the following command in the terminal:
sudo /etc/init.d/networking restart
Comments
Tanushree (not verified)
Thu, 08/18/2011 - 17:35
Permalink
Informative
Very Informative.Thanks.
Clarence (not verified)
Wed, 10/26/2011 - 20:09
Permalink
Sweet, finally a post that
Sweet, finally a post that fulfills my research. So many people get this topic wrong. You are a great thinker. =-=