linux – 适当的网络配置,使KVM来宾位于主机的同一网络上
发布时间:2020-12-13 17:01:53 所属栏目:Linux 来源:网络整理
导读:我在Lenny上运行Debian Linux服务器.在其中,我正在使用KVM运行另一个Lenny实例.两个服务器都是外部可用的,具有公共IP,以及第二个具有LAN专用IP的接口.一切正常,但VM将所有网络流量视为源自主机服务器.我怀疑这可能与我在主机上运行的基于iptables的防火墙有
我在Lenny上运行Debian
Linux服务器.在其中,我正在使用KVM运行另一个Lenny实例.两个服务器都是外部可用的,具有公共IP,以及第二个具有LAN专用IP的接口.一切正常,但VM将所有网络流量视为源自主机服务器.我怀疑这可能与我在主机上运行的基于iptables的防火墙有关.
我想弄清楚的是:如何正确配置主机的网络,以满足所有这些要求? >主机和VM都有2个网络接口(公共和私有). 目前,主机的网络接口配置为网桥. eth0和eth1没有分配IP地址,但br0和br1有. 主机上的/ etc / network / interfaces: # The primary network interface auto br1 iface br1 inet static address 24.123.138.34 netmask 255.255.255.248 network 24.123.138.32 broadcast 24.123.138.39 gateway 24.123.138.33 bridge_ports eth1 bridge_stp off auto br1:0 iface br1:0 inet static address 24.123.138.36 netmask 255.255.255.248 network 24.123.138.32 broadcast 24.123.138.39 # Internal network auto br0 iface br0 inet static address 192.168.1.1 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 bridge_ports eth0 bridge_stp off 这是VM的libvirt / qemu配置文件: <domain type='kvm'> <name>apps</name> <uuid>636b6620-0949-bc88-3197-37153b88772e</uuid> <memory>393216</memory> <currentMemory>393216</currentMemory> <vcpu>1</vcpu> <os> <type arch='i686' machine='pc'>hvm</type> <boot dev='hd'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='utc'/> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/bin/kvm</emulator> <disk type='file' device='cdrom'> <target dev='hdc' bus='ide'/> <readonly/> </disk> <disk type='file' device='disk'> <source file='/raid/kvm-images/apps.qcow2'/> <target dev='vda' bus='virtio'/> </disk> <interface type='bridge'> <mac address='54:52:00:27:5e:02'/> <source bridge='br0'/> <model type='virtio'/> </interface> <interface type='bridge'> <mac address='54:52:00:40:cc:7f'/> <source bridge='br1'/> <model type='virtio'/> </interface> <serial type='pty'> <target port='0'/> </serial> <console type='pty'> <target port='0'/> </console> <input type='mouse' bus='ps2'/> <graphics type='vnc' port='-1' autoport='yes' keymap='en-us'/> </devices> </domain> 除了我的其他防火墙规则外,防火墙脚本还包含此命令以传递发往KVM来宾的数据包: # Allow bridged packets to pass (for KVM guests). iptables -A FORWARD -m physdev --physdev-is-bridged -j ACCEPT (不适用于这个问题,但我的桥接配置的副作用似乎是我不能干净地关闭.内核最终告诉我“unregister_netdevice:等待br1变得自由”而且我必须硬复位系统.也许是一个我做过蠢事的标志?) 解决方法
您将VM桥接到错误的接口.它们应桥接到连接到外部世界的网络接口(在您的情况下为br1).
请记住,每个VM还应在guest虚拟机中设置其IP地址,而不是在主机上设置. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |