Vinit's Tech Blog

Life has meaning as long as you keep learning.

Setting up Networking on Ubuntu using NETPLAN

Most of you who are familiar with Ubuntu / Linux, must be aware of how we used to configure network interfaces and bridges. Prior to Ubuntu 18.04, all the configuration for network interfaces was performed under /etc/network/interfaces file. With 18.04 release, Ubuntu released a new and improved mechanism to configure the network interfaces and the configuration is put in a YAML file. This utility is known as netplan. The users / system administrators only need to specify what interfaces are needed and what functions they perform in the yaml file and based on that configuration netplan generates a configuration for the selected renderer. Isn't that cool? I personally do a lot of virtualization in ubuntu using kvm and each virtual machine needs to be segregated based on their use in the network. This is where netplan comes in very handy. In this blog post, I am going to share different ways of configuring netplan and what one can do with it.

When an Ubuntu server or workstation is installed, the initial netplan config is saved in a yaml file in /etc/netplan/ directory.

root@rnd-srvr:~# cat /etc/netplan/01-netcfg.yaml 
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
enp1s0f0:
addresses: [ 172.16.31.31/26 ]
gateway4: 172.16.31.1
nameservers:
search: [ xyz.com ]
addresses:
- "172.16.31.1"

Detailed documentation on netplan can be found @ www.netplan.io.

In the above config, we can see that the server is assigned an IP address of 172.16.31.31/26 with the default-gateway and DNS server with IP 172.16.31.1.

Comments are closed