Friday, August 7, 2015

Using Nano Editor to set static IP

Previously i have use to using GUI to change the IP address on Ubuntu, but now come to server and there is no GUI, so I have force to learn using command to change the IP address.

Here is the guide to set static IP address on  Linux Ubuntu  by using the Nano text editor.

sudo nano /etc/network/interfaces

so do not miss out the s in interface word, else the Linux unable to recognize your command. Due to changing system setting, it may prompt you the password for root. Once you entered the password and you may see the something as below.

auto lo eth0
iface lo inet loopback
iface eth0 inet dynamic
eth0 is the network card name, as you have more than 1 network card, it may have few name. So make sure the name of the interface. you may verify your interface card by using the ifconfig to show the list of interface and interface details.

so you may manually to change the file by using the nano editor. Below is my example and please take note that the iface eth0 inet dynamic  change to static.

auto lo eth0
iface lo inet loopback
iface eth0 inet static
 address 192.168.1.101
 netmask 255.255.255.0
 gateway 192.168.1.1

after you complete change, press Ctrl + x to save the change. The editor will promt you

Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?

Type Y to accept the change then press enter to save the file.

After you save the config file, you may restart the interface to make change. Type below command to down the interface

sudo ifdown eth0

and

sudo ifup eth0

to up the interface.

No comments:

Post a Comment