添加NAT网桥 只有一个公网IP,想要虚拟机上网,就只能使用NAT模式.没有使用WEB UI上的方案,直接编辑/etc/network/interface文件
1 2 3 4 5 6 7 8 9 10 11 12 |
auto vmbr0 iface vmbr0 inet static address 192.168.100.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 echo 1 > /proc/sys/net/ipv4/conf/vmbr0/proxy_arp post-up iptables -t nat -A POSTROUTING -s '192.168.100.0/24' -o enp2s0 -j MASQUERADE post-down iptables -t nat -D POSTROUTING -s '192.168.100.0/24' -o enp2s0 -j MASQUERADE |
注:enp2s0为有公网IP的网卡 编辑完成后运行service networking restart生效 安装D……