You are on page 1of 6

8/8/2020 How to Configure Network Bridge in Ubuntu 8/8/2020 How to Configure Network Bridge in Ubuntu

How to Configure Network Bridge in Ubuntu Creating a Network Bridge Using NetPlan in Ubuntu

tecmint.com/create-network-bridge-in-ubuntu Netplan is a simple and easy-to-use front-end utility for configuring networking in Linux using
the YAML format. It currently supports NetworkManager and systemd-netword as backend
Linux supports the implementation of a software network bridge to reproduce the function of a tools.
network bridge, a networking device that interconnects two or more communication networks or
To configure networking for an interface such as a bridge, edit your netplan configuration file
network segments providing a way for them to work as a single network. It acts almost like a
found in /etc/netplan/ directory.
network switch, and in a software sense, it is used to implement the concept of a “virtual network
switch”. The following is an example configuration file, where the renderer is systemd-netword which is
the default (replace enp1s0 with your ethernet interface name).
A typical use case of software network bridging is in a virtualization environment to connect
virtual machines (VMs) directly to the host server network. This way, the VMs are deployed on network:
the same subnet as the host and can access services such as DHCP and much more. version: 2
renderer: networkd
ethernets:
In this article, you will learn different ways to set up a network bridge in Ubuntu and use it within
enp1s0:
a virtualization environment to create virtual networking in a bridged mode under VirtualBox and dhcp4: no
KVM, to connect Virtual Machines to the same network as the host. bridges:
br0:
dhcp4: yes
Installing Network Bridge Utilities in Ubuntu interfaces:
- enp1s0
Begin by installing the bridge-utils package which contains utilities for configuring the Ubuntu
ethernet bridge using the apt package manager as shown.

$ apt-get install bridge-utils

Next, identify the interface name for your ethernet device using the IP command as shown.

$ ip ad
OR
$ ip add

Netplan Configuration File

Save the configuration file and apply the configuration to enable the bridge network by running
the following command.

$ sudo netplan apply

Then use the brctl command to show all bridges on the system. In this case, the Ethernet
interface is automatically added as a port to the bridge.

$ sudo brctl show

Check Network Interfaces in Ubuntu

https://www.tecmint.com/create-network-bridge-in-ubuntu/ 1/12 https://www.tecmint.com/create-network-bridge-in-ubuntu/ 2/12


8/8/2020 How to Configure Network Bridge in Ubuntu 8/8/2020 How to Configure Network Bridge in Ubuntu

Next, activate the bridge connection as follows (you can use either the connection/interface name
or the UUID).

$ sudo nmcli conn up br0


OR
Show Network Bridges
$ sudo nmcli conn up e7385b2d-0e93-4a8e-b9a0-5793e5a1fda3

If you want to bring down or deactivate the created network bridge, then delete it using the
following commands.

$ sudo ip link set enp1s0 up Activate Bridge Network Connection


$ sudo ip link set br0 down
$ sudo brctl delbr br0
Then deactivate the Ethernet interface or connection.
OR
$ sudo nmcli conn up Wired\ connection\ 1
$ sudo nmcli conn down Ethernet\ connection\ 1
$ sudo nmcli conn down br0
OR
$ sudo nmcli conn del br0
$ sudo nmcli conn down 525284a9-60d9-4396-a1c1-a37914d43eff
$ sudo nmcli conn del bridge-br0

Creating a Network Bridge Using Nmcli in Ubuntu


nmcli is a widely-used network manager command-line tool to administer NetworkManager Deactivate Ethernet Connection
(create, show, edit, delete, activate, and deactivate network connections) and displaying network
device status. Now try to view active connections once more, the Ethernet interface should now be a slave in
the bridge connection as shown in the following screenshot.
To create a network bridge using nmcli, run the following command.
$ sudo nmcli conn show --active
$ sudo nmcli conn add type bridge con-name br0 ifname br0

Create a Network Bridge Using nmcli Tool


Check Active Network Connections
Then add the Ethernet interface as a port in the bridge as shown (remember to replace enp1s0
with your device name). Creating a Network Bridge Using nm-connection-editor Tool
$ sudo nmcli conn add type ethernet slave-type bridge con-name bridge-br0 ifname To open the nm-connection-editor application, run the following command from the terminal.
enp1s0 master br0
$ nm-connection-editor

From the network connections editor window, click on the + sign to add a new connection
Add a Network Bridge Ports profile.

Next, confirm that the bridge has been created by showing all network connections.

$ sudo nmcli conn show --active

Verify Network Bridge

https://www.tecmint.com/create-network-bridge-in-ubuntu/ 3/12 https://www.tecmint.com/create-network-bridge-in-ubuntu/ 4/12


8/8/2020 How to Configure Network Bridge in Ubuntu 8/8/2020 How to Configure Network Bridge in Ubuntu

Next, set the bridge connection name and the interface name.

Add a New Network Connection

Next, choose the connection type as Bridge from the drop-down and click Create.

Set Bridge Connection Name

Then click the Add button to add the bridge slave ports i.e the Ethernet interface as shown in the
following screenshot. Select Ethernet as the connection type and click Create.

Select Network Connection Type

https://www.tecmint.com/create-network-bridge-in-ubuntu/ 5/12 https://www.tecmint.com/create-network-bridge-in-ubuntu/ 6/12


8/8/2020 How to Configure Network Bridge in Ubuntu 8/8/2020 How to Configure Network Bridge in Ubuntu

Set New Bridge Connection Name

Under bridged connections, the new connection should now appear.

Add a Network Bridge Connection

Next, set the connection name according to your preference and click Save.

https://www.tecmint.com/create-network-bridge-in-ubuntu/ 7/12 https://www.tecmint.com/create-network-bridge-in-ubuntu/ 8/12


8/8/2020 How to Configure Network Bridge in Ubuntu 8/8/2020 How to Configure Network Bridge in Ubuntu

Verify New Bridge Connection

Now if you open the network connection editor once more, the new bridge interface and the slave
interface should exist as indicated in the following screenshot.
Check Network Bridge Connection

Next, activate the bridge interface and deactivate the Ethernet interface, using the nmcli command.

$ sudo nmcli conn up br0


$ sudo nmcli conn down Ethernet\ connection\ 1

How to Use a Network Bridge in a Virtualization Software

After setting up a network bridge (virtual network switch), you can use it in a virtualization
environment such as Oracle VirtualBox and KVM to connect VMs to the host network.

https://www.tecmint.com/create-network-bridge-in-ubuntu/ 9/12 https://www.tecmint.com/create-network-bridge-in-ubuntu/ 10/12


8/8/2020 How to Configure Network Bridge in Ubuntu 8/8/2020 How to Configure Network Bridge in Ubuntu

Using a Network Bridge in Oracle VirtualBox From the web console, it will be select automatically. Besides, you can also configure a network
bridge using the virsh command-line tool, and a VM’s XML configuration file.
Open VirtualBox, then from the list of VMs, select a VM, then click on its settings. From the
settings window, go to the Network option and select an adapter (e.g Adapter 1). For more details, read the netplan and nmcli man pages (by running man netplan and man
nmcli ) as well as virtual networking in libvirt and virtual networking in VirtualBox. You can
Then check the option Enable Network Adapter, set the value of the attached to the field to
post any queries to us via the comment section below.
Bridged Adapter, then set the Name of the bridged interface (e.g br0) as indicated in the
following screenshot. Then click Ok.

Configure VM to Use Bridge Network in VirtualBox

Using a Network Bridge in KVM

You can use the new network bridge under KVM by adding the --network=bridge=br0
option while creating a new virtual machine, using the virt-install command.

# virt-install --virt-type=kvm --name Ubuntu18.04 --ram 1536 --vcpus=4 --os-


variant=ubuntu18.04 --cdrom=/path/to/install.iso --network=bridge=br0,model=virtio
--graphics vnc --disk
path=/var/lib/libvirt/images/ubuntu18.04.qcow2,size=20,bus=virtio,format=qcow2

https://www.tecmint.com/create-network-bridge-in-ubuntu/ 11/12 https://www.tecmint.com/create-network-bridge-in-ubuntu/ 12/12

You might also like