Netplan makes Linux Cross-Hypervisor migration easy!

The network configuration abstraction renderer

Netplan is a utility for easily configuring networking on a linux system. You simply create a YAML description of the required network interfaces and what each should be configured to do. From this description Netplan will generate all the necessary configuration for your chosen renderer tool.

Currently supported backends are systemdnetworkd and NetworkManager.

A little History

Netplan was introduced to the mainstream in Ubuntu 18.04 as the new default way to configure network interfaces. For those familiar with the old /etc/network/interfaces file, Netplan was unwanted and seen as a complicated way to do a simple thing.

I, personally, felt this way as well as a bunch of other people in various forums across the net. That was until I learned how to use it and seen how powerful it is. Now, I welcome Netplan and hope that all Linux flavors add support for it!

How Netplan works, YAML to NIC Config

How Netplan makes migrations and Disaster Recovery easier

When you migrate a Linux machine to a new hypervisor you have two main issues that you face.

  • driver requirements for new hardware
  • configuration for new network adapters

The first issue, hardware drivers, are easily handled by modifying Linux initramfs to load the drivers for Azure and AWS at boot. I have previously explained how to do this in my “Azure Migration Tips” pages.

I didn’t talk too much about reliable networking configuration, because in some cases things “just worked.” In the case of CentOS 6.x you needed to also run a custom script from Zerto that would basically look for NIC’s and switch them to DHCP if AWS or Azure was detected. It works pretty well but leaves some ambiguity during failback. Netplan solves this because it can control both failover and failback.

Netplan for VMware

So a Netplan YAML file for VMware with a static IP address that will be assigned to a nic that has a particular MAC address would look something like this:

Netplan YAML for static IP to MAC mapping

As you can see its pretty straight forward. We define a network adapter (ens160), of type ethernet, which needs to match a MAC address. When it finds that nic, assign it an address along with gateway, nameservers, and a search domain.

Netplan for public cloud

Let me start by showing you the YAML files for both AWS and Azure.

Azure Netplan YAML
AWS Netplan YAML (non-nitro instances)
AWS Netplan YAML (nitro instances)

These are even simpler than the config for VMware. They search for a nic that uses a particular Linux kernel driver, then configures that nic for dhcp and renames the nic to something easy to use.

These are all very basic config’s for instances with a single network adapter, and more complex vms would mean more complex YAML files. But, for the majority of use cases I’ve seen, these will do the trick.

Recap of what Netplan does

When your machine boots up with the above YAML config files in the /etc/netplan folder, Netplan will generate a configuration for the normal Linux network manager you are using (either systemd-networkd or NetworkManager) so that that manager knows what to do with your network cards.

It does this EVERY time the machine boots. which means that if it “wakes up” in Azure or AWS… it will find that new network card and assign it the proper configuration.

But Netplan is an Ubuntu project, I use RHEL…

I thought you might say that … not to fear, Netplan is open source, you can compile it on any flavor of Linux you want as long as you meet the dependencies.

There is also a yum repository that has epel releases that can be applied to both CentOS and RHEL here

What I’ve tested so far

So far I have tested Netplan on Ubuntu 18.04 to both Azure and AWS from VMware.

I have also tested Centos7 and RHEL7 from to Azure and AWS from VMware.

What I still need to do

Still to do is test older versions of each OS, including CentOS6, RHEL6, Ubuntu 16.04. I will test both Azure and AWS as recovery targets.

I also need to see what it will take to get Netplan compiled with Python 3.6 support, because right now the epel repo only has Python 3.4 support.

I would also like to get involved more with Netplan and see what I can do for the project


Share This Post

Post Comment