我有一个hetzner专用主机。 另外我买了一个6IP子网。
我的主要IP是:148.111.111.200我的主要子网是:255.255.255.224
我的额外IP是148.222.222.1到148.222.222.6。
我的使用场景如下:几个实例将面向公共IP(networking服务器等)所有的实例将有一个内部局域网的第二个nic安装,所以我可以在外面的专用networking上lockingmysql服务器,memcached等。
networking服务器将在148.222.222.1联机,并将有第二个网卡与IP 10.10.10.10
目前,我已经安装了内部局域网。 所有的实例都可以通过内部IP(10.10.10.X)相互连接和ping,但是我的networking服务器无法连接到互联网。
我不能使用桥接模式,因为hetzner不允许多个MAC在同一个外部IP,所以我不得不使用路由模式。 这是我的/ etc / network / interfaces文件的主机:
# network interface settings auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 148.111.111.200 netmask 255.255.255.255 pointopoint 148.111.111.193 gateway 148.111.111.193 broadcast 148.111.111.223 post-up echo 1 > /proc/sys/net/ipv4/conf/eth0/proxy_arp #commentedout #up route add -net 148.111.111.192 netmask 255.255.255.224 gw 148.111.111.193 eth0 # default route to access subnet auto vmbr0 iface vmbr0 inet static address 148.111.111.200 netmask 255.255.255.255 bridge_ports none bridge_stp off bridge_fd 0 up ip route add 148.222.222.1/32 dev vmbr0 up ip route add 148.222.222.2/32 dev vmbr0 auto vmbr1 iface vmbr1 inet static address 10.10.10.1 netmask 255.255.255.0 bridge_ports none bridge_stp off bridge_fd 0 post-up echo 1 > /proc/sys/net/ipv4/ip_forward post-up iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o eth0 -j MASQUERADE post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o eth0 -j MASQUERADE auto vmbr2 iface vmbr2 inet static address 148.222.222.1 netmask 255.255.255.248 bridge_ports none bridge_stp off bridge_fd 0
这里是我的kvm interfaces文件:
auto eth0 iface eth0 inet static address 148.222.222.1 netmask 255.255.255.255 pointopoint 148.111.111.200 gateway 148.111.111.200 dns-nameservers 8.8.8.8 8.8.4.4 auto eth1 address 10.10.10.12 netmask 255.255.255.0 network 10.10.10.0 broadcast 10.10.10.255
目前,KVM实例可以ping另一个,但没有其他的作品主机可以ping实例,但没有别的而我无法访问我的实例上网。
我需要在我的configuration中更改什么才能使其工作。
PS网卡types在proxmox中设置为virtio
我通过使用以下configuration解决了问题:
auto eth0 iface eth0 inet static address 148.111.111.200 netmask 255.255.255.255 pointopoint 148.111.111.193 gateway 148.111.111.193 broadcast 148.111.111.193 # default route to access subnet auto vmbr0 iface vmbr0 inet static address 148.111.111.200 netmask 255.255.255.255 bridge_ports none bridge_stp off bridge_fd 0 bridge_maxwait 0 #subnet up ip route add 148.222.222.0/32 dev vmbr0 up ip route add 148.222.222.1/32 dev vmbr0 up ip route add 148.222.222.2/32 dev vmbr0 up ip route add 148.222.222.3/32 dev vmbr0 up ip route add 148.222.222.4/32 dev vmbr0 up ip route add 148.222.222.5/32 dev vmbr0 up ip route add 148.222.222.6/32 dev vmbr0 up ip route add 148.222.222.7/32 dev vmbr0 auto vmbr1 iface vmbr1 inet static address 10.10.10.1 netmask 255.255.255.0 bridge_ports none bridge_stp off bridge_fd 0 post-up echo 1 > /proc/sys/net/ipv4/ip_forward post-up iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o eth0 -j MASQUERADE post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o eth0 -j MASQUERADE
在您的客户端机器上,您需要定义一个或两个networking接口
ubuntu / etc / network / interfaces的configuration示例
#vmbr0 auto eth0 iface eth0 inet static address 148.222.222.1 netmask 255.255.255.255 pointopoint 148.111.111.200 gateway 148.111.111.200 #public IP for the proxmox node dns-nameservers 8.8.8.8 8.8.4.4 #vmbr1 auto eth1 iface eth1 inet static address 10.10.10.20 netmask 255.255.255.0 network 10.10.10.0 broadcast 10.10.10.255
看看你的vmbr0configuration,看起来好像你正在把路由指向接口无法到达的设备(即,到networking掩码放在接口networking范围之外的设备)。
如果不深入你的configuration,我会提出以下build议来简化你现在和未来的设置:
Create a VM that will act as your UTM (也许运行pfsense,vyatta,astaro,zentyal,clearos,解开等)。 这将确保您只担心在连接网关(和冗余网关)angular色的一个或两个节点上连接。 那么所有的路由和访问逻辑将在这个UTM虚拟机中发生。 我亲自用pfsense和zentyal成功完成了这个任务 Proxmox VE 3.2 now works with openvswitch ,尝试并部署在上面。 这将使您轻松pipe理您的networking堆栈,而不必深入研究ebtables和iptables规则的内部。 此外,您正在eth {0,1}接口和它们之上的网桥上configurationnetworking。 我通常会build议从eth {0,1}接口取下configuration并仅在网桥接口上configurationnetworking。
以下是如何将接口configuration细节从主机接走,同时也将networking之间的路由控制权交给UTM VM ..:
auto eth0 iface eth0 inet manual auto eth1 iface eth1 inet manual auto vmbr0 iface vmbr0 inet manual bridge_ports eth0 bridge_stp off bridge_fd 0 auto vmbr1 iface vmbr1 inet manual bridge_ports eth0 bridge_stp off bridge_fd 0 auto vmbr2 iface vmbr2 inet static address 10.10.10.12 netmask 255.255.255.0 gateway 10.10.10.1 bridge_ports eth1 bridge_stp off bridge_fd 0
显然,如果连接到主机是一个问题,你将不得不修改vmbr0或vmbr1,并为主机添加一个IP。基本的想法是不负担主机与虚拟机之间的networking路由,并有一个专用虚拟机负责照顾那些细节
通过这种设置,您的UTM虚拟机变得function强大,您甚至可以将主机转发路由到外部可访问的IP地址。 在这种情况下,我build议在群集中运行proxmox(甚至只是双节点群集),并为UTM VM启用HA。
你也需要在顶部
汽车
iface lo inet loopback
auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 148.111.111.200 netmask 255.255.255.255 pointopoint 148.111.111.193 gateway 148.111.111.193 broadcast 148.111.111.193 # default route to access subnet auto vmbr0 iface vmbr0 inet static address 148.111.111.200 netmask 255.255.255.255 bridge_ports none bridge_stp off bridge_fd 0 bridge_maxwait 0 #subnet up ip route add 148.222.222.0/32 dev vmbr0 up ip route add 148.222.222.1/32 dev vmbr0 up ip route add 148.222.222.2/32 dev vmbr0 up ip route add 148.222.222.3/32 dev vmbr0 up ip route add 148.222.222.4/32 dev vmbr0 up ip route add 148.222.222.5/32 dev vmbr0 up ip route add 148.222.222.6/32 dev vmbr0 up ip route add 148.222.222.7/32 dev vmbr0 auto vmbr1 iface vmbr1 inet static address 10.10.10.1 netmask 255.255.255.0 bridge_ports none bridge_stp off bridge_fd 0 post-up echo 1 > /proc/sys/net/ipv4/ip_forward post-up iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o eth0 -j MASQUERADE post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o eth0 -j MASQUERADE