Linux 端口转发一则

目前已知的,公司的网络只有 80、8008(后来又给关了 - -)、443 端口的 TCP 可以出去,其它已知的所有端口都被封锁。所以,我的学上科网工具就歇菜了。

最后尝试,通过配置端口转发,将ss主机的端口9999,映射到 443 。这样,本地客户端连接到 443,就相当于连接了 9999 端口,翻墙服务器就可以用了。

iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 9999

可以使用下面一句将这个配置保存下来:

service iptables save

但是目前先不保存,这个方案暂时用一下。毕竟 443 可能还会被用来做 https 的。

查看上面的转发规则是否存在,可以用:

iptables -t nat -L

====================

保存 iptables 可能提示没有这个 service,是因为需要安装 iptables 的辅助工具:

ununtu: apt install iptables-persistent
centos: yum install iptables-services
原文地址:https://www.cnblogs.com/pied/p/9173950.html