libvirt 的 KVM/QEMU 网络 TAP 问题

发布于 2024-07-05 16:32:13 字数 1503 浏览 11 评论 0原文

我正在尝试将 libvirt 与 virsh 结合使用来管理我的 kvm/qemu 虚拟机。 我遇到的问题是让它与公共 IP 一起工作。 服务器运行的是ubuntu 8.04。

libvirt 不断尝试将其运行为:

/usr/bin/kvm -M pc -m 256 -smp 3 -monitor pty -no-acpi \ 
  -drive file=/opt/virtual-machines/calculon/root.qcow2,if=ide,boot=on \ 
  -net nic,vlan=0,model=virtio -net tap,fd=10,vlan=0 -usb -vnc 127.0.0.1:0

启动,但没有任何网络访问权限(ping 无处可去)。 在没有 fd=10 的情况下运行它可以使其正常工作,kvm 为我创建必要的 TAP 设备,并且网络在主机内部运行。 我见过的所有设置指南都集中在设置伪装上,而我只想要一个简单的桥接和未经过滤的网络访问(来宾和主机都必须使用公共 IP)。

在主机上运行 ifconfig 会给出此信息,桥接器是在我的 /etc/network/interfaces 文件中手动设置的。 :

br0   Link encap:Ethernet  HWaddr 00:1e:c9:3c:59:b8
      inet addr:12.34.56.78  Bcast:12.34.56.79  Mask:255.255.255.240
      inet6 addr: fe80::21e:c9ff:fe3c:59b8/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:3359 errors:0 dropped:0 overruns:0 frame:0
      TX packets:3025 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:180646 (176.4 KB)  TX bytes:230908 (225.4 KB)

eth0  Link encap:Ethernet  HWaddr 00:1e:c9:3c:59:b8
      inet6 addr: fe80::21e:c9ff:fe3c:59b8/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:6088386 errors:0 dropped:0 overruns:0 frame:0
      TX packets:3058 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:680236624 (648.7 MB)  TX bytes:261696 (255.5 KB)
      Interrupt:33

任何帮助将不胜感激。

I'm trying to use libvirt with virsh to manage my kvm/qemu vms. The problem I have is with getting it to work with public IPs. The server is running ubuntu 8.04.

libvirt keeps trying to run it as:

/usr/bin/kvm -M pc -m 256 -smp 3 -monitor pty -no-acpi \ 
  -drive file=/opt/virtual-machines/calculon/root.qcow2,if=ide,boot=on \ 
  -net nic,vlan=0,model=virtio -net tap,fd=10,vlan=0 -usb -vnc 127.0.0.1:0

Which boots, but does not have any network access (pings go nowhere). Running it without fd=10 makes it work right, with kvm creating the necessary TAP device for me and networking functioning inside the host. All the setup guides I've seen focus on setting up masquerading, while I just want a simple bridge and unfiltered access to the net (both the guests and host must use public IPs).

Running ifconfig on the host gives this, the bridge is manually setup in my /etc/network/interfaces file. :

br0   Link encap:Ethernet  HWaddr 00:1e:c9:3c:59:b8
      inet addr:12.34.56.78  Bcast:12.34.56.79  Mask:255.255.255.240
      inet6 addr: fe80::21e:c9ff:fe3c:59b8/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:3359 errors:0 dropped:0 overruns:0 frame:0
      TX packets:3025 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:180646 (176.4 KB)  TX bytes:230908 (225.4 KB)

eth0  Link encap:Ethernet  HWaddr 00:1e:c9:3c:59:b8
      inet6 addr: fe80::21e:c9ff:fe3c:59b8/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:6088386 errors:0 dropped:0 overruns:0 frame:0
      TX packets:3058 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:680236624 (648.7 MB)  TX bytes:261696 (255.5 KB)
      Interrupt:33

Any help would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雨轻弹 2024-07-12 16:32:13

我按照 https://help.ubuntu.com/community/KVM 上的桥接网络指南进行操作/etc/network/interfaces 中有以下内容:

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
        address 192.168.0.10
        network 192.168.0.0
        netmask 255.255.255.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        bridge_ports eth0
        bridge_fd 9
        bridge_hello 2
        bridge_maxage 12
        bridge_stp off

我没有更改任何 libvirt 网络设置,并且我的 kvm 映像的启动方式如下:

/usr/bin/kvm -M pc -no-kqemu -m 256 -smp 1 -monitor pty -boot c -hda \
    /libvirt/apt.img -net nic,macaddr=00:16:3e:77:32:1d,vlan=0 -net \
    tap,fd=11,script=,vlan=0 -usb -vnc 127.0.0.1:0

然后,我照常在 kvm 映像中指定静态网络设置。 自从我按照指南操作以来,一切正常。

我在 /etc/libvirt/qemu/ 的 xml 文件中确实有以下设置:

<interface type='bridge'>
  <mac address='00:16:3e:77:32:1d'/>
  <source bridge='br0'/>
</interface>

I followed the bridged networking guide at https://help.ubuntu.com/community/KVM and have the following in /etc/network/interfaces:

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
        address 192.168.0.10
        network 192.168.0.0
        netmask 255.255.255.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        bridge_ports eth0
        bridge_fd 9
        bridge_hello 2
        bridge_maxage 12
        bridge_stp off

I have not changed any libvirt network settings and my kvm images are booted like:

/usr/bin/kvm -M pc -no-kqemu -m 256 -smp 1 -monitor pty -boot c -hda \
    /libvirt/apt.img -net nic,macaddr=00:16:3e:77:32:1d,vlan=0 -net \
    tap,fd=11,script=,vlan=0 -usb -vnc 127.0.0.1:0

I then specify the static network settings in the kvm image as normal. Has all worked ok since I followed the guide.

I do have the following settings in my xml files in /etc/libvirt/qemu/ though under devices:

<interface type='bridge'>
  <mac address='00:16:3e:77:32:1d'/>
  <source bridge='br0'/>
</interface>
刘备忘录 2024-07-12 16:32:13

我想你的 Tap 设备应该显示在 ifconfig 中。

运行“brctl show”

它将显示桥接和隧道设备连接。

您可能必须将 iptable 条目显示为所有数据包都将通过网桥路由

iptables -I INPUT -i br0 -j ACCEPT

i guess your tap device should be shown in ifconfig.

run "brctl show "

it will show bridge and tunnel device connection.

you may have to put iptable entry show that all the packets will be routed through bridge

iptables -I INPUT -i br0 -j ACCEPT

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文