KVM 端口转发

iptables_port_forwarding

该功能需要guest使用default的NAT网络,guest可以上网.
如果在外网IP缺乏的情况下,想外网与guest连接,就需要通过iptables来做端口转发.

iptables -t nat -A PREROUTING -d $wan_ip -p tcp -m tcp --dport $wan_port -j DNAT --to-destination 192.168.122.10:3389
iptables -I FORWARD -d 192.168.122.0/24 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT

-A PREROUTING -d 115.238.185.227/32 -p tcp -m tcp –dport 2224 -j DNAT –to-destination 192.168.122.2:22 -A POSTROUTING -s 192.168.122.0/24 ! -d 192.168.122.0/24 -j MASQUERADE

  • virtualization/kvm/kvm_port_forwarding.txt
  • 最后更改: 2019/04/16 18:31
  • (外部编辑)