问题:
使用 CentOS 6.10 构建的主机和虚拟机。
ExternalMachine⇔VM 使用 Host iptables 的 nat 功能进行路由。
作为一个问题,iptables has started("service iptables status") 在重新启动主机或打开电源后,
但是我们无法路由到已经自动启动的VM。
出现这种现象后,重启 iptables("service iptables restart") 会通过所有路由。
iptables 和 VM 都在运行,并且 iptables 设置符合预期。
我不知道为什么它不能路由到虚拟机。
如果你能教我什么是问题,我将不胜感激。
---------AutostartSetting/StopSetting------------
# vi /etc/sysconfig/libvirt-guests
START_DELAY=30
ON_SHUTDOWN=shutdown
SHUTDOWN_TIMEOUT=180
# virsh autostart <VM NAME>
-----操作系统-------
cat /etc/redhat-release
CentOS release 6.10 (Final)
----kvm----
qemu-kvm-0.12.1.2-2.506.el6_10.5.x86_64
附加信息:
---------------
#virsh net-edit default
<network>
<name>default</name>
<uuid>1d4f2476-0da2-45d5-b97f-xxxxxxxxxxx</uuid>
<forward mode='nat'/>
<bridge name='virbr0' stp='off' delay='0' />
<mac address='XX:XX:XX:XX:XX:XX'/>
<ip address='1.2.3.4' netmask='255.255.255.0'>
</ip>
</network>
-----------------
确认后,Host daemon 的启动顺序如下。
1.iptables
2.网络
3.qemu-ga
4.libvirtd
5.libvirt-guest
libvirt 依赖于网络,网络依赖于 iptables
chkconfig 的顺序无法更改。
在这种情况下,我应该在 chkconfig 结束时运行 iptables 重启脚本,还是让 anacron 重启 iptables?或者你有没有其他方法来归档它?
最佳答案
libvirt/qemu 网络是如何配置的?如果是 tap 网络(或 macvtap,与此相同),则实际的 tap 设备(来自 ip addr
输出)仅在 VM 暂停或运行时存在。并且 iptables 规则使用接口(interface),因此如果在 iptables(重新)启动时该接口(interface)不存在,则需要在创建 VM 时重新添加规则。简单的 iptables 重启也可以。
关于centos - 在 KVM 主机上使用 iptables 设置 nat 时,无法路由到设置为在主机启动时自动启动的 VM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59404813/