我正在 Centos 6 专用服务器上设置 KVM 主机。我已成功构建并运行 VPS/客户机,但它们没有连接。客户机上的 IP 已提升,它们正在 KVM (br0) 上使用我的桥接器,但 IP 未被 ping 通,它们无法从外部 ping 通。KVM 和客户机能够相互 ping 通,但客户机无法连接到 KVM 外部。100% 数据包丢失。KVM 能够建立和接收外部连接。
用于创建客户的命令是:
virt-install --name=vps2 --disk path=/var/lib/libvirt/images/vps2.img,size=8 --ram=512 --os-type=linux --network bridge:br0 --nographics --extra-args='console=tty0 console=ttyS0,115200n8 serial' --location '/tmp/CentOS-6.9-x86_64-minimal.iso' --boot cdrom
以下是我的 KVM 主机的网络设置:
/etc/sysconfig.network
NETWORKING=yes
HOSTNAME=****
NOZEROCONF=yes
GATEWAY="91.***.***.254"
virsh 网络表
Name State Autostart Persistent
--------------------------------------------------
default active yes yes
是否配置
ifconfig
br0 Link encap:Ethernet HWaddr D0:***:***:7C
inet addr:91.***.***.216 Bcast:91.***.***.255 Mask:255.255.254.0
inet6 addr: fe80::d267:***:***:47c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2342975 errors:0 dropped:0 overruns:0 frame:0
TX packets:18077 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:112401012 (107.1 MiB) TX bytes:3782581 (3.6 MiB)
eth0 Link encap:Ethernet HWaddr D0:***:***:7C
inet6 addr: fe80::d267:***:***:47c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:214922 errors:0 dropped:0 overruns:0 frame:0
TX packets:6170 errors:7 dropped:0 overruns:0 carrier:7
collisions:28 txqueuelen:1000
RX bytes:14366872 (13.7 MiB) TX bytes:1286723 (1.2 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:672 (672.0 b) TX bytes:672 (672.0 b)
virbr0 Link encap:Ethernet HWaddr 52:***:***:5E
inet addr:192.***.***.1 Bcast:192.***.***.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
vnet0 Link encap:Ethernet HWaddr FE:***:***:E7
inet6 addr: fe80::fc54:***:***:96e7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:135 errors:0 dropped:0 overruns:0 frame:0
TX packets:137374 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:6725 (6.5 KiB) TX bytes:8448525 (8.0 MiB)
vnet1 Link encap:Ethernet HWaddr FE:***:***:66
inet6 addr: fe80::fc54:***:***:6666/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:786 errors:0 dropped:0 overruns:0 frame:0
TX packets:2103722 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:33539 (32.7 KiB) TX bytes:129504050 (123.5 MiB)
vnet2 Link encap:Ethernet HWaddr FE:***:***:66
inet6 addr: fe80::fc54:***:***:6666/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:35627 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 b) TX bytes:1852760 (1.7 MiB)
eth0
DEVICE="eth0"
HOSTNAME=****
HWADDR="D0:***:***:7C"
NM_CONTROLLED="no"
ONBOOT="yes"
TYPE="Ethernet"
UUID="19***:***d3"
BRIDGE=br0
br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO="static"
DNS1="8.8.8.8"
DNS2="8.8.4.4"
GATEWAY="91.***.***.254"
HWADDR="D0:***:***:7C"
IPADDR="91.***.***.216"
NETMASK="255.255.254.0"
ONBOOT="yes"
NM_CONTROLLED="no"
路线-n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.***.***.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
91.***.***.0 0.0.0.0 255.255.254.0 U 0 0 0 br0
0.0.0.0 91.***.***.254 0.0.0.0 UG 0 0 0 br0
brctl 显示
bridge name bridge id STP enabled interfaces
br0 8000.d067e5e7047c no eth0
vnet0
vnet1
virbr0 8000.52540098305e yes virbr0-nic
vnet2
VPS / 访客
是否配置
eth0 Link encap:Ethernet HWaddr 52:***.***:E7
inet addr:91.***.***.217 Bcast:91.***.***.255 Mask:255.255.254.0
inet6 addr: fe80::***.***:96e7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3372 errors:0 dropped:0 overruns:0 frame:0
TX packets:26 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:160593 (156.8 KiB) TX bytes:1440 (1.4 KiB)
Interrupt:11 Base address:0x4000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
ip 地址显示
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:***.***:e7 brd ff:ff:ff:ff:ff:ff
inet 91.***.***.217/23 brd 91.***.***.255 scope global eth0
inet6 fe80::***.***:96e7/64 scope link
valid_lft forever preferred_lft forever
我尝试通过主机中的 default.xml 添加 IP:
/etc/libvirt/qemu/networks/default.xml
<network>
<name>default</name>
<uuid>e0***:***45</uuid>
<forward mode='nat'/>
<bridge name='virbr0' stp='on' delay='0' />
<mac address='52:***:***:5E'/>
<ip address='192.***.***.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.***.***.2' end='192.***.***.254' />
<host mac='52:***:***:e7' name='vps1' ip='91.***.***.217' />
<host mac='52:***:***:bc' name='vps2' ip='91.***.***.219' />
</dhcp>
</ip>
</network>
我在 IP 表中创建了各种规则以允许 2 个服务器之间的通信,但无济于事。我已禁用 SElinux 和 iptables,但仍然无法连接。
我的客户端上的 IP 似乎已提升,它正在使用桥接,它正在使用 Google 的名称服务器,但没有连接,我无法 ping 客户端 IP。我的想法是 KVM 不允许客户端与外界之间的桥接流量,但即使禁用了 IP 表,仍然没有任何反应。
您认为这可能与桥接器和客户机之间的故障有关吗?如果您需要更多信息,请告诉我。谢谢。
答案1
已解决。我必须在客户机内的 eth0 配置中将“广播”行替换为“网关”,现在才有外部连接。
DEVICE=eth0
HWADDR=52:**:A0
TYPE=Ethernet
UUID=B***9
ONBOOT=yes
BOOTPROTO=static
IPADDR=91.***.***.217
GATEWAY=91.***.***.254
NETMASK=255.255.254.0