This guide is applicable only for KVM based VPSes, for OpenVZ based VPSes please click here
From Ubuntu 18.04, a switch was made to configure network using NetPlan written in YAML. In this article, we will learn how to configure networking in newer versions of Ubuntu, such as Ubuntu 18.04, 19.04, 19.10 and 20.04 using Netplan.
First, we find the Network interface name,
In this example, the system is configured with the network interface name as ens3, this might not be the case with your system, please verify the system network interface name with the
ip acommand above before proceeding with the guide below!
We will see how we can configure the IPv4,
A side note on this, YAML is strict on indentation so we will use 2 spaces through out the guide.
Initially, the network is configured to DHCP.
network: version: 2 renderer: networkd ethernets: ens3: dhcp4: yes
We will make it Static by changing to
network: version: 2 renderer: networkd ethernets: ens3: dhcp4: no addresses: - 22.214.171.124/27 gateway4: 126.96.36.199 nameservers: addresses: - 188.8.131.52 - 184.108.40.206
For nameservers, we are using google's public DNS.
You can also try CloudFlare's public DNS as well.
After exiting the configuration, run the following command to apply the changes.
This should effectively configure the IPv4 from DHCP to Static and to test if the network is still up.
root@vps:~# ping 220.127.116.11 PING 18.104.22.168 (22.214.171.124) 56(84) bytes of data. 64 bytes from 126.96.36.199: icmp_seq=1 ttl=57 time=0.515 ms 64 bytes from 188.8.131.52: icmp_seq=2 ttl=57 time=0.537 ms 64 bytes from 184.108.40.206: icmp_seq=3 ttl=57 time=0.522 ms
This concludes our topic of configuring static IPv4 on Ubuntu systems.
If you can not configure and facing technical difficulties, kindly reach out to us via Support Ticket.