Ubuntu Server on Raspberry Pi 4: Setting up a Layer 2 WiFi-Ethernet Bridge that Forwards DHCP Requests
In this article, we will walk through the process of setting up a Layer 2 WiFi-Ethernet bridge on Ubuntu Server 64-bit running on a Raspberry Pi 4B. The setup will involve connecting a USB WiFi dongle in WDS/4addr/AP mode to a gateway, and configuring the bridge using the iproute2 tool.
Prerequisites
- A Raspberry Pi 4B with Ubuntu Server 64-bit installed
- A USB WiFi dongle with WDS/4addr/AP mode support
- A gateway to connect to
Setting up the Bridge
The first step is to set up the bridge between the WiFi and Ethernet interfaces. To do this, we will use the iproute2 tool. Run the following command to bring up the WiFi and Ethernet interfaces:
sudo ip link set wlan0 up
sudo ip link set eth0 up
Next, we will create the bridge and add the WiFi and Ethernet interfaces to it. Run the following commands:
sudo ip link add name br0 type bridge
sudo ip link set br0 up
sudo ip link set wlan0 master br0
sudo ip link set eth0 master br0
At this point, the bridge is set up and the WiFi and Ethernet interfaces are added to it. However, the bridge is not yet forwarding DHCP requests. To enable this, we need to configure the DHCP client to request an IP address on the bridge interface.
Configuring DHCP
To configure DHCP, we will use the dhclient tool. Run the following command to request an IP address on the bridge interface:
sudo dhclient -d -v br0
This will start the DHCP client and request an IP address on the bridge interface. Once an IP address has been obtained, the bridge will begin forwarding DHCP requests.
Verifying the Setup
To verify that the setup is working correctly, we can use the ping command to test the connectivity. Run the following command:
ping -c 4 google.com
If the ping is successful, this indicates that the bridge is forwarding DHCP requests and the setup is working correctly.
- Setting up a Layer 2 WiFi-Ethernet bridge on Ubuntu Server 64-bit running on a Raspberry Pi 4B involves bringing up the WiFi and Ethernet interfaces, creating a bridge, and adding the interfaces to the bridge.
- To enable the bridge to forward DHCP requests, the DHCP client must be configured to request an IP address on the bridge interface.
- The setup can be verified using the ping command.
References
--endarticle--