Manjaro 中的 KVM 和桥接网卡无法从 OpenWRT 路由器和 DHCP 服务器获取 IP

Manjaro 中的 KVM 和桥接网卡无法从 OpenWRT 路由器和 DHCP 服务器获取 IP

我刚刚按照以下答案中的步骤进行操作:

Virt-Manager GUI 是否有一种简单的方法来配置网络直通/桥接?

一切似乎都很顺利。但虚拟机未从 DHCP 服务器获取 IP 地址。

我使用的是 Manjaro Linux 的最新发行版 (20.2.1)。

我喜欢 Manjaro,它快速、简单且有效。我在 x86_64、arm 和 arm64 架构上使用。

以下是我的配置,物理网卡是enp0s31f6,主桥是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>

物理网络地址是192.168.1.0/24。

如何解决这个问题?

编辑1

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

配置中是否缺少任何步骤?

答案1

今天我有一些时间来解决这个问题。如果您考虑以下网络 172.18.0.0/24,则以下命令解决了我的问题:

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

谢谢大家。

相关内容