Creating a Network Bridge (wlan0, eth1) to Connect a Second Device to eth0 on Ubuntu 20.04
In this article, we will discuss the steps required to create a network bridge between wlan0 and eth1 on an Ubuntu 20.04 box, with the goal of connecting a second device to the eth0 interface. This setup can be useful in a variety of scenarios, such as extending a wireless network or creating a wired/wireless hybrid network.
Network Topology
The network topology for this setup is as follows:
- WiFi router with private IP address 10.12.12.1
- Ubuntu 20.04 box with Nvidia Jetson, connected to the WiFi network
- Second device to be connected to the eth0 interface on the Ubuntu 20.04 box
Prerequisites
Before we begin, make sure that you have the following prerequisites in place:
- Ubuntu 20.04 box with Nvidia Jetson
- WiFi router with private IP address 10.12.12.1
- Second device to be connected to the eth0 interface on the Ubuntu 20.04 box
- Sufficient network cables and hardware to connect the devices
Step 1: Install the Required Packages
To create a network bridge on Ubuntu 20.04, we will need to install the bridge-utils and dnsmasq packages. To do this, open a terminal and run the following commands:
sudo apt update
sudo apt install bridge-utils dnsmasqStep 2: Create the Network Bridge
Once the required packages are installed, we can create the network bridge. To do this, run the following command:
sudo nano /etc/network/interfaces.d/bridge-networkThis will open a new file in the nano text editor. Add the following lines to the file, replacing eth1 with the name of the interface you want to use for the bridge:
auto br0
iface br0 inet dhcp
bridge_ports eth1
wireless-mode managed
wireless-essid
wireless-key Save and close the file. Then, run the following command to bring the bridge up:
sudo ifup br0Step 3: Connect the Second Device
Now that the network bridge is up and running, you can connect the second device to the eth0 interface on the Ubuntu 20.04 box. Once connected, the second device should be able to access the network through the bridge.
Step 4: Configure DHCP
To provide DHCP service to the devices connected to the bridge, we will need to configure the dnsmasq package. To do this, run the following command:
sudo nano /etc/dnsmasq.confAdd the following lines to the file, replacing 10.12.12.1 with the IP address of your WiFi router:
interface=br0
dhcp-range=10.12.12.50,10.12.12.150,255.255.255.0,24h
dhcp-option=3,10.12.12.1
dhcp-option=6,10.12.12.1Save and close the file. Then, restart the dnsmasq service with the following command:
sudo systemctl restart dnsmasqStep 5: Test the Setup
To test the setup, connect a second device to the eth0 interface on the Ubuntu 20.04 box and check that it is able to access the network through the bridge. You can also check the status of the bridge with the following command:
brctl showIn this article, we have discussed the steps required to create a network bridge between wlan0 and eth1 on an Ubuntu 20.04 box, with the goal of connecting a second device to the eth0 interface. This setup can be useful in a variety of scenarios, such as extending a wireless network or creating a wired/wireless hybrid network. We have covered the following topics:
- Network topology
- Prerequisites
- Installing the required packages
- Creating the network bridge
- Connecting the second device
- Configuring DHCP
- Testing the setup