Playing VPS often uses port forwarding to achieve faster speeds. For example OVH computer room network My visit here is very slow, with Remote Desktop will vomit blood type. So they use other routes as a springboard, like Los Angeles, Hong Kong, and so on. Another example if you need a Japanese IP, but local access to Linode, Conoha Japan are detours, and slow, then if you use a Hong Kong VPS to do relays, you can achieve relatively stable and fast results.
Let's start by introducing a tutorial that uses Iptables to relay. The advantage of using iptables is that you can do it without extra load.
The source of this tutorial: http://aixiaoxiao.cn/thread-239-1-1.html I read the writing has been very detailed, and my own verification can be used, so directly reproduced. Save a few things.
* Special NOTE: The local server IP may not be public network IP, such as Aliyun is intranet IP, please use Ipconfig to confirm the flow of the network card IP is an extranet or intranet. First step: Turn on the system forwarding function
Will Net.ipv4.ip_forward=0
Modified into net.ipv4.ip_forward=1
Edit and use command to make configuration immediately effective
Step Two: Iptables's order
1 2 3 4 |
iptables-t nat-a prerouting-p TCP--Dport [port number]-J Dnat --to-destination [target IP] iptables-t nat-a prerouting-p UDP--Dport [port number]-J dnat--to-destination [Destination IP] Iptables-t nat-a postrouting-p tcp-d [Destination IP]--dport [port number]-J SNAT--to-source [local server IP] iptables-t na T-a postrouting-p udp-d [Destination IP]--dport [port number]-J SNAT--To-source |