Linux Networking: Mastering VLAN Trunking, Bonding, and QoS for High-Performance Systems

Linux Networking: Mastering VLAN Trunking, Bonding, and QoS for High-Performance Systems

Introduction

In today's fast-paced IT environments, performance, reliability, and scalability are critical factors that determine the effectiveness of a network. Advanced Linux networking techniques such as VLAN trunking, interface bonding, and Quality of Service (QoS) are key tools in the hands of system administrators and network engineers who aim to build robust and efficient systems. Whether you're managing a data center, configuring high-availability clusters, or optimizing bandwidth for critical services, these technologies provide the foundation for high-performance networking on Linux.

This article explores each of these advanced networking capabilities, explaining their benefits, configurations, and practical use cases. By the end, you will have a comprehensive understanding of how to implement VLANs, bonding, and QoS effectively on your Linux systems.

Understanding VLAN Trunking in Linux

What is VLAN Trunking?

Virtual LANs (VLANs) allow the segmentation of a physical network into multiple logical networks. VLAN trunking is the process of transporting multiple VLANs over a single network link—typically between switches or between a switch and a server. This allows a single network interface card (NIC) to handle traffic for multiple VLANs, optimizing resource usage and simplifying cabling.

Trunking is crucial in virtualized environments where multiple virtual machines (VMs) or containers need to reside in separate VLANs for security or organizational reasons.

Why Use VLAN Trunking?
  • Isolation: Separates traffic for security and compliance.

  • Efficiency: Reduces the number of physical interfaces needed.

  • Scalability: Makes it easy to add or modify VLANs without physical changes.

Linux Support for VLANs

Linux supports VLANs natively via the kernel module 8021q. The modern toolset uses the ip command from the iproute2 package for configuration. Older systems may use the vconfig utility, though it's now deprecated.

Ensure the module is loaded:

sudo modprobe 8021q

Creating VLAN Interfaces

Use the ip command:

sudo ip link add link eth0 name eth0.10 type vlan id 10 sudo ip addr add 192.168.10.1/24 dev eth0.10 sudo ip link set dev eth0.10 up

Persistent Configuration

On Ubuntu (netplan):

network: version: 2 ethernets: eth0: {} vlans: vlan10: id: 10 link: eth0 addresses: - 192.168.10.1/24

On RHEL/CentOS (ifcfg):

# /etc/sysconfig/network-scripts/ifcfg-vlan10 DEVICE=vlan10 PHYSDEV=eth0 VLAN=yes BOOTPROTO=static IPADDR=192.168.10.1 NETMASK=255.255.255.0 ONBOOT=yes

Interface Bonding for Redundancy and Performance

What is Network Bonding?

Interface bonding, also known as NIC teaming, combines multiple network interfaces into a single logical interface. This can provide:

  • Redundancy (failover): If one interface fails, traffic automatically reroutes.

  • Load balancing: Distribute network traffic across multiple interfaces.

Bonding Modes in Linux
Mode Description
0 Round-robin (load balancing)
1 Active-backup
2 XOR (based on MAC/IP hash)
3 Broadcast (sends on all slaves)
4 LACP (IEEE 802.3ad) dynamic teaming
5 Adaptive transmit load balancing
6 Adaptive load balancing

 

Enabling Bonding

Load the bonding module:

sudo modprobe bonding

Create a bonded interface:

sudo ip link add bond0 type bond sudo ip link set bond0 type bond mode 802.3ad sudo ip link set eth0 down sudo ip link set eth1 down sudo ip link set eth0 master bond0 sudo ip link set eth1 master bond0 sudo ip addr add 192.168.1.100/24 dev bond0 sudo ip link set bond0 up sudo ip link set eth0 up sudo ip link set eth1 up

Persistent Configuration

On Ubuntu with Netplan:

network: version: 2 bonds: bond0: interfaces: [eth0, eth1] parameters: mode: 802.3ad mii-monitor-interval: 100 addresses: [192.168.1.100/24]

