我有一个KVM服务器和两个虚拟机。 我有一个主IP和两个额外的“单”IP(而不是一个子网)。 我不希望在本地KVM上有专用地址的networking,但是我想从提供者(我买的)给虚拟机分配公有IP地址,我想pipe理这些IP在KVM主机上的路由,不在提供者一方(所以,不仅仅是从提供者桥接,而是从我的主机到虚拟机桥接)
我在互联网上find的所有教程都有点混乱,因为它们都是解决相同问题的不同方法(但对我来说还是不起作用)。
这会工作吗?
auto eth0 iface eth0 inet manual auto vmbr0 iface vmbr0 inet static address 176.xy133 (not 192.168.1.1) netmask 255.255.255.224 (not 255.255.255.0) gateway 176.xy129 (Provider's GW IP) bridge_ports eth0 bridge_stp off bridge_fd 0
您的设置实际上与公网IP没有任何关系 – 您的底层问题是您需要使用桥接networking而不是NAT或仅主机桥接。
把下面的东西放到/etc/network/interfaces :
iface eth0 inet manual iface br0 inet static bridge_ports eth0 bridge_stp no bridge_fd 0 bridge_maxwait 0 address 192.168.1.2 netmask 255.255.255.0 gateway 192.168.1.1 dns-nameservers 192.168.1.2 8.8.8.8 8.8.4.4 dns-search example.com
为您的特定设置重新configuration。
然后configuration您的虚拟机以桥接到br0 ,它的行为就像直接连接到进入eth0的电缆一样。
即你的访客虚拟机将如下所示:
<interface type='bridge'> <mac address='52:54:de:ad:be:ef'/> <source bridge='br0'/> <model type='virtio'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface>