4
1
Till now I have managed to installed OpenVPN server on DigitalOcean and OpenVPN client on Raspberry Pi. My Raspberry Pi's OpenVPN IP is 10.8.0.6 which I can ping from OpenVPN server. Now this RPi is connected to LAN netword(gateway 10.1.1.253, SubnetMask:255.255.252.0) by IP 10.1.2.14. There is another Linux system connected to this client's(RPi) network and its IP is 10.1.2.2.
Now I want to access 10.1.2.2 from OpenVPN server via VPN. Can anybody explain me how should I do this ?
EDIT: As per @masgo's suggestion, I did following
- In
server.conf
file, addedclient-config-dir /etc/openvpn/ccd
,route 10.1.0.0 255.255.252.0
andpush "route 10.1.0.0 255.255.252.0"
- In /etc/openvpn/ccd/lappy file, added
iroute 10.1.0.0 255.255.252.0
- Now I am able to ping to ip 10.1.2.14(OpenVPN's client) from OpenVPN server but not to ip 10.1.2.2. What I am missing in client side routing?
My netmask is not
255.255.255.252
but255.255.252.0
– Bhushan – 2016-08-25T11:09:30.500So I need to add following command in RPi
iptables -t nat -A POSTROUTING -d 10.1.0.0 / 22 -j MASQUERADE
. Right ? – Bhushan – 2016-08-25T11:12:55.700@BhushanPatil That's right. As for the network, apologies, my bad. – MariusMatutiae – 2016-08-25T11:17:58.477
@BhushanPatil No space in 10.1.0.0/22, careful. – MariusMatutiae – 2016-08-25T11:18:46.147
THAT WORKED. thank you very much. But I am new to networking stuff, so will you explain me what this command
iptables -t nat -A POSTROUTING -d 10.1.0.0/22 -j MASQUERADE
doing magic here ? – Bhushan – 2016-08-25T11:38:36.7331@BhushanPatil Sure: it rewrites the IP header of every frame sent, with its own IP address for the sender, to make it look like the frames are sent from the RPI instead of being passed on from the Ocean server. It also keeps track of all conversations automagically, so that when the reply comes, the RPI knows that the reply is really for the Ocean server, not for itself. – MariusMatutiae – 2016-08-25T12:00:19.450