问题:
主机和使用CentOS 6.10构建的虚拟机。外部机器⇔VM使用主机iptables的nat功能进行路由。作为一个问题,iptables在重启主机或打开电源后已经启动(“service iptables status"),但我们无法路由到已自动启动的VM。在此现象之后,重启iptables (“服务iptables重启”)将通过所有路由。
iptables和VM都在运行,并且iptables设置与预期一致。
我不知道为什么不能路由到VM。如果你能告诉我问题出在哪里,我将不胜感激。
-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>
-----------------确认后,主机守护程序的启动顺序如下所示。
1.iptables 2.network 3.qemu-ga 4.libvirtd 5.libvirt-guest
libvirt依赖于网络,而网络依赖于iptables,chkconfig的顺序无法更改。在这种情况下,我应该让iptables重启脚本在chkconfig的末尾运行,还是让anacron重启iptables?或者,你有没有其他的方法来相信它?
发布于 2019-12-19 17:24:05
libvirt/qemu网络是如何配置的?如果是tap网络(或macvtap,与此相同),则实际的tap设备(来自ip addr输出)仅在VM暂停或运行时存在。而且iptables规则使用接口,因此如果iptables (Re)启动时接口不存在,那么在创建VM时需要重新添加规则。简单的iptables重新启动也可以。
https://stackoverflow.com/questions/59404813
复制相似问题