Using public interfaces on a server connected through a GRE tunnel
- by Evan
I'm pretty new to networking so please forgive any terminology mistakes.
I have 2 servers connected with a GRE tunnel.
Server1 (10.0.0.1) ---- Server2 (10.0.0.2)
I want to be able to bind to the public IPs on Server2 using Server1. To do this, I setup virtual interfaces with Server2's public IPs on Server1 and then used routing rules on Server1 to route the packets through the GRE tunnel.
On Server1:
ip rule add from [Server2's first public IP] table gre
ip rule add from [Server2's second public IP] table gre
ip route add default via 10.0.0.2 dev gre1 table gre
This works great and I can see the packets arriving via GRE on Server2. I can see the packet exiting the tunnel on Server2's gre1 device as shown:
From Server1: ping -I [Server2's public ip] google.com
tcpdump from Server2's GRE tunnel device:
12:07:17.029160 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84)
[Server2's public ip] > 74.125.225.38: ICMP echo request, id 6378, seq 50, length 64
This is exactly the packet I want. However, I'm not seeing it go out at all on eth0:0 (where Server2's public IP is bound to).
I've tried to use routing rules to get packets coming from Server2's public IP (which would be coming out of dev gre1) to go through dev eth0 on the public default gateway and that doesn't work either.
I'm at a loss, thank you to anyone who can help.