Hello,
Long time OpenVPN administrator, first time poster here.
I have been employing for quite some time, at numerous sites, a site-to-site VPN using layer 3 tunnelling via TUN (not TAP) devices.
My configurations typically look like this:
side a (LAN: 172.16.0.1) < ------------- > side b (LAN: 172.16.1.1)
172.16.0.0/24 172.31.0.1 172.16.0.2 172.16.1.0/24
side a tunnel IP side b tunnel IP
Everything works both ways just fine, however, one annoying side effect of doing it this way is, if someone on side a communicates with a server on side b, the IP address that side b machine sees is side b's OpenVPN server LAN address, instead of the side a originating IP address.
So, for instance if a machine on side a with an IP of 172.16.0.5 talks to a machine on side b who's IP address is 172.16.1.10, the logs, network traffic, etc. don't reflect that it's 172.16.0.5; instead the LAN address of side b is what the client on that network sees (172.16.1.1).
So, the (sophomoric) question to be asked is, can we not show the gateway IP, but the real client IP's address? Because the tunnels are symmetric, both sides can communicate, such that any machines on 172.16.1.0/24 can directly access machines on 172.16.0.0/24, and vice-versa.
side a config:
port 1194
proto tcp-server
dev tun0
ca /etc/openvpn/CA/keys/ca.crt
cert /etc/openvpn/CA/keys/sidea.cert
key /etc/openvpn/CA/keys/sidea.key
dh /etc/openvpn/CA/keys/dh2048.pem
remote public.ip.of.side.b 1194
ifconfig 172.31.0.1 172.31.0.2
route 172.16.1.0 255.255.255.0 172.31.0.2
up /etc/openvpn/set-up-nat-and-routing.sh
tls-server
persist-key
persist-tun
cipher BF-CBC
verb 5
comp-lzo
float
side b config
port 1194
proto tcp-client
dev tun0
ca /etc/openvpn/CA/keys/ca.crt
cert /etc/openvpn/CA/keys/sideb.crt
key /etc/openvpn/CA/keys/sideb.key
dh /etc/openvpn/CA/keys/dh2048.pem
remote side.a.public.ip.address 1194
ifconfig 172.31.0.2 172.31.0.1
route 172.16.0.0 255.255.255.0 172.31.0.1
up /etc/openvpn/set-up-nat-and-routing.sh
tls-client
persist-key
persist-tun
cipher BF-CBC
verb 5
comp-lzo
float
Beyond this config, the systems are configured to do ipv4 forwarding, and the appropriate iptables-based forwarding. I have tried playing with the values of
iptables -t nat -A POSTROUTING -o $INTERFACE -j MASQUERADE to not much avail (where $INTERFACE is the appropriate LAN interface).
Any suggestions would be appreciated--this really isn't a problem, as much as an annoyance of gap in knowledge.