How to a Set Static IP in Ubuntu – Graphically

Some recent changes to Ubuntu have changed the way we set a static IP in Ubuntu 12.04 and 12.10. Previously we could change the /etc/resolv.conf file adding in our static IP details. But due to some internal changes I’m finding it more stable to make changes in the graphical interface…. nm-connection-editor, as these new changes are overwriting the file with some generated content.

UPDATE: I have written some instructions on how to set a static IP in a more ‘Linux’ fashion. Check them out here (for wired connections only)

 

What do I need to set up a static IP?

You need to add some details which you may not know of the top of your head:

  • Your chosen IP
  • Netmask
  • Gateway
  • DNS Server

Where can I find these details?

Your chosen IP

Your router will most likely have a reserved range of IPs for static use, every domestic router I’ve used has reserved 100 – 200 (though you may have to check your router manual if you find its not).

Netmask, Gateway and DNS Server

Enter the following command in a terminal

The output will list the details of your network interfaces, wireless and wired. In the section of the [Wired] interface there are some IPv4 Settings that will look something like below:

  • Address – current IP address
  • Prefix – the address inside the brackets is the netmask
  • Gateway – this is the gateway, otherwise known as the default gateway
  • DNS – is your current DNS server

Setting the Static IP

To the set the static IP run this command in a terminal:

Ubuntu 12.04 Static IP - Netword Connections

This will open the graphical network manager as seen below. If you have more than one connection, select the one you want to apply the static IP to, then click Edit.

This will open the Editing Wired dialog. It is in this box that we need to enter the information we found earlier. In the box below you can see my default settings before applying my static IP. Each of the values can be edited by clicking on them.

Ubuntu 12.04 Static IP - Editing Wired Connections

I’ve applied my changes, clicked save, nothing has changed?

Easy answer: Restart your computer
My answer: Enter the following few commands without the need to restart We need to restart some networking services to make sure we are using the most recent settings:

If restarting these services has no effect go ahead and try a restart.

Now try the following again to make sure your changes are in effect:

The output should reflect the static IP settings we retrieved earlier.

Hope this post helps you guys, any questions….. you know what to do.

  • Andrei Tanasuca

    I know it is a bit offtopic but i would like to know if you have a solution for nm-applet to startup for other than main account.
    Do you think a .dmrc file is the answer and controlling the session with session?

    Thank you

    • Weird problem, I’ve noticed this has randomly disappeared for a few people. What version of Linux are you using? and which desktop environment? When you run ‘nm-applet’ in a terminal does it appear in your notification area?

      • Andrei Tanasuca

        I think a “nm-online” solution will do the trick.
        Thank you for your answer

  • Ludovic Urbain

    Well, my conclusion is ubuntu is a piece of shit. No fucking way a distrib has any right to replace the use of /etc/network/interfaces . I’m shocked and disgusted, won’t buy again.

    • I do kind of agree, one of my attractions in the first place was the ability to customize it like this, now they want to stop this! The other reason was because it was quite lightweight, which is also becoming an issue!

    • John

      You can turn it off. In /etc/NetworkManager/NetworkManager.conf set managed=true. Then proceed with interfaces resolv.conf etc.

      • Great stuff, defo worth noting!

      • Ludovic Urbain

        Sure. I can also just put ubuntu in the trash and not have to turn off a dozen dozen useless tools.

  • Brian

    Each time I switch to manual configuration, the save button “grays out” and I can’t save anything. Anyone have this happen?

    • me

      yes. I had this exact problem. I fixed it by editng /etc/network/interfaces .. and rebooting.

    • Peter Hagedorn

      I also had a greyed out Save button but realized that this was because I had accidentally clicked add twice so it was waiting for me to type a second address. When I deleted this empty address field I was allowed to save.

  • Brendan White

    worked a charm – thanks dude.

  • rtalcott

    Thank you!

  • A C Boros

    I’m having a heck of a time getting a static IP set on a new Ubuntu 12.04 LTS server. I’ve done what you said in this article but, it isn’t working. When I try to run the sudo service networking restart command, I get the wait/stop response but, not a restart.

    I’ve rebooted and that hasn’t helped either.

    If I try to edit the NetworkManage.conf file, to change the manage false to true, I cannot save the file.

    If I click on Connection Information (Ubuntu Desktop GUI) I get an error, “Error displaying connection Information. No valid active connections found.” I still have access to the Internet.

    Any thoughts on where to go from here are welcome. I’ve been struggling with this on and off for several days now.

  • OMAR OROZCO

    Thanks!! I was fighting with the /etc/network/interfaces, but even when I managed to get static IP, I lost my internet access !!! but with your method everything is OK

  • H Gudsen

    After fighting with network/interfaces I found this post and it worked for me. But does someone know how to do the same from command line? I have a server that might be upgraded to 13.04, so I’d like to know how to solve the problem not having access to X.

  • Daren Humphries

    Great guide! It seems like Ubuntu is alot easier to port forward than windows… at least that’s my opinion. Thanks!

  • Pingback: [ubuntu] Plexapp.com, port forwarding and static IP addresses | Ubuntu InfoUbuntu Info()

  • Pingback: [ubuntu] Plexapp.com, port forwarding and static IP addresses | WyldePlayground.netWyldePlayground.net -()

  • Pingback: [ubuntu] Plexapp.com, port forwarding and static IP addresses | James n Sheri.comJames n Sheri.com()

  • Dennis Blewett

    Worked great. I needed the DNS information, which I was not putting in the graphical NetworkManager. Riddle solved. Case closed.

  • Pingback: Internet over wireless while connected to a LAN network()

  • CommanderMan0

    This was super helpful, thank you!

  • Klaus

    Super thanks for this, made my life as Former Win man easier ?

  • Tom

    thanks. worked a treat with 14.4

  • Iain

    Worked for me too – thanks!

  • Akshay

    cool!

  • Manoj Bharti

    How can I set static ip in ubuntu 18.04 bionic beaver server.