How to make VLAN configuration permanent?

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):

  1. Edit the interfaces file:
    Open the /etc/network/interfaces file in a text editor:

    sudo nano /etc/network/interfaces
  2. Add VLAN configuration:
    Add the following lines, replacing eth0 with your actual interface name and 10 with your VLAN ID:

    auto eth0.10
    iface eth0.10 inet dhcp

    This configuration will create a VLAN interface eth0.10 that uses DHCP.

  3. Restart networking:
    After saving the file, restart the networking service:

    sudo systemctl restart networking

For Red Hat-based systems (like CentOS):

  1. Create a VLAN configuration file:
    Create a new file in the /etc/sysconfig/network-scripts/ directory. The filename should be in the format ifcfg-ethX.Y, where X is the interface number and Y is the VLAN ID. For example:

    sudo nano /etc/sysconfig/network-scripts/ifcfg-eth0.10
  2. Add VLAN configuration:
    Add the following lines to the file:

    DEVICE=eth0.10
    BOOTPROTO=dhcp
    ONBOOT=yes
    VLAN=yes
  3. Restart 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.

0 Comments

no data
Be the first to share your comment!