Configuring a static IP address in Ubuntu

To configure a static IP address in Ubuntu from the command line, you will need to edit /etc/network/interfaces

sudo vim /etc/network/interfaces  
iface eth0 inet static  
address 192.168.2.156  
netmask 255.255.255.0  
gateway 192.168.2.1  
dns-nameservers 208.67.222.222, 208.67.220.220  

Then restart the interface:

sudo ifdown eth0; sudo ifup eth0  
comments powered by Disqus