Thursday, October 2, 2014

How to set a Static IP in Ubuntu

(from:http://www.sudo-juice.com/how-to-set-a-static-ip-in-ubuntu-the-proper-way/)

Setting a static IP in Ubuntu is useful for a lot of things. You may want to forward ports from your router to serve web pages, use SSH from outside your local network or set up some sort of media server.

For whatever reason, Ubuntu is trying to make our lives easier by introducing graphical tools to be used by default but kind of making our terminal life a bit harder!

The quick answer to setting up a static IP in Ubuntu the proper way is:


  1. Disable the graphical management of your network connection in /etc/NetworkManager/NetworkManager.conf
  2. Gather the information for the static IP (interface, IP to be used, default gateway, subnet, DNS)
  3. Modify /etc/network/interfaces to include the information above.
  4. Restart networking and network-manager services



gksudo gedit /etc/NetworkManager/NetworkManager.conf
So our NetworkManager.conf now looks like this….

[main]
plugins=ifupdown,keyfile
#dns=dnsmasq

[ifupdown]
managed=true

gksudo gedit /etc/network/interfaces
/etc/network/interfaces file now looks like this:

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
address 192.168.0.101
gateway 192.168.0.1
netmask 255.255.255.0
dns-nameservers 8.8.8.8 8.8.4.4

Restart your networking services
sudo service network-manager restart
sudo service networking restart
sudo service resolvconf restart



No comments:

Post a Comment