Iptables – Routing specific traffic through StrongSwan VPN

ipseciptablesstrongswanvpn

I am expected to make http requests to a server (local IP 172.XX.XX.XX) behind a gateway of a telecom. A VPN has been setup between my VPS 46.XX.XX.XX and to gateway 193.XX.XX.XX.

However I need to make a SOAP API request with end point say http://172.XX.XX.XX:4506/ which is behind the gateway 193.xxx.xxx.xxx.

However, I need to send this request through the tunnel that has been setup between our system and the telecom.

How do I implement this so that when I make the request, my network can push the traffic through the tunnel and also receive via the tunnel.

My vps has address 46.xxx.xx.xx

IP route command shows;

ip route

default via 46.xx.xx.x dev eth0 
10.16.0.0/16 dev eth0  proto kernel  scope link  src 10.16.0.6 
10.131.0.0/16 dev eth1  proto kernel  scope link  src 10.131.14.73 
46.xxx.xx.0/20 dev eth0  proto kernel  scope link  src 46.xxx.xx.xxx 
169.254.0.0/16 dev eth0  scope link  metric 1002 
169.254.0.0/16 dev eth1  scope link  metric 1003 

thank you.

Best Answer

You need just to add a route to the desired IP address / network so that the next hop is the other end of your VPN tunnel.

For example:

ip route add 192.168.10.200 via 10.210.10.1

makes all packets destined to 192.168.10.200 go via 10.210.10.1 host at the other end of the VPN tunnel.

You also need to make sure that the other end's routing has been set up correctly.

Related Topic