Report this

What is the reason for this report?

How to forward traffic from Pub IP of VPN Gateway A to VPN Gateway B internal Host

Posted on July 31, 2020

I setup a IPSec connection from a VPN GW-A to VPN GW-B, hosts in VPN A subnet can send packets to hosts in VPN B subnet and vice-verse.

VPN GW-A is Ubuntu Server.

I need to connect to GW-A pub IP on port 9876 and route/forward to host in the GW-B subnet to the same port 9876.

What i did

net.ipv4.ip_forward=1 net.ipv6.conf.all.forwarding=1

-A PREROUTING -d GW-A/32 -p tcp -m tcp --dport 9876 -j DNAT --to-destination HOST-B:9876 -A POSTROUTING -s HOST-B/32 -d GW-A/32 -p tcp -m tcp --sport 9876 --dport 9876

My tcpdump log when try to connect to GW-A on port 9876 is

12:07:51.830469 IP CLIENT.60364 > GW-A.9876: Flags [SEW], seq 2029591603, win 8192, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0 12:07:51.830520 IP GW-A.60364 > HOST-B.9876: Flags [SEW], seq 2029591603, win 8192, options [mss 1460,nop,wscale 8,nop,nop,sackOK], length 0 12:07:57.898877 IP CLIENT.60364 > GW-A.9876: Flags [S], seq 2029591603, win 8192, options [mss 1460,nop,nop,sackOK], length 0 12:07:57.898928 IP GW-A.60364 > HOST-B.9876: Flags [S], seq 2029591603, win 8192, options [mss 1460,nop,nop,sackOK], length 0

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.