0

I have just followed the steps in the answer of the following:

Does Virt-Manager GUI have a easy way to configure networking passthrough/bridge?

and everything seems to work. But the virtual machine is not getting an IP address from DHCP server.

I am using the last distribution of Manjaro Linux (20.2.1).

I like Manjaro it is fast, simple and effective. I am using on x86_64, arm and arm64 architectures.

The following is my configuration, the physical nic is enp0s31f6 and the master bridge is br0:

marco@wks ~]$ ip a l
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 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
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP group default qlen 1000
    link/ether 4c:ed:fb:cc:08:3d brd ff:ff:ff:ff:ff:ff
4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:6c:06:9b:b6 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:6cff:fe06:9bb6/64 scope link 
       valid_lft forever preferred_lft forever
6: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 52:54:00:60:81:e4 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
       valid_lft forever preferred_lft forever
7: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:60:81:e4 brd ff:ff:ff:ff:ff:ff
8: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 52:f3:20:28:27:65 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.111/24 brd 192.168.1.255 scope global noprefixroute br0
       valid_lft forever preferred_lft forever
10: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master virbr0 state UNKNOWN group default qlen 1000
    link/ether fe:54:00:ec:3c:d9 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc54:ff:feec:3cd9/64 scope link 
       valid_lft forever preferred_lft forever
52: veth5807e61@if51: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP group default 
    link/ether ce:3f:52:3e:e4:2e brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::cc3f:52ff:fe3e:e42e/64 scope link 
       valid_lft forever preferred_lft forever
[marco@wks ~]$ ip link
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: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master br0 state UP mode DEFAULT group default qlen 1000
    link/ether 4c:ed:fb:cc:08:3d brd ff:ff:ff:ff:ff:ff
4: docker0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default 
    link/ether 02:42:6c:06:9b:b6 brd ff:ff:ff:ff:ff:ff
6: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:60:81:e4 brd ff:ff:ff:ff:ff:ff
7: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN mode DEFAULT group default qlen 1000
    link/ether 52:54:00:60:81:e4 brd ff:ff:ff:ff:ff:ff
8: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 52:f3:20:28:27:65 brd ff:ff:ff:ff:ff:ff
10: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel master virbr0 state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether fe:54:00:ec:3c:d9 brd ff:ff:ff:ff:ff:ff
52: veth5807e61@if51: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master docker0 state UP mode DEFAULT group default 
    link/ether ce:3f:52:3e:e4:2e brd ff:ff:ff:ff:ff:ff link-netnsid 0
[marco@wks ~]$ bridge link
2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 100 
7: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 master virbr0 state disabled priority 32 cost 100 
10: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master virbr0 state forwarding priority 32 cost 100 
52: veth5807e61@if51: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master docker0 state forwarding priority 32 cost 2
[marco@wks ~]$ ip route
default via 192.168.1.1 dev br0 proto static metric 20425 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
192.168.1.0/24 dev br0 proto kernel scope link src 192.168.1.111 metric 425 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
[marco@wks ~]$ sudo virsh net-list --all
[sudo] password for marco: 
 Name      State    Autostart   Persistent
--------------------------------------------
 br0       active   yes         yes
 default   active   yes         yes
[marco@wks ~]$ sudo virsh net-dumpxml br0
<network>
  <name>br0</name>
  <uuid>b3875e6c-2858-4e0a-be9a-f98e83cc5b70</uuid>
  <forward mode='bridge'/>
  <bridge name='br0'/>
</network>

physical network address is 192.168.1.0/24.

How can troubleshoot this?

EDIT1

[marco@wks tianshou]$ sudo virsh domiflist jobs2021
 Interface   Type     Source   Model    MAC
-----------------------------------------------------------
 -           bridge   br0      virtio   52:54:00:48:89:a9

Is any step missing in the configuration?

  • Normally, `libvirt`-managed VMs are connected via an interface named vnet#, where # is a number. You have a NIC named `vnet0` connected to `virbr0`, the bridge `libvirt` normally uses to implement NAT networks. Therefore, your VM probably gets an IP address from `libvirt`'s DHCP server in the 192.168.122.0/24 range. To get the IP address from a network external to `libvirt`, connect the VM to `br0` instead of `virbr0`. You can get more insight with `virsh domiflist VM` where VM is the name or number of the virtual machine. – berndbausch Feb 11 '21 at 03:10
  • Ok @berndbausch, but my VM is connected to br0 and it does not get a network address. That's my issue. – learning-man Feb 11 '21 at 08:24
  • Can you post the output of `virsh domiflist VM`? I see only one `vnet` interface named `vnet0`, and it is plugged into `virbr0`. – berndbausch Feb 11 '21 at 09:26
  • just posted at the end @berndbausch, honestly 2 months back I was using centos8 and it was much easier to setup. What is the best distribution for KVM ? I need to combine KVM and NVIDIA and I am thinking to POP!_OS, what do you think? – learning-man Feb 11 '21 at 21:11
  • Please check this Q/A on SF (where I made an answer) in case it's relevant: https://serverfault.com/questions/963759/docker-breaks-libvirt-bridge-network/ (Docker breaks libvirt bridge network) – A.B Feb 11 '21 at 21:20
  • Or a similar one (where I also answered) here on UL: https://unix.stackexchange.com/questions/572022/linux-bridge-for-virtual-machines-not-forwarding-ip-packets-but-is-forwarding-a – A.B Feb 11 '21 at 21:27

1 Answers1

0

Today I have some time to solve this issue. If you consider the following network 172.18.0.0/24, the following commands solved my issue:

iptables -t nat -A POSTROUTING -s 172.18.0.0/24 -d 172.18.0.0/24 -j ACCEPT
iptables -A FORWARD -i br0 -o br0 -j ACCEPT

Thanks everybody.