Configure Static IP Address and Set DNS in Ubuntu 15.10 Desktop and Server
Before we start this tutorial, I would like to begin with explaining what is an IP address what it is used for. The IP address is a unique set of numbers, separated with dots with which your computer identifies in a network via Internet Protocol.
IP addresses can by set dynamically by the network or statically. The difference between those are the dynamic IP address might be changed when connecting to a network, while the static IP address remains the same after each connection to a network.
Dynamic IP addresses are often used by ISPs to provide connection to their clients. Static IP addresses are often used on servers, so that a given server can be accessed over that IP address or domain pointed to the same IP address.
In this tutorial, we are going to show you how to configure or set a static IP address for both Ubuntu 15.10 Desktop and Server edition.
IP Network Settings
IMPORTANT NOTE: For the purpose of this tutorial, I will be using the following settings:
IP Address: 192.168.0.100 Netmask: 255.255.255.0 Gateway: 192.168.0.1 Nameserver: 18.104.22.168 Nameserver: 22.214.171.124
Make sure to use your own settings depending on the network to which you are connected to.
Set Static IP Address on Ubuntu 15.10 Desktop
If you’re using Ubuntu 15.10 Desktop edition, its’ easy to setup a static IP address. To start setting up the static IP address for your Ubuntu Desktop, start the Unity Dash and look for “Network Connections”
Next select the active wired connection and click the “Edit” button:
In the newly opened window, select “IPv4 Settings” tab. This is where you edit the settings for IP version 4. Then in the dropdown menu next to “Method” select “Manual“:
Now click the “Add” button and enter your IP address settings:
You can now hit the “Save” button to apply the changes. If your computer previously used dynamic IP address, you will now need to reconnect to your network so the static IP address can be set. This can be done by using the “connection” setting in the top right corner:
After that used the same menu to connect again. Once you are connected to your network, use the “Connection information” to review your current settings:
Your network settings are now configured.
Assigning a Static IP Address to Ubuntu 15.10 Server
When configuring the network settings on our Ubuntu server, we don’t have the fancy GUI to help us. You will need to get your hands dirty and use the command line.
For the purpose of this tutorial, I am using “vim editor” as my text editor. You can choose different one as long as you are comfortable using it.
So let’s start. The first thing we need to do is find our network adapter. This can be done with the following command:
$ ifconfig -a
Now in my case the network adapter is called “enp0s3“. Changes are that your network connection will be either “eth0” or “eth1“. If you are using wireless network it would most probably be “wlan0” or “wlan1”
Now open the “interfaces” file with the following command:
$ sudo vim /etc/network/interfaces OR $ sudo nano /etc/network/interfaces
Your file will most probably have the following two lines:
auto lo auto lo intet loopback
Now you need to add your network settings below those two lines. Remember to replace “enp0s3” with the name of your network adapter and the correct IP settings, Netmask, Gateway and DNS servers.
auto lo enp0s3 iface lo inet loopback iface enp0s3 inet static address 192.168.0.102 netmask 255.255.255.0 gateway 192.168.0.1 dns-nameservers 126.96.36.199 188.8.131.52
When ready, press the “Esc” button and type “:wq” without the quotes followed by “Enter” to save the changes. To apply the new configuration, you will need to restart your Ubuntu 15.10 networking with:
$ sudo /etc/init.d/networking restart OR $ sudo systemctl restart networking
Now you can check if your new IP address has been assigned with:
$ ifconfig -a
Congratulations, your static IP address has now been successfully configured in your Ubuntu 15.10 Desktop and Server.
Be very careful when editing the network settings of your machines. Keep in mind that if you set the wrong configuration the machine may become inaccessible over the network.
This is why it would be nice to ensure that if something goes wrong with your desktop/server network settings you have physical access to the machine you are configuring or there is someone else on the other end who will be able to assist you.
This is especially important when you are editing the settings on remote server that is located on thousands miles away from your location.