Here we are not using DNAT but linux PBR. We'll need two IP addresses on your system, say IP1 & IP2.
- On your system, create a GRE tunnel between Local IP1 and Remote IP:
## CREATE GRE TUNNELmodprobe ip_gre echo 1 > /proc/sys/net/ipv4/ip_forward ip tu add zen mode gre remote 10.66.63.5 local 10.66.63.21 ttl 128 ip ad ad dev zen 172.17.0.41 peer 172.17.0.42/30
ip li set zen up ip tu ls zen ip ad ls zen ping 172.17.0.42 -c 5 - Create a custom routing table to handle routing for GRE traffic:
- Create a rule to route traffic originating from IP2 through custom routing table created in step 3:
- Create a route in custom routing table to make GRE interface the default gateway.
- Send traffic with IP2 as source ip.