how to transmit traffic from a linux vpn server to

2019-09-23 13:38发布

问题:

I have established a vpn server in area b,and I can get internet from my pc on area a through this vpn server.But some services are access more convenient through area c,I want to get this services more faster,So I want to transmit all the vpn traffic from my vpn server to another linux server.Is there some awesome solution for this issue? I have googled some solutions about that,e.g. the iptables、the haproxy..but I have tried failed.could someone give me the iptables commands for this?

回答1:

First you have to run the following command to allow forwarding: sysctl net.ipv4.conf.eth0.forwarding=1 Then you have to specify the nat configuration and which ports you want to forward:

iptables -t nat -A PREROUTING -p tcp -i **Public network interface** --dport **Desired port you want to use on vpn server** -j DNAT --to-destination **IP of area C**:**Desired port you want to use on area C**

iptables -A FORWARD -p tcp -d **IP of area C** --dport **Port you want to connect on area C** -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

Hope this can help