Adding a VLAN interface with Netplan
Follow the below to add a VLAN through Netplan on a Ubuntu server
1. Open the Netplan Configuration File:
sudo nano /etc/netplan/01-network-manager-all.yaml
2. Edit the File with the Correct Configuration:
network:
version: 2
ethernets:
eno1:
dhcp4: yes
routes:
- to: default
via: 192.168.1.1
on-link: true
metric: 100
vlans:
vlan50:eno50: id: 50
link: eno1
gateway4:routes: - to: 192.168.50.0/24
via: 192.168.50.1
nameservers:on-link: true addresses: [192.168.1.9, 192.168.1.8]
Note to self: Are gateway and nameservers even required above since it is set up in Pfsense?
3. Apply the Configuration:
sudo netplan apply
4. Verify the Configuration:ip a
You should now see the vlan50 interface.
Docker MACVLAN example:
docker network create -d macvlan \
--subnet=192.168.50.0/24 \
--gateway=192.168.50.1 \
-o parent=eno50 \
DockNet
Note: You have to restart docker after editing the netplan.