To make VLAN configuration permanent on a Linux system, you typically need to edit the network configuration files. The exact method can vary depending on the distribution you are using. Below are examples for both Debian-based and Red Hat-based systems.
For Debian-based systems (like Ubuntu):
Edit the interfaces file: Open the
/etc/network/interfacesfile in a text editor:sudo nano /etc/network/interfacesAdd VLAN configuration: Add the following lines, replacing
eth0with your actual interface name and10with your VLAN ID:auto eth0.10 iface eth0.10 inet dhcpThis configuration will create a VLAN interface
eth0.10that uses DHCP.Restart networking: After saving the file, restart the networking service:
sudo systemctl restart networking
For Red Hat-based systems (like CentOS):
Create a VLAN configuration file: Create a new file in the
/etc/sysconfig/network-scripts/directory. The filename should be in the formatifcfg-ethX.Y, whereXis the interface number andYis the VLAN ID. For example:sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0.10Add VLAN configuration: Add the following lines to the file:
DEVICE=eth0.10 BOOTPROTO=dhcp VLAN=yesRestart networking: Restart the network service to apply the changes:
sudo systemctl restart network
Verification
You can verify that the VLAN is configured correctly by using the following command:
ip link show
This will list all network interfaces, including your newly created VLAN interface.
