Advanced Linux Networking: configuring VLANs and bridges

Networking is a crucial component of any system, and Linux provides a variety of advanced networking options. In this article, we will discuss how to configure VLANs and bridges on a Linux system.

What are VLANs?

A VLAN (Virtual Local Area Network) is a logical group of network devices that share a common communication domain. VLANs allow network administrators to segment their network into multiple virtual LANs, each with its own set of VLAN tags. VLANs help in improving network performance, security, and scalability.

To configure VLANs on Linux, you need to have the VLAN package installed. To install the VLAN package, use the following command:

sudo apt-get install vlan

Once the VLAN package is installed, you can create VLANs using the vconfig command. The syntax for creating a VLAN is as follows:

sudo vconfig add <physical_interface> <vlan_id>

For example, to create a VLAN with ID 10 on the eth0 interface, use the following command:

sudo vconfig add eth0 10

After creating the VLAN, you can assign an IP address to it using the ifconfig command. For example, to assign the IP address 192.168.10.1 to the VLAN interface, use the following command:

sudo ifconfig eth0.10 192.168.10.1 netmask 255.255.255.0 up

What are Bridges?

A bridge is a software device that connects two or more network segments. Bridges help in forwarding network traffic between different network segments and improve network performance.

To configure bridges on Linux, you need to have the bridge-utils package installed. To install the bridge-utils package, use the following command:

sudo apt-get install bridge-utils

Once the bridge-utils package is installed, you can create a bridge using the brctl command. The syntax for creating a bridge is as follows:

sudo brctl addbr <bridge_name>

For example, to create a bridge named br0, use the following command:

sudo brctl addbr br0

After creating the bridge, you can add the physical interfaces to it using the brctl command. For example, to add the eth0 and eth1 interfaces to the br0 bridge, use the following command:

sudo brctl addif br0 eth0
sudo brctl addif br0 eth1

After adding the interfaces to the bridge, you can assign an IP address to the bridge interface using the ifconfig command. For example, to assign the IP address 192.168.1.1 to the bridge interface, use the following command:

sudo ifconfig br0 192.168.1.1

Some extras

To list all the VLANs on a Linux system, use the following command:

sudo vconfig list

The output will show you the physical interface, VLAN ID, and the associated VLAN interface:

VLAN 	        DEV     VID 
eth0.10 	eth0 	10 

To remove a VLAN, use the following command:

sudo vconfig rem <vlan_interface>

For example, to remove the VLAN interface eth0.10, use the following command:

sudo vconfig rem eth0.10

To check the status of a bridge, use the following command:

sudo brctl show <bridge_name>

For example, to show the status of the br0 bridge, use the following command:

sudo brctl show br0

The output will show you the bridge interface, the associated physical interfaces, and their status:

bridge name 	bridge id 		STP enabled 	interfaces 
br0 		8000.000000000000 	no 		eth0 
							eth1

To remove a bridge, use the following command:

sudo brctl delbr <bridge_name>

For example, to remove the br0 bridge, use the following command:

sudo brctl delbr br0

Remember that configuring VLANs and bridges can be complex and requires a good understanding of networking concepts. Always consult the official documentation and/or seek help from experts when configuring advanced networking options.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top