Ubuntu 20 or 22 Network Router (Bridge) Configuration with NetPlan

Mindwatering Incorporated

Author: Tripp W Black

Created: 02/27/2023 at 04:46 PM


Configuration Files


Set-up an Ubuntu workstation as a network bridge.
If you are not comfortable w/a console/terminal prompt, and would prefer a graphical interface, install the regular Ubuntu workstation software rather than the minimal Ubuntu server.

That said, if you choose the graphical workstation, you will still need to do the bridge configuration "by hand" via terminal.

These instructions assume:
- the workstation is set-up with the network management using NetPlan (networking system software) vs. systemd
- that the ISP, if the network gateways are ISP managed, are both (one for each network) willing to add a "static route"
- that the workstation has two network cards, and one is connected to the first internal network (LAN1) and the other is connected to the second internal network (LAN2).
- that the workstation will get its network address/IP dynamically via DHCP4.
- For this example, the following networking environment exists
LAN1 -
LAN2 -
LAN1 Gateway -
LAN2 Gateway -
- For this example, the following NIC (network interface cards/ports) are in the workstation
PC NIC1 = ens160, with static IP of
PC NIC2 = ens162, with static IP of
- The primary user is My Admin, with the login myadmin, that is set-up during the installation.

1. Install Ubuntu
Insert the appropriate "Live" DVD or use the appropriate disk image/ISO file.
If using the minimal server installation, ensure the install SSH is left checked (enabled) for remote network access this workstation from other workstations on the LAN.

2. After your installation, login as your primary user, myadmin confirm your network addresses.
Open a Terminal window, and enter the following command.
$ ip address
<view output, ignore the local loopback, lo interface >
. . .
2. ens160: ...
inet 10.0.1.nn ...
3. ens162: ...
inet 192.168.1.nn ...

- Both NICs are likely to have the DHCP addresses assigned by each of the two network gateways.
- Current this workstation has access to both networks, and can browse, use printers, etc. on both. However, neither of the workstations on either network know how to get to the "other" network.

3. Update the installation to switch the workstation to routing (technically bridging is one LAN subset) mode.
a. In the existing Terminal window locate the NetPlan networking file.
$ cd /etc/NetPlan/
$ ls
<view output>

- The filename may vary. Use the filename above for the next step below.

b. Edit the file, use the sequence <esc>:wq to save the change. Use <i> to insert new text.
$ sudo vi /etc/netplan/01-network-manager-all.yaml
version: 2
renderer: networkd
dhcp4: no
- to:
table: 101
- from:
table: 101
dhcp4: no
- to: default
- to:
table: 102
- from:
table: 102

c. Restart the network:
$ sudo systemctl restart network

4. Disable the firewall:
$ sudo ufw status
<view output>

If not already disabled, disable the UFW firewall service with:
$ sudo ufw disable

In the YAML above, we created static routes for each of the NICs/gateways, add a static route on each gateway to route through this new workstation.
- From the gateway, set the static route to the network to go via (through)
- From the gateway, set the static route to the network to go via (through)

$ sudo netplan try
<review for errors>

$ sudo netplan apply

5. Test from other workstations on either side.

previous page