{"id":2816,"date":"2022-02-23T00:47:25","date_gmt":"2022-02-23T00:47:25","guid":{"rendered":"https:\/\/dft.wiki\/?p=2816"},"modified":"2026-06-08T21:55:47","modified_gmt":"2026-06-09T01:55:47","slug":"network-bridge-link-aggregation-and-vlan-in-linux","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=2816","title":{"rendered":"Network Bridge, Link Aggregation, and VLAN in Linux"},"content":{"rendered":"<p>On-prem servers must deal with challenges that cloud providers handle behind the scenes.<\/p>\n<ul>\n<li>Network Bridge\n<ul>\n<li>Makes Linux work as a layer 2 switch, forwarding frames based on a local ARP table per interface.<\/li>\n<\/ul>\n<\/li>\n<li>Link Aggregation\n<ul>\n<li>Combines multiple network interfaces into a single interface for increased throughput and hardware fault tolerance.<\/li>\n<\/ul>\n<\/li>\n<li>VLAN\n<ul>\n<li>A Linux server can route traffic between multiple VLANs or serve across multiple sub-networks.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<p><strong>NETWORK BRIDGE<\/strong><\/p>\n<pre>sudo apt install bridge-utils -y\r\nsudo brctl addbr br0\r\nsudo brctl addif br0 eth0 eth1\r\nip addr show<\/pre>\n<p>Configuring bridging using <code>\/etc\/network\/interfaces<\/code>:<\/p>\n<pre># Set up interfaces manually:\r\niface <strong>eth0<\/strong> inet <strong>manual<\/strong>\r\niface <strong>eth1<\/strong> inet <strong>manual<\/strong>\r\n\r\n# Set up the bridge interface:\r\niface <strong>br0<\/strong> inet static\r\n    <strong>bridge_ports eth0 eth1<\/strong>\r\n<strong>    bridge-stp off<\/strong>\r\n<strong>    bridge-fd 0<\/strong>\r\n    address 192.168.1.2\r\n    broadcast 192.168.1.255\r\n    netmask 255.255.255.0\r\n    gateway 192.168.1.1<\/pre>\n<p>Additional options that may apply to your setup:<\/p>\n<ul>\n<li><strong>bridge_stp off<\/strong>\n<ul>\n<li>Disable Spanning Tree Protocol<\/li>\n<\/ul>\n<\/li>\n<li><strong>bridge_waitport 0<\/strong>\n<ul>\n<li>No delay before a port becomes available<\/li>\n<\/ul>\n<\/li>\n<li><strong>bridge_fd 0<\/strong>\n<ul>\n<li>No forwarding delay<\/li>\n<\/ul>\n<\/li>\n<li><strong>bridge_ports regex eth*<\/strong>\n<ul>\n<li>Match ports using a regular expression<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<p><strong>LINK AGGREGATION<\/strong><\/p>\n<p>Configuring LACP using <code>\/etc\/network\/interfaces<\/code>:<\/p>\n<pre>sudo apt install ifenslave -y\r\necho \"bonding\" | sudo tee -a \/etc\/modules\r\nmodprobe bonding\r\nsudo nano \/etc\/network\/interfaces<\/pre>\n<pre>auto bond0\r\niface bond0 inet static\r\n    address 192.168.1.101\r\n    netmask 255.255.255.0\r\n    gateway 192.168.1.1\r\n    dns-nameservers 192.168.1.1\r\n<strong>    bond-mode 802.3ad\r\n    bond-miimon 100\r\n    bond-lacp-rate fast\r\n    bond-slave eth0 eth1\r\n    bond-downdelay 200\r\n    bond-updelay 200\r\n    bond-lacp-rate 1\r\n    bond-xmit-hash-policy layer2+3<\/strong>\r\n\r\n<strong>allow-hotplug eth0<\/strong>\r\nauto eth0\r\niface eth0 inet <strong>manual<\/strong>\r\n\r\n<strong>allow-hotplug eth1<\/strong>\r\nauto eth1\r\niface eth1 inet <strong>manual<\/strong><\/pre>\n<pre>sudo systemctl restart networking\r\ncat \/proc\/net\/bonding\/bond0<\/pre>\n<p>Configuring LACP bonding using <code>Netplan<\/code>:<\/p>\n<pre>network:\r\n version: 2\r\n renderer: networkd\r\n ethernets:\r\n   eports:\r\n     match: \r\n       name: eth*\r\n bonds:\r\n   bond0:\r\n     interfaces: [eports]\r\n     addresses: [10.0.0.1\/24]\r\n     gateway4: 10.0.0.1\r\n     nameservers:\r\n       search: [domain.local]\r\n       addresses: [8.8.8.8]\r\n     parameters:\r\n       mode: 802.3ad\r\n       lacp-rate: fast\r\n       mii-monitor-interval: 100<\/pre>\n<p>Apply the configuration:<\/p>\n<pre>netplan status --diff --all\r\nsudo netplan apply\r\ncat \/proc\/net\/bonding\/bond0<\/pre>\n<hr \/>\n<p><strong>VLAN<\/strong><\/p>\n<p>Configure a VLAN via the command line (non-persistent):<\/p>\n<pre>sudo apt install vlan\r\nmodprobe --first-time 8021q\r\nmodinfo 8021q\r\nsudo ip link add link eth0 name eth0.100 type vlan id 100\r\nsudo ip addr add 192.168.1.2\/24 dev eth0.100<\/pre>\n<p>Configure a VLAN using <code>Netplan<\/code>.<\/p>\n<p>Edit the relevant file(s) in <code>\/etc\/netplan\/<\/code>:<\/p>\n<pre>network:\r\n  ethernets:\r\n    eth0:\r\n      dhcp4: true\r\n    vlans:\r\n        eth0.100:\r\n            id: 100\r\n            link: eth0\r\n            addresses: [192.168.10.10\/24]<\/pre>\n<p>Then restart the network service:<\/p>\n<pre>sudo systemctl restart systemd-networkd<\/pre>\n<p>Configure a VLAN using <code>ifconfig<\/code>:<\/p>\n<pre>sudo apt install net-tools -y<\/pre>\n<p>Add the following to <code>\/etc\/network\/interfaces<\/code>:<\/p>\n<pre>auto eth0.100\r\niface eth0.100 inet static\r\naddress 192.168.10.10\r\nnetmask 255.255.255.0\r\nvlan-raw-device eth0.100<\/pre>\n<p>Then bring the interface up:<\/p>\n<pre>sudo ifconfig eth0.100 up<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>On-prem servers must deal with challenges that cloud providers handle behind the scenes. Network Bridge [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,1],"tags":[],"class_list":["post-2816","post","type-post","status-publish","format-standard","hentry","category-linux","category-ccna"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/2816","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2816"}],"version-history":[{"count":7,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/2816\/revisions"}],"predecessor-version":[{"id":5689,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/2816\/revisions\/5689"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2816"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2816"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2816"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}