Configuring networks on Linux systems is achievable with numerous tools and frameworks. Although today’s releases like RHEL, CentOS Stream, and Fedora rely on using NetworkManager with nmcli as its command-line client, traditional network scripts remain predominant — on server and virtualization installations where determinism, stability, and precise control are issues.
Networking scripts refer to system configuration files in /etc/sysconfig/network-scripts/
on RHEL-based systems and in /etc/network/interfaces
on Debian-based systems. The scripts they define determine how network interfaces are brought up at bootup and how they behave at runtime.
Mastering KVM Virtualization - The Ultimate eBook
From home labs to production clouds - master KVM Host management, automating KVM administration using Terraform, Vagrant, and cloud automation. This eBook will enable you to build scalable virtual infrastructure that works whether you're learning at home or deploying enterprise solutions. Get your full copy today
Scripts for network on a KVM host are highly useful since administrators would be able to have persistent configurations for:
- Static IP Addresses
- Linux bridges for connecting virtual machines to the externeral network
- Bonded interfaces for performance and for redundancy
- VLANs and high-end topologies employed for virtualization labs or production clusters
Ensute bridge utilities package are installed:
# Debian-based systems
sudo apt update && sudo apt install bridge-utils
# SLES / openSUSE
sudo zypper -n install bridge-utils
# Arch-based systems
sudo pacman -Syu bridge-utils
1. Create Linux bridge (No VLAN)
This method of Linux bridge creation involves manually editing the traditional network configuration files to define a virtual network bridge.
The resuting bridge allows multiple network interfaces to communicate as if they are on the same physical network segment.
Debian-based Systems
Ensure the bridge utilities package is installed:
sudo apt update && sudo apt install bridge-utils
List available networkn interfaces in your machine:
ip link show
Once you have the name of your physical interface, set the variables to be used in network cofigurations.
# Specofy Physical interface added to bridge (e.g ens3)
PHY_INT=ens3
# Specify the name of the bridge interface (e.g br0)
BR_NAME=br0
If using static IP address on the bridge provide extra configurations
# Static IP address of the bridge
IPADDR=192.168.1.10
# The subnet mask
NETMASK=255.255.255.0
# The default gateway
GATEWAY=192.168.1.1
# DNS server 1
DNS1=8.8.8.8
# DNS server 2
DNS2=8.8.4.4
For Debian-based systems, we edit the network interfaces file /etc/network/interfaces
to configure the bridge. But first backup the current network configuration file:
sudo cp /etc/network/interfaces{,.bak}
- Bridge using DHCP
sudo tee -a /etc/network/interfaces<<EOF
auto ${BR_NAME}
iface ${BR_NAME} inet dhcp
bridge_ports ${PHY_INT}
bridge_stp off # disable Spanning Tree Protocol
bridge_fd 0 # no forwarding delay
bridge_maxwait 0 # no delay for interface to come up
auto ${PHY_INT}
iface ${PHY_INT} inet manual
EOF
- Bridge with Static IP Addressing
To include IP address, subnet mask, gateway, and DNS servers in the bridge configuration, adjust like below.
sudo tee -a /etc/network/interfaces<<EOF
auto lo
iface lo inet loopback
auto ${BR_NAME}
iface ${BR_NAME} inet static
address ${IPADDR}
netmask ${NETMASK}
gateway ${GATEWAY}
dns-nameservers ${DNS1} ${DNS2}
bridge_ports ${PHY_INT}
bridge_stp off
bridge_fd 0
bridge_maxwait 0
auto ${PHY_INT}
iface ${PHY_INT} inet manual
EOF
Before we restart networking service, open the file manually to validate configurations, and delete any duplicates.
# Open and validate settings, rectify any duplicates
sudo nano /etc/network/interfaces
Go through the settings and make any changes accordingly. Once done, restart the networking service for the changes to be applied.
sudo systemctl restart networking
RHEL-based Systems
# CentOS Stream / Rocky / AlmaLinux
sudo dnf -y install epel-release
sudo dnf -y install bridge-utils
# RHEL 9
sudo subscription-manager repos \
--enable codeready-builder-for-rhel-9-$(arch)-rpms
sudo dnf install \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
sudo dnf -y install bridge-utils
# RHEL 8
sudo subscription-manager repos \
--enable codeready-builder-for-rhel-8-$(arch)-rpms
sudo dnf install \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf -y install bridge-utils
Check your ethernet interface name.
ip link show
# OR
ip addr
Set the variables to be used.
# Specify the name of the physical interface (eth0)
PHY_INT=eth0
# Specify the name of the bridge interface (br0)
BR_NAME=br0
If using static IP address on the bridge provide extra configurations.
# Static IP address of the bridge
IPADDR=192.168.1.10
# The subnet mask
NETMASK=255.255.255.0
# The default gateway
GATEWAY=192.168.1.1
# DNS server 1
DNS1=8.8.8.8
# DNS server 2
DNS2=8.8.4.4
It’s recommended to back up existing network configurations before making any changes.
sudo cp /etc/sysconfig/network-scripts/ifcfg-${PHY_INT} \
/etc/sysconfig/network-scripts/ifcfg-${PHY_INT}.bak
Create a new network configuration file for defined bridge interface:
- Using DHCP – If using DHCP server to assign IP address to bridge
sudo tee /etc/sysconfig/network-scripts/ifcfg-${BR_NAME}<<EOF
DEVICE=${BR_NAME}
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
DELAY=0
EOF
- Using Static IP Address – Manually assigning IP address information to bridge.
sudo tee /etc/sysconfig/network-scripts/ifcfg-${BR_NAME}<<EOF
DEVICE=${BR_NAME}
TYPE=Bridge
BOOTPROTO=none
IPADDR=${IPADDR}
NETMASK=${NETMASK}
GATEWAY=${GATEWAY}
DNS1=${DNS2}
DNS2=${DNS2}
ONBOOT=yes
DELAY=0
EOF
Configure Physical Interface:
sudo tee /etc/sysconfig/network-scripts/ifcfg-${PHY_INT}<<EOF
DEVICE=${PHY_INT}
TYPE=Ethernet
BRIDGE=${BR_NAME}
BOOTPROTO=none
ONBOOT=yes
EOF
Apply the changes by restarting the network service.
sudo systemctl restart network
Ensure the bridge is configured correctly by cheking its status:
ip add show ${BR_NAME}
2. Create Linux bridge (With VLAN)
Debian-based systems
Let’s assume the physcial interface is eno1 and VLAN ID is 100. Here’s how you will create a sub-vlan interface.
sudo apt update
sudo apt install bridge-utils vlan
Ensure that the 8021q
module required for VLAN is loaded.
sudo modprobe 8021q
To ensure it loads on boot, add it to /etc/modules
.
echo 8021q | sudo tee -a /etc/modules
Add VLAN interface to the /etc/network/interfaces
file.
sudo nano /etc/network/interfaces
- Using DHCP
auto eno1.100
iface eno1.100 inet manual
vlan-raw-device eno1
auto br0
iface br0 inet dhcp
bridge_ports eno1.100
bridge_stp off
bridge_fd 0
bridge_maxwait 0
- Using Static IP Address
auto eno1.100
iface eno1.100 inet manual
vlan-raw-device eno1
auto br0
iface br0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
bridge_ports eno1.100
bridge_stp off
bridge_fd 0
bridge_maxwait 0
When done with the configurations restart networking service.
sudo systemctl restart networking
RHEL-based systems
Install necessary packages on your system.
sudo dnf install -y NetworkManager network-scripts
Confirm that kernel modules are loaded:
sudo modprobe --first-time 8021q
modinfo 8021q
Step 1: Configure physical network Interface
Edit the physical interface configuration:
sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
Add and modify the contents. Don’t forget to replace eth0
with your actual interface as seen from ip ad
or ip link show
commands:
DEVICE=eth0
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
Step 2: Create VLAN Interface
Create a configuration file for the VLAN interface. Here VLAN ID used is 100
.
sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0.100
Add the following content to the file. Modify to work for your network setup.
DEVICE=eth0.100
BOOTPROTO=none
ONBOOT=yes
VLAN=yes
BRIDGE=br0
Step 3: Create Bridge Interface
Create a configuration file for the bridge interface.
sudo vi /etc/sysconfig/network-scripts/ifcfg-br0
- Bridge Using DHCP
DEVICE=br0
TYPE=Bridge
BOOTPROTO=dhcp
ONBOOT=yes
STP=off
- Bridge with Static IP Configurations
DEVICE=br0
TYPE=Bridge
BOOTPROTO=none
ONBOOT=yes
STP=off
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
Restart network service when done.
# If using network service
sudo systemctl restart network.service
# If using NetworkManager
sudo systemctl restart NetworkManager
Validate your network configurations:
# List bridges
brctl show
# IP configurations
ip addr
# Interfaces
ip link show
3. Create Linux bridge on Bond / Team interface
eth0
is your management interfaceeth1
andeth2
are the interfaces bonded together- Bond name is
bond0
Available bonding modes
Bonding Mode | Description | Switch Configuration |
---|---|---|
0 (balance-rr) | Round-robin distribution of packets across interfaces. | Static Etherchannel (not LACP-negotiated) |
1 (active-backup) | One interface is active, others are in backup mode. | Autonomous ports |
2 (balance-xor) | XOR hashing of MAC addresses to distribute packets across interfaces. | Requires specific switch configuration |
3 (broadcast) | Broadcast packets to all interfaces. | Not recommended for most use cases |
4 (802.3ad) | LACP (Link Aggregation Control Protocol) for dynamic link aggregation. | LACP-capable switch required |
5 (balance-tlb) | Transmit load balancing based on destination MAC address hash. | No specific switch configuration required |
6 (balance-alb) | Adaptive load balancing based on traffic patterns. | No specific switch configuration required |
BONDING_OPTS Parameters
The BONDING_OPTS
parameter in a bonding interface configuration allows you to specify additional options for the bonding driver. Here’s a table of commonly used options:
Option | Description |
---|---|
mode | Specifies the bonding mode (e.g., 0 , 1 , 4 ). |
miimon | ARP/ICMP link monitoring interval in milliseconds. |
downdelay | Delay before marking a slave down (milliseconds). |
updelay | Delay before marking a slave up (milliseconds). |
lacp_rate | LACP rate (slow/fast) for mode 4 (802.3ad). |
xmit_hash_policy | Transmit hash policy (e.g., layer2 , layer3+4 ). |
arp_ip | IP address for ARP requests. |
fail_over_mac | MAC address to use for the bond interface. |
On Debian-Based Systems
Follow these steps on a Debian based Linux machine.
Step 1: Install Packages and Load modules
sudo apt update
sudo apt install vlan ifenslave bridge-utils
Load necessary modules
sudo modprobe bonding vlan
echo bonding | sudo tee -a /etc/modules
Step 2: Configure Bonding Interface
Edit the /etc/network/interfaces
file to create a bonding interface
sudo nano /etc/network/interfaces
Define interfaces used in bond (bond0)
# Define interfaces used in bonded interface
auto eth1
iface eth1 inet manual
bond-master bond0
auto eth2
iface eth2 inet manual
bond-master bond0
Add bond network configurations
- Using mode
0 (balance-rr)
example:
auto bond0
iface bond0 inet manual
bond-slaves eth1 eth2
bond-miimon 100
bond-mode balance-rr
- Using mode
4 (802.3ad)
example:
auto bond0
iface bond0 inet manual
bond-slaves eth1 eth2
bond-miimon 100
bond-mode 802.3ad
bond-lacp-rate 1
- Using mode
1 (active-backup)
example:
auto bond0
iface bond0 inet manual
bond-slaves eth1 eth2
bond-miimon 100
bond-mode active-backup
Step 3: Add bridge configurations
We can complete the setup by creating a linux bridge with static IP address.
- Bridge with DHCP
# Bridge setup
auto br0
iface br0 inet dhcp
bridge_ports bond0
bridge_stp off # Disable Spanning Tree Protocol
bridge_fd 0 # Forwarding delay 0 for fast forwarding
bridge_maxwait 0 # No delay during bridge creation
- Bridge with static IP address
# Bridge setup
auto br0
iface br0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
bridge_ports bond0
bridge_stp off # Disable Spanning Tree Protocol
bridge_fd 0 # Forwarding delay 0 for fast forwarding
bridge_maxwait 0 # No delay during bridge creation
Restart networking service to changes to take effect:
sudo systemctl restart networking
Creating a bond on VLAN interface
By combining bonding (link aggregation) and VLAN (virtual LAN) tagging features, you can optimize network connectivity and segmentation effectively.
Let’s consider the following environment:
- Physical interfaces used in bonding
eth1
andeth2
- VLAN ID:
100
- Bridge name:
br0
- Bond name:
br0
Here are complete network configurations that can be customized to your needs.
# Ethernet interfaces
auto eth1
iface eth1 inet manual
bond-master bond0
auto eth2
iface eth2 inet manual
bond-master bond0
# Bonding setup on VLAN 100
auto bond0.100
iface bond0.100 inet manual
bond-slaves eth1 eth2
bond-miimon 100
bond-mode active-backup
vlan-raw-device bond0
# Bridge setup
auto br0
iface br0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 8.8.8.8 8.8.4.4
bridge_ports bond0.100
bridge_stp off # Disable Spanning Tree Protocol
bridge_fd 0 # Forwarding delay 0 for fast forwarding
bridge_maxwait 0 # No delay during bridge creation
On RHEL-based Systems
Step 1: Install necessary packages / load module
Install all the necessary packages:
sudo dnf install -y NetworkManager teamd
Load kernel module using modprobe
command:
sudo modprobe bonding && modinfo bonding
Step 2: Create Bond interface
Next create a bond interface configuration file
sudo vi /etc/sysconfig/network-scripts/ifcfg-bond0
Add and customize the contents below.
- Example on using mode 1 (active-backup):
NAME=bond0
DEVICE=bond0
TYPE=Bond
ONBOOT=yes
BONDING_MASTER=yes
BOOTPROTO=none
BONDING_OPTS="mode=active-backup miimon=100"
BRIDGE=br0
NM_CONTROLLED=no
- BONDING_OPTS configurations when using mode 4 (802.3ad):
BONDING_OPTS="mode=802.3ad lacp_rate=fast miimon=100"
#OR
BONDING_OPTS="mode=4 lacp_rate=fast miimon=100"
- BONDING_OPTS configurations when using mode 0 (balance-rr):
BONDING_OPTS="mode=balance-rr miimon=100"
#OR
BONDING_OPTS="mode=0 miimon=100"
Step 3: Configure Bond Slaves
Create configuration files for the interfaces to be used in the bond (e.g., eth1 and eth2).
- For
eth1
sudo vi /etc/sysconfig/network-scripts/ifcfg-eth1
Add configuration for eth1
interface.
NAME=bond0-slave0
DEVICE=eth1
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
NM_CONTROLLED=no
- For
eth2
sudo vi /etc/sysconfig/network-scripts/ifcfg-eth2
Add configuration for eth2
interface.
NAME=bond0-slave1
DEVICE=eth2
ONBOOT=yes
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
NM_CONTROLLED=no
Step 4: Create Bridge Interface
Create a configuration file for the bridge interface.
sudo vi /etc/sysconfig/network-scripts/ifcfg-br0
- With DHCP
DEVICE=br0
TYPE=Bridge
BRIDGE_PORTS=bond0
BOOTPROTO=dhcp
ONBOOT=yes
NM_CONTROLLED=no
DELAY=0
- With Static IP address
DEVICE=br0
TYPE=Bridge
BRIDGE_PORTS=bond0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
NM_CONTROLLED=no
DELAY=0
Creating a VLAN interface on a bond
- Bond name:
bond0
- VLAN ID:
100
Step 1: Create bond interface configuration:
- Create
/etc/sysconfig/network-scripts/ifcfg-bond0
NAME=bond0
DEVICE=bond0
TYPE=Bond
ONBOOT=yes
BONDING_MASTER=yes
BOOTPROTO=none
BONDING_OPTS="mode=active-backup miimon=100"
NM_CONTROLLED=no
Step 2: Create VLAN interface on bond
- Create
/etc/sysconfig/network-scripts/ifcfg-bond0.100
DEVICE=bond0.100
BOOTPROTO=none
ONBOOT=yes
TYPE=VLAN
PHYSDEV=bond0
VLAN=yes
BRIDGE=br0
NM_CONTROLLED=no
Step 3: Create Linux Bridge on Bond VLAN Interface
- Create
/etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DNS2=8.8.4.4
NM_CONTROLLED=no
Restart network after making all the configurations
sudo systemctl restart network
🌍 Whether at work or on the go, access Mastering KVM Virtualization anytime, in the book you will learn:
- Host Network Management using Netplan: bridges, VLANs, Bonded interfaces
- Host Network Management using Network Manager (NMCLI) – bridged, VLANs, Bonds/Teamed
- Host Network Management using Networking Scripts
- Host Network Management using Open vSwitch
Watch out for other KVM guides from our team: