192.168.56.0/24
|
192.168.56.1 | 192.168.56.17 (Wired connection 1)
| v |
The internet --- gateway router *-------------------* (enp1s0) *---- (... app sockets)
|
|------> Your machine
192.168.56.0/24 (bridge-slave-enp1s0)
| |
192.168.56.1 | | 192.168.56.17
| v v |
The internet --- gateway router *-------------------* (enp1s0) *---------* (br0) *---- (... app sockets)
| *
|------> Your machine |
+---- (... libvirt VMs, could direct attachable and no need to NAT)
Show current connection definitions:
$ nmcli conn show
NAME UUID TYPE DEVICE
Wired connection 1 baf0574f-34d5-30d4-8b65-a5bf1d06c85e ethernet enp1s0
$ ip a
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 12:34:56:62:90:90 brd ff:ff:ff:ff:ff:ff
inet 192.168.56.17/24 brd 192.168.56.255 scope global noprefixroute enp1s0
valid_lft forever preferred_lft forever
Define bridge interface and connects between bridge and physical interface:
$ nmcli conn add ifname br0 type bridge con-name br0
$ nmcli conn add type bridge-slave ifname enp1s0 master br0
Setup bridge interface attributes:
$ nmcli conn modify br0 ipv4.addresses 192.168.56.17/24
$ nmcli conn modify br0 ipv4.gateway 192.168.56.1
$ nmcli conn modify br0 ipv4.dns 192.168.56.1
$ nmcli conn modify br0 ipv4.method manual
$ nmcli conn up br0
Delete defaulted physical interface definition:
- CAUTION: Running this command on ssh will be disconnected. You will need to reconnect after ran 1 minute or later.
$ nmcli conn delete baf0574f-34d5-30d4-8b65-a5bf1d06c85e
Review final definitions:
$ nmcli conn show
NAME UUID TYPE DEVICE
br0 f3e8eb0b-3b78-47ed-9797-153f19a05dc3 bridge br0
bridge-slave-enp1s0 8a69787b-5496-4771-8c14-e6a77c18b00c ethernet enp1s0
$ ip a
2: enp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
link/ether 30:bf:00:62:90:90 brd ff:ff:ff:ff:ff:ff
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether e2:e1:5a:bb:ee:71 brd ff:ff:ff:ff:ff:ff
inet 192.168.56.17/24 brd 192.168.56.255 scope global noprefixroute br0
valid_lft forever preferred_lft forever
- NOTE: Previously in Ubuntu versions, the
NetworkManager
GUI could be used to configure the bridge interface. However, as of Ubuntu 22.04, theNetworkManager
GUI becomes useless after this configuration. Do not use the GUI to manipulate any network configurations.
Place /etc/libvirt/qemu/networks/bridge-br0.xml
:
<network>
<name>bridge-br0</name>
<forward mode="bridge" />
<bridge name="br0" />
</network>
Then:
systemctl restart libvirtd
Done!