Since the release of Ubuntu 17.10, the way users can tweak the network configuration has changed. In previous versions, you would be able to change this from the etc/network/interfaces file which was discussed in a previous tutorial called setup a static IP on ubuntu 16.4
NetPlan is a new network configuration tool introduced in Ubuntu 17.10 to manage network settings. In this tutorial, I am going to show you how to setup a static IP address using the new NetPlan tool.
In the first instance, you will need to find out
You should see something like this:
For clarity, I have listed the key pieces of information that you will require. First, look for the network adapter, it will read something like this: enp0s3 Alongside this, you will see a block of text. The key pieces of information that you will require are. inet: 192.168.0.109 netmask: 255.255.255.0
The other pieces of information you will require will the gateway address and the dns-name servers. The default gateway (gateway) address will be the router address. In most cases, it will be along the lines of 192.168.0.1 but check your router just to make sure.
The final piece of information you will require will be the dns-name server address. The DNS is basically a phone book for the internet and keeps track of domain names and the IP address associated with a website. This will normally be provided through your ISP however you can also use public DNS from Google or open DNS.
Google and OpenDNS Public DNS addresses
The Google public DNS IP addresses are as follows:
Likewise, the OpenDNS public DNS addresses are
Now that we have all the information, going back to terminal, enter the following command. This is achieved using the following command:
sudo nano /etc/netplan/01-netcfg.yaml
You should then see a file that looks something like this:
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
In this instance, the configuration file is setup by default to use DHCP. To configure a static IP address you should change both the DHCP4 and DHCP6 settings to No. You should also add the additional information added at the end of the DHCP6 line (remember to change the IP addresses to match your requirements).
For clarity these lines represent:
addressess: [192.168.1.131] The IP address to make static /24 being the netmask. gateway4 :192.168.0.1 The IP address of your router.
- nameservers: The heading denoting that the next block of addresses will be for the DNS.
- addresses: [220.127.116.11,18.104.22.168] DNS IP addresses in this case for OpenDNS.
Save the changes ctrl x and then activate the new configuration with the following command:
sudo netplan apply
And that is how you set a static IP address on ubuntu 17.10. If you want to find out more about netplan then https://wiki.ubuntu.com/Netplan is worth a read.