I am trying to setup vlans on my eth0 network card. The following are the steps that I've taken:
- Install
vlanwithsudo apt-get install vlan Edit
/etc/network/interfacesin vi by adding:auto eth0.100 iface eth0.100 inet dhcpRestarted networking and/or restarted Ubuntu
- Ran
ifconfig
I don't see the eth0.100 listed, I'm not sure what I am doing wrong.
I can add vlans using vconfig but they don't stay after a reboot.
2 Answers
First you must install vlan
sudo apt-get install vlanload kernel module
sudo modprobe 8021qCreate a new interface that is a member of a specific VLAN, VLAN id 100
We use the physical interface eth0 in this example. This command will add an additional interface next to the interfaces which have been configured already
sudo vconfig add eth0 100Assign an address to the new interface:
sudo ip addr add 10.0.0.1/24 dev eth0.100To make this setup permanent. Add the module to the kernel on boot
sudo bash -c 'echo "8021q" >> /etc/modules'Create the interface and make it available when the system boots. Add the following lines to /etc/network/interfaces
auto eth0.100
iface eth0.100 inet dhcp vlan-raw-device eth0 4 The modern way to create a VLAN interface is using ip link from iproute2. Assuming you want to run the VLAN over interface eno1:
sudo ip link add link eno1 name vlan100 type vlan id 100Now optionally give it an address:
sudo ip address add 10.0.0.100/24 dev vlan100And bring it up:
sudo ip link set vlan100 upTo make this permanent, define the vlan interface in /etc/netplan/*. This will look like:
network: version: 2 ethernets: eno1: ... eno1 config ... vlans: vlan100: id: 100 link: eno1 addresses: [10.0.0.100/24]Detailed documentation is in the netplan reference.