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.
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
- 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:
IPv4 Settings: Address: 192.168.1.67 Prefix: 24 (255.255.255.0) Gateway: 192.168.1.254 DNS: 192.168.1.254
- 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:
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.
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:
sudo service resolvconf restart sudo service networking restart
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.