Setting up Static IP in Ubuntu 12.04 System

How to Set up Static IP in Ubuntu 12.04 System

Though Ubuntu's Network Connections wizard can help you set up static IP both for wired and wireless, in certain situations you need to follow other way like use your network interface file to set up static IP. If you are working in a remote machine, or you want to have more number of DNS servers configured then I will prefer to set up static IP in Ubuntu through network interface files.

Below steps helps to set up static IP.

  1. Modify /etc/NetworkManager/NetworkManager.conf file. By default the file looks as below.
    [main]
    plugins=ifupdown,keyfile
    dns=dnsmasq

    no-auto-default=F0:1F:AF:35:44:CC,

    [ifupdown]
    managed=true

  2. First comment line dns=dnsmasq by putting # at the start of line
  3. Set managed to false (last line)
  4. Finally /etc/NetworkManager/NetworkManager.conf looks as below
    [main]
    plugins=ifupdown,keyfile
    #dns=dnsmasq

    no-auto-default=F0:1F:AF:35:44:CC,

    [ifupdown]
    managed=true

  5. Next, have a proper /etc/network/interface file. One example file is shown below.
    iface lo inet loopback


    auto eth0
    iface eth0 inet static
    address 192.168.1.114
    netmask 255.255.255.0
    gateway 192.168.1.1
    network 192.168.1.0
    broadcast 192.168.1.255
    dns-nameservers 192.168.1.114 8.8.8.8


    iface wlan0 inet static
    address 192.168.1.114
    netmask 255.255.255.0
    gateway 192.168.1.1
    network 192.168.1.0
    broadcast 192.168.1.255
    dns-nameservers 192.168.1.114 8.8.8.8

    You need to put proper IP address, gateway, DNS servers etc.

  6. Next restart network related services
    sudo service network-manager restart
    sudo service networking restart

Thats all. You should be able to use either wired or wireless static IP in Ubuntu 12.04 systems.

And yes, if you are using wireless, one time effort you need to put is to create a wireless entry in Network Connections wizard, where you need to put security details.