@lumarseg

Netplan-101

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.

1. How does it work?

Netplan reads network configuration from /etc/netplan/*.yaml which are written by administrators, installers, cloud image instantiations, or other OS deployments. During early boot, Netplan generates backend specific configuration files in /run to hand off control of devices to a particular networking daemon.

Netplan currently works with these supported renderers

  • NetworkManager
  • Systemd-networkd 

2. Commands

Netplan uses a set of subcommands to drive its behavior:

  • netplan generate: Use /etc/netplan to generate the required configuration for the renderers.
  • netplan apply: Apply all configuration for the renderers, restarting them as necessary.
  • netplan try: Apply configuration and wait for user confirmation; will roll back if network is broken or no confirmation is given.

3. Examples

3.1. How to enable DHCP on an interface.

network:
version: 2
ethernets:
eth0:
dhcp4: true

3.2. How to configure a static IP address on an interface network:

network:
version: 2
  ethernets:
    eth0:
      dhcp4: no
      addresses: [192.168.10.80/24]
      nameservers:
        addresses: [200.91.75.5, 8.8.8.8]
      routes:
        - to: default #0.0.0.0/0
          via: 192.168.10.1

 

More examples on: https://netplan.readthedocs.io/

Please find and share the provided snippet here: [NETPLAN-101]