On Fri, Aug 2, 2024 at 11:44 AM Germano Massullo
<germano.massullo(a)gmail.com> wrote:
I am running a libvirt hostmachine (Fedora 40) which has 192.168.1.6 IP
address, assigned by router's DHCP server.
I want the libvirt VMs IPs to be assigned by router's DHCP server, so I
tried to setup a bridge via
# virsh net-define foo.xml
and trying the following files as xml file, but they all failed to
achieve the task. Here I list the two XML variants I tried to use
1)
<network>
<name>bridge-no-nat</name>
<bridge name='virbr1_no-nat' stp='on' delay='0'/>
<forward mode='open'/>
</network>
RETURNS:
open forwarding requested, but no IP address provided for network
'bridge-no-nat'
2)
I created in nmtui the bridge virbr1_no_nat then I used following XML
for virsh net-define
<network>
<name>br1_no_nat</name>
<forward mode='bridge'/>
<bridge name='virbr1_no_nat'/>
<virtualport type='openvswitch'/>
<portgroup name='default'/>
</network>
then I configure the VM network to use but when I start the VM I get error:
internal error: Unable to add port vnet1 to OVS bridge virbr1_no_nat: <null>
Do you know how I can solve this?
Here are the rough steps I perform to bridge VMs to my home network so
the VMs receive a DHCP address from my DHCP server. It also allows you
to SSH into your VMs like any other host on your network. The steps
are for a modern install on Fedora with Systemd and Network Manager
(and not systemd-network).
1. Ignore anything from `sudo -E virsh net-edit default`. You don't
use the default NAT. You use virbr0 instead.
2. Install nmtui.
3. `sudo nmtui`, then 'Edit a connection." Select bridge virbr0.
* Under slaves, add Ethernet Connection 1. Check Automatically
Connect and Available to All Users.
* Under IPv4, select Automatic. Remove addresses and friends.
* Under IPv6, select Disabled. I don't run IPv6 internally.
4. Reboot the machine.
5. After reboot and login, you should see ethernet UP, vbridge UP, and
the host has a DHCP address via the bridge.
$ ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s20f0u3c2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel mast
er virbr0 state UP mode DEFAULT group default qlen 1000
link/ether 20:7b:d2:8c:55:d4 brd ff:ff:ff:ff:ff:ff
3: wlo1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN m
ode DORMANT group default qlen 1000
link/ether 9a:28:0e:bd:f4:ee brd ff:ff:ff:ff:ff:ff permaddr 00:41:0e:67:0e:7
b
altname wlp87s0
4: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mod
e DEFAULT group default qlen 1000
link/ether 20:7b:d2:8c:55:d4 brd ff:ff:ff:ff:ff:ff
And:
$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group defaul
t qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: enp0s20f0u3c2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel mast
er virbr0 state UP group default qlen 1000
link/ether 20:7b:d2:8c:55:d4 brd ff:ff:ff:ff:ff:ff
3: wlo1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN g
roup default qlen 1000
link/ether 9e:8e:8a:6f:35:5e brd ff:ff:ff:ff:ff:ff permaddr 00:41:0e:67:0e:7
b
altname wlp87s0
4: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP gro
up default qlen 1000
link/ether 20:7b:d2:8c:55:d4 brd ff:ff:ff:ff:ff:ff
inet 172.16.2.15/12 brd 172.31.255.255 scope global dynamic noprefixroute vi
rbr0
valid_lft 6293sec preferred_lft 6293sec
6. In Virtual Machine Manager, select a VM, select NIC, choose Bridge
device... and select virbr0.
7. Start the VM. The VM will get an IP address from your local DHCP server.
You might find these commands useful if you don't (yet) have a bridge:
<
https://wiki.archlinux.org/title/Network_bridge> and maybe this
discussion: <
https://bbs.archlinux.org/viewtopic.php?id=253232>.
Jeff