About

Given some equipment that has a wired network interface and a wireless network interface, both interfaces can be joined at the link layer using a bridge such that both interfaces act as one and there is no need for a split IP address space between the two interfaces.

Now additionally suppose that the wired network interface support jumbo frames, something very typical that is also typically not supported on wireless network interfaces. If one would bridge the two together, then the rules are that the lowest common denominator in regards to MTU is chosen such that a bridge created from a jumbo frame interface and a non-jumbo frame interface will end up acting as a non-jumbo frame interface. However, that is a big loss for a network that contains machines that are all capable of doing jump frames such that there must be some other way to use the same address space for the whole network, benefit from jumbo frames but also additionally have WiFi and wired Ethernet.

On Linux, there is a trick that leverages virtual interfaces in order to effectively "bridge two bridges" such that packets flow from one bridge to the other at the link layer without having to perform any sort of routing. Here is a sketch of what will be accomplished based on the following assumptions:

  • eth0 is a wired interface,
  • wlan0 is a wireless interface that is managed by hostapd,
  • veth0 and veth1 are virtual Ethernet devices

Only the wired bridge br0 has an IP address whereas the wireless bridge br1 does not have any IP address and is purely prophylactic in regards to the network layer. veth0 and veth1 perform the Ethernet frame translation automatically.

Whenever a wireless client connects via hostapd over the wlan0 interface, packets are transmitted over the bridge br1 that incidentally also contains veth1 that is linked (at the link layer) with veth0 such that the packets will end up spilling into br0. On br0 typically there is a DHCP server that hands out IP addresses to wired clients but since br0 is connected to br1, the DHCP server will end up handing IP addresses also to wireless clients.

Here is what the setup looks like in terms of ifupdown.

br0

The bridge br0 is statically initialized to:

  • ensure that the virtual Ethernet interface veth0 is up,
  • bridges the wired Ethernet interface eth0 and the virtual Ethernet interface veth0,
  • assigns an IP address of 192.168.1.1,
  • enables jumbo frames by setting the br0 MTU to 9000
auto br0
iface br0 inet static
    pre-up ifup veth0
    bridge_ports eth0 veth0
    address 192.168.1.1
    netmask 255.255.255.0
    mtu 9000

eth0

The wired Ethernet interface eth0 is just configured passively to set its MTU to 9000 without being brought up.

auto eth0
iface eth0 inet manual
    mtu 9000

br1

The wireless bridge interface br1 will be passively configured to:

  • ensure that the virtual Ethernet interface veth1 is up,
  • bridge the virtual Ethernet interface veth1,
  • set the MTU to 15000 that is compatible with the wireless interface wlan0
auto br1
iface br1 inet manual
    pre-up ifup veth1
    bridge_ports veth1
    mtu 1500

veth0 and veth1

veth0 and veth1 are the virtual Ethernet interfaces that will connect the two bridges br0 and br1. These virtual Ethernet interfaces are both configured in a Peer-to-Peer (P2P) manner where one interface sets the other as its peer and vice-versa.

Similarly, since veth0 will belong to the wired / jumbo frame capable bridge, jumbo frames are enabled on the virtual Ethernet interface veth0 but not on the virtual Ethernet interface that connects to the bridge br1 meant to work with non-jumbo frame capable interfaces.

auto veth0
iface veth0 inet manual
    pre-up ip link add veth0 type veth peer name veth1 || :
    hwaddress 02:00:00:01:00:00
    mtu 9000

iface veth1 inet manual
    pre-up ip link add veth1 type veth peer name veth0 || :
    hwaddress 02:00:00:01:00:01
    mtu 1500

DHCP

Regardless of DHCP brand, the DHCP server should be configured to listen just on br0.

HostAPd

Although out of the scope, wlan0 is managed by hostapd that adds wlan0 to the br1 bridge. The only configuration relevant concerning hostapd is the following:

interface=wlan0
bridge=br1

Note that one of the nicer things about this setup is that hostapd can be configured to enable 4addr and add STA interfaces to the bridge.

Efficiency

The setup described is highly efficient due to most of the interfaces involved living within memory space and without any hefty processing needs. There is no packet mangling going on here, address rewrites or even additional hardware involved. Similarly the bridges are connected at the link layer without any extra routing needs.


networking/bridging_two_bridges.txt ยท Last modified: 2023/06/21 00:35 by office

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.