Using Iptables for Port forwarding

Source: Internet
Author: User
Tags vps iptables

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

1 Vi/etc/sysctl. conf

Will Net.ipv4.ip_forward=0
Modified into net.ipv4.ip_forward=1

Edit and use command to make configuration immediately effective

1 Sysctl-p

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.