Connecting 2 VPNs

Scripts with setup, destroy, and modify routing tables and firewall rulesets for client connections.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
eLBati
OpenVpn Newbie
Posts: 2
Joined: Fri May 15, 2015 9:49 pm

Connecting 2 VPNs

Post by eLBati » Fri May 15, 2015 10:09 pm

Hello,

I have an openVPN server, with IP 192.168.170.1 (tap0), and my local PC, with IP 192.168.170.3 (tap0)

The server is also a client of another VPN and has IP 192.168.180.2.
The server's interfaces:

Code: Select all

tap0      Link encap:Ethernet  HWaddr 8e:03:2e:02:96:85  
          inet addr:192.168.170.1  Bcast:192.168.170.255  Mask:255.255.255.0
          [...]

tap1      Link encap:Ethernet  HWaddr 6e:6c:c5:f7:43:e2  
          inet addr:192.168.180.2  Bcast:192.168.180.255  Mask:255.255.255.0
          [...]
From server I can ping 192.168.180.* hosts, like 192.168.180.1

On my local PC, Kernel IP routing table contains

Code: Select all

Destination          Gateway         Genmask             Flags Metric Ref      Use Iface
[...]
192.168.180.0        192.168.170.1   255.255.255.0       UG    0      0        0    tap0
[...]
and I can ping 192.168.180.2 (my server's IP), but can't ping 192.168.180.1 (remote VPN host).

How can I reach 192.168.180.1 from my local PC?

Thanks

eLBati
OpenVpn Newbie
Posts: 2
Joined: Fri May 15, 2015 9:49 pm

Re: Connecting 2 VPNs

Post by eLBati » Fri Jul 03, 2015 6:56 pm

I was missing the SNAT rule:

Code: Select all

iptables -t nat -A POSTROUTING -o tap1 -s 192.168.170.0/24 -j SNAT --to-source 192.168.180.2

Post Reply