iptables nat共享上网

Posted XY

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iptables nat共享上网相关的知识,希望对你有一定的参考价值。

1.阿里云无外网ECS通过有公网IP代理上网

[[email protected] ~]# echo 1 >/proc/sys/net/ipv4/ip_forward     # 开启转发
[[email protected] ~]# iptables -t nat -A PREROUTING -p tcp --dport 2222 -j DNAT --to-destination 10.132.35.1:22  # 本机公网IP端口2222,转发到10.132.35.1的22号端口上
[[email protected] ~]# iptables -t nat -A POSTROUTING -d 10.132.35.1 -p tcp --dport 22 -j MASQUERADE              # 内网10.132.32.1端口22转发出去,回源

 

以上是关于iptables nat共享上网的主要内容,如果未能解决你的问题,请参考以下文章

iptables在我们的网络机房实现NAT共享上网

iptables防火墙nat表实现共享上网规则策略实战

用iptables做软路由实现共享上网

防火墙iptables

通过iptables实现共享上网及端口代理转发

iptables典型NAT上网