Table of Contents
Ubuntu - Networking - Netplan - Configure networking with Netplan
Netplan is based on YAML based configuration system that makes configuration process very simple.
Netplan has replaced the old configuration file /etc/network/interfaces that we previously used for configuring network interfaces in Ubuntu.
Configuration Files
Netplan configuration files are at /etc/netplan/*.yaml.
- Ubuntu server defaults to using system-networkd with the configuration file named 01-netcfg.yaml,
- Ubuntu desktop generates a configuration file for Network-Manager named 01-network-manager-all.yaml.
NOTE: If you have multiple interfaces, use 02-network-manager-all.yaml for the second interface.
Netplan applies the configuration in the numerical order; i.e. the 01 file will be applied before the 02 file.
Find the name of the active network interfaces that you want to configure
ip a
returns:
... enp3s0 ...
NOTE: Note the interface name that you want to configure using Netplan.
- In this case, enp3s0.
Edit the netplan file.
- /etc/netplan/01-network-manager-all.yaml
# Let NetworkManager manage all devices on this system #network: # version: 2 # renderer: NetworkManager network: version: 2 #renderer: NetworkManager renderer: networkd ethernets: enp3s0: dhcp4: no # disable existing configuration for ethernet #addresses: [192.168.1.69/24] #gateway4: 192.168.1.1 #nameservers: #addresses: [192.168.1.1] dhcp6: no # add configuration for bridge interface bridges: br0: interfaces: [enp3s0] dhcp4: no addresses: [192.168.1.69/24] gateway4: 192.168.1.1 nameservers: addresses: [192.168.1.1] #addresses: [192.168.1.26,192.168.1.2,192.168.1.25,192.168.1.1,1.1.1.1] parameters: # stp: false stp: true forward-delay: 4 dhcp6: no
NOTE:
- renderer: Either networkd or NetworkManager.
- networkd uses the settings in the Netplan config file. This is preferred.
- NetworkManager uses the settings in the Ubuntu Network GUI settings.
- stp: Defines whether the bridge should use Spanning Tree Protocol
- forward-delay: Specifies the period of time the bridge will remain in the Listening and Learning states before getting to the Forwarding state.
Test
Before applying any changes, test the configuration file:
sudo netplan try
Apply Configuration
sudo netplan apply
NOTE: In case you see any error, try debugging to investigate the problem.
To run debug:
sudo netplan –d apply
Restart the network service
On Ubuntu Desktop
sudo systemctl restart network-manager
On Ubuntu Server
sudo systemctl restart system-networkd
Verify IP Address
ip a