I have an OpenVPN tun0 10.8.0.0 255.255.255.0
There is an interface on the server eth1 for 192.168.0.0 255.255.255.0
I would like to route the OpenVPN connections to access the 192.168.0.0 network.
I can connect to the VPN from my client, I get an ip of 10.8.0.6 but on the server it will not route the traffic from tun0 to eth1. When I do a tracerout for 192.168.0.1 it shows going out towards 10.8.0.1 but stops right there.
If I try to ping 192.168.0.1 on the server from tun0 I get no response. ping 192.168.0.1 -I tun0
Anyone can please help me what do I need to add on the server to get the routing and the NAT working?
Thanks!
it seems you need to update two part of your configuration.
Push route from your server conf file, just add the following line
push "route 192.168.0.0 255.255.255.0 10.8.0.1"
Then you need to NAT all traffic coming from 10.8.0.0 so then your device on 192.168.0.0 will know where to route back the paquet to VPN client. Just run this command on your server.
iptables -A POSTROUTING -s 10.8.0.0/24 -o eth1 -j MASQUERADE
Also double check you have ip forwarding enable on the server by commented out the line net.ipv4.ip_forward=1
from the file /etc/sysctl.conf
. Then run the command sysctl -p
to enable the rule.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments