Set a static IP address in Ubuntu 12.04 Precise Pangolin
It is not intuitively obvious how to assign Ubuntu 12.04 Precise Pangolin a a static IP address from the command line. However, much of Linux administration involves the editing of text files, and assigning a static IP address is no different. You’ll need to edit the following file:/etc/network/interfacesInitially, the file only contains information about your local loopback address:
auto lo
iface lo inet loopback
To assign a static IP address, you’ll need to make some changes to this file.
Let’s say you want to assign a static IP of 10.10.10.142 to your eth0 network connection (the first Ethernet adapter on your system; if you only have one, it will be eth0), with a subnet mask of 255.255.0.0 and a local gateway of 10.10.10.1 First, make a backup copy of the interfaces file:
rahul@rahul-desktop:~$sudo cp /etc/network/interfaces ~
This will make a backup copy in your home directory in case something goes amiss during the editing process. Next, fire up a text editor:rahul@rahul-desktop:~$ sudo vim /etc/network/interfaces
Once the file is open, add the following lines:
iface eth0 inet static
address 10.10.10.142
netmask 255.255.0.0
gateway 10.10.10.1
Once you’ve added these lines, save the interfaces file to disk, and exit your text editor.
You’ll then to need have your system load the new IP configuration. You can do that by rebooting or restarting the service you can use this command to force Ubuntu to re-read the configuration files:
rahul@rahul-desktop:~$ sudo ifup eth0
Orrahul@rahul-desktop:~$sudo /etc/init.d/networking restart
Your system will then have a static IP address.
No comments:
Post a Comment