On RHEL/CentOS:

# /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 IPADDR=192.168.1.100 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 ONBOOT=yes BOOTPROTO=static BONDING_OPTS="mode=4 miimon=100"

Implementing Quality of Service (QoS)

What is QoS?

Quality of Service refers to techniques used to prioritize network traffic, ensuring important packets—like voice or video—are not delayed or dropped during congestion.

QoS helps to:

  • Limit bandwidth per application or interface.

  • Prioritize latency-sensitive traffic.

  • Prevent any single flow from consuming all bandwidth.

Linux Tools for QoS
  • tc (Traffic Control): Part of iproute2, allows complex traffic shaping.

  • Queuing Disciplines (qdiscs):

    • htb: Hierarchical Token Bucket (bandwidth shaping).

    • tbf: Token Bucket Filter (simple rate-limiting).

    • fq_codel: Modern default in many distros (fair queuing).

Basic QoS Setup with tc

Limit HTTP traffic to 1Mbps:

sudo tc qdisc add dev eth0 root handle 1: htb default 30 sudo tc class add dev eth0 parent 1: classid 1:1 htb rate 10mbit sudo tc class add dev eth0 parent 1:1 classid 1:30 htb rate 1mbit ceil 5mbit sudo tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip dport 80 0xffff flowid 1:30

Prioritize VoIP traffic (UDP port 5060):

sudo tc class add dev eth0 parent 1:1 classid 1:10 htb rate 1mbit ceil 10mbit prio 0 sudo tc filter add dev eth0 protocol ip parent 1:0 prio 1 u32 match ip dport 5060 0xffff flowid 1:10

Monitoring QoS

View stats and debug:

sudo tc -s qdisc show dev eth0 sudo tc -s class show dev eth0

Integrating VLANs, Bonding, and QoS

Combining these features enables complex and highly optimized networking setups. For instance:

  • Bonded NICs carry VLAN-tagged traffic to support isolated workloads.

  • QoS rules shape or prioritize traffic on each VLAN or logical interface.

Example:

  • bond0 carries trunked VLANs bond0.10, bond0.20

  • Apply different QoS to each VLAN to prioritize critical services

Consider MTU consistency across devices and proper switch configuration (e.g., LACP on switch ports, VLAN tagging).

Automation and Persistence

For larger environments or repeatable setups, use scripts or configuration management tools:

Example Bash script:

#!/bin/bash ip link add bond0 type bond ip link set bond0 type bond mode 802.3ad ip link set eth0 master bond0 ip link set eth1 master bond0 ip link add link bond0 name bond0.10 type vlan id 10 ip addr add 192.168.10.2/24 dev bond0.10 ip link set bond0 up ip link set eth0 up ip link set eth1 up ip link set bond0.10 up

Or use Ansible for repeatable deployments.

Troubleshooting Tips

Common Pitfalls
  • VLANs not reachable: Check switch port config.

  • Bonding fails: Validate mode compatibility and cabling.

  • QoS has no effect: Ensure rules match real traffic (e.g., port numbers).

Useful Commands
  • ip a: View all interfaces

  • ethtool eth0: NIC status

  • brctl show: For bridges

  • tcpdump -i eth0 vlan: Inspect VLAN-tagged traffic

  • tc -s: Inspect QoS stats

Conclusion

Advanced Linux networking empowers sysadmins and engineers to build scalable, resilient, and performance-tuned infrastructures. Mastering VLAN trunking, interface bonding, and QoS not only enhances the reliability of your network but also enables efficient resource allocation and traffic control.

These tools are not just optional for modern infrastructure—they are essential. By integrating them intelligently, you can deliver a highly available, secure, and optimized networking environment ready to meet enterprise-grade demands.

George Whittaker is the editor of Linux Journal, and also a regular contributor. George has been writing about technology for two decades, and has been a Linux user for over 15 years. In his free time he enjoys programming, reading, and gaming.

Load Disqus comments