I have a VPN server (ubuntu) with 2 interface:
eth0: A.B.C.D
eth1: 192.168.8.45
I've setup VPN which create tun interface. VPN IP is 10.8.0.0/24 Now from VPN client (10.8.0.6) I can connect to my LAN (192.168.8.0/24), ping and access server on LAN. I've forced all traffic through LAN by setting in server.conf
push "redirect-gateway def1"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
And set IP tables
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
With these setting, I can connect to the internet, but using IP address of eth0 (A.B.C.D), not through eth1 as I want.
If I try to set:
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth1 -j MASQUERADE
Then I cannot connect to the internet.
So what is the problem? I've already googled but no answer in this case.
Could you help me? I will really appreciate. Thank you
Best Answer
When you try to set
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth1 -j MASQUERADE
you route add traffic from VPN to eth1. But I think you doesn't have route to 0.0.0.0/0 trough eth1. There not enough information about your network, but you could add iptables ruleiptables -t nat -A POSTROUTING -s 192.168.8.0/24 -o eth0 -j MASQUERADE
and try to check what happened.