Metadata:
How to create a network bridge on Ubuntu Server to share a network connection as an ethernet gateway.
- Initially published on 10-30-2024.
- Parent note: Raspberry Pi Network Interface
Sharing network connections on Ubuntu Server
Last post we took a look at the utility of the Raspberry Pi as a network interface. One use-case for the device was using it as a wireless adaptor for my desktop computer instead of purchasing some new internal or external adapter.
This was done with respect to using Ubuntu as an operating system with access to a GUI. The screenshots shared showed the network manager interface and showed the options that were navigated.
In a realistic scenario, this would likely be done without a graphical user interface, such as in a shell to Ubuntu Server. In such cases, in order to do this, the network manager must first be installed:
Doing this may require access to the internet. This depends on whether the server image came packaged with this utility. This can present a scenario where the tool cannot be installed because wifi is necessary to connect to the network in the first place! This depends on the wireless network's passphrase encryption method.
If the encryption method is WEP, then the user must navigate to the Netplan configuration file and use root permissions to alter /ect/netplan/50-cloud-init.yaml to include the correct passphrase. The file will include information similar of the following:
The ip a within the terminal, which will list all the hardware network interfaces on a device.
I've not tried the above solution. This is due to the fact that my network uses WPA2 as a key encryption method, which Netplan doesn't seem to natively support. This necessitates the usage of the Network Manager utility.
In this case, an ethernet connection was used to install the utility. If one cannot access an ethernet connection to allow the installation, then they will need to discover an alternative approach to gain access to the package - such as downloading the package to some piece of external storage and transferring it to the device that requires it.
Once Network Manager is installed, the utility can be used to discover and connect to a wireless SSID.
To discover a wireless network, use the following command:
From the list, select an applicable
A successful run of this command will return the following: Device <adapter-id> successfully activated with <machine identifier string>
One can now use ping or wget to test their connection and confirm that the wireless interface is working.
Bridging the connection
Once the wireless interface is working, Network Interface can be used to create the network bridge. Run the following:
Where ip a within the terminal.
A successful return of the above command should read similar to Connection '<arbitrary-label>' (<machine identifier string>) successfully added. We can then run:
Which will then give a response that reads similar to Connection successfully activated (D-Bus active path: <directory>) where the directory in this case was /org/freedesktop/NetworkManager/ActiveConnection/6
The network connection is now shared! One may need to restart the device that is acting as a gateway and any device that is using it as a gateway.