为什么虚拟机无法获得我从提供商那里获得的公共IP?

我有一个KVM主机(在Debian上)

root@kvm-host:/# cat /etc/network/interfaces auto eth0 iface eth0 inet manual auto vmbr0 iface vmbr0 inet static address 176.xy133 netmask 255.255.255.224 gateway 176.xy129 # Provider's GW IP bridge_ports eth0 bridge_stp off bridge_fd 0 root@kvm-host:/# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 176.xy128 0.0.0.0 255.255.255.224 U 0 0 0 vmbr0 0.0.0.0 176.xy129 0.0.0.0 UG 0 0 0 vmbr0 root@kvm-host:/# arp -an ? (176.xy155) at <incomplete> on vmbr0 ? (176.xy129) at xx:yy:zz:11:22:33 [ether] on vmbr0 root@kvm-host:/# ifconfig 1: lo: ... 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether AA:BB:CC:DD:EE:FF brd ff:ff:ff:ff:ff:ff inet6 fe80::a60:6eff:feDD:EEFF/64 scope link valid_lft forever preferred_lft forever 3: vmbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN link/ether AA:BB:CC:DD:EE:FF brd ff:ff:ff:ff:ff:ff inet 176.xy133/27 brd 176.xy159 scope global vmbr0 inet6 fe80::a60:6eff:feDD:EEFF/64 scope link valid_lft forever preferred_lft forever 4: venet0: <BROADCAST,POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN link/void inet6 fe80::1/128 scope link valid_lft forever preferred_lft forever 

我有公共IP:176.xy133(KVM-Host),176.xy151,176.xy155。

现在我试图在每个虚拟机上获取networking:

 user@VM:/$ cat /etc/network/interfaces auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 176.xy155 netmask 255.255.255.255 pointtopoint 176.xy133 gateway 176.xy133 

我卸载了networkingpipe理器。

下一步:

 user@VM:/$ sudo ifup eth0 RTNETLINK answers: File exists Failed to bring up eth0 user@VM:/$ ping 176.xy133 connect: Network is unreachable root@VM:/# route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 

(即空,甚至没有默认网关

 user@VM:/$ sudo add default via 176.xy133 RTNETLINK answers: no such process user@VM:/$ sudo arp -a (ie empty) user@VM:/$ sudo arp -s 176.xy133 AA:BB:CC:DD:EE:FF SIOCSARP Network is unreachable 

我甚至不能设置静态路由(MAC-addr./IP-addr。)。

在VM上设置networking有什么问题? (我希望我提供了所有必要的信息,具体)

检查MAC地址是不是随机生成的; 许多ISP只会将IP分配给有效提供商发布的MAC地址。 我可以通过一台已知好的机器在机器上获得IP,将最后一个八位字节加1。

编辑:确保“brctl show vmbr0”显示合理的东西。 就像是

 xen-br0 8000.90b11c316da4 no eth0 

在硬件节点(主机)上, /etc/network/interface可能如下所示:

 # This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # Which interface are to be started at boot auto lo vmbr0 # The loopback network interface iface lo inet loopback # The bridge for VM iface vmbr0 inet static address 176.xy133 netmask 255.255.255.224 network 176.xy128 broadcast 176.xy159 gateway 176.xy129 # Provider's GW IP bridge_ports eth0 bridge_maxwait 2 up /sbin/ifconfig eth0 inet 0.0.0.0 promisc up /sbin/sysctl -w net.ipv4.conf.br0.proxy_arp=1 up /sbin/sysctl -w net.ipv4.conf.default.forwarding=1 up /sbin/sysctl -w net.ipv4.ip_forward=1 

当然,您可能更喜欢在/etc/sysctl.d/创build一个vm-routing文件来存储sysctlconfiguration。

VM主机上 ,您必须能够使用相同的networkingconfiguration:

 iface eth0 inet static address 176.xy155 netmask 255.255.255.224 network 176.xy128 broadcast 176.xy159 gateway 176.xy129 # Provider's GW IP