Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have set up a working OpenVPN server and client, and can apparently connect to each other just fine.

I'm trying to route all of the clients traffic (web+DNS) through the VPN server, however it isn't working. Per the OpenVPN tutorial, I'm doing:

sudo iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE

And this apparently does nothing. Once connected to the VPN, the client can ping the server just fine, but has absolutely no Internet access.

Doing

sudo iptables -S or sudo iptables -L

doesn't look like anything has changed.. I've changed the server and client config files per the tutorial's instructions.

Any help would be great, thanks.

Update

Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
MASQUERADE  all  --  10.8.0.0/24          0.0.0.0/0           
MASQUERADE  all  --  10.8.0.0/24          0.0.0.0/0           
MASQUERADE  all  --  10.8.0.0/24          0.0.0.0/0           
MASQUERADE  all  --  10.8.0.0/24          0.0.0.0/0    
share|improve this question
1  
Run cat /proc/sys/net/ipv4/ip_forward. Does it say "1"? –  cjc Apr 5 '12 at 18:49
    
It says 0.... Hm... –  B. VB. Apr 5 '12 at 18:49
1  
Do echo 1 > /proc/sys/net/ipv4/ip_forward. Does it work now? –  cjc Apr 5 '12 at 18:50
    
I had to change it using nano. sudo echo 1 > ... said permission denied. Anyway, I changed it, but from the client still no Internet access.. –  B. VB. Apr 5 '12 at 18:55
1  
Can you dump out the firewall rules and update your question? iptables -L -n and iptables -L -n -t nat. –  cjc Apr 5 '12 at 18:59
show 1 more comment

1 Answer

up vote 2 down vote accepted

After a Chat with the OP, we concluded that this was an issue with the DNS configuration, where OpenVPN was pushing "10.8.0.1" as the DNS server through DHCP. Since there was no name server running on the VPN server, this caused the client to fail to resolve remote hosts.

Pushing "8.8.8.8" as the DNS server through OpenVPN's DHCP resolved the issue.

We also needed to turn on ip_forward.

The OP needs to add the following to /etc/sysctl.conf:

net.ipv4.ip_forward = 1

(or uncomment it, if there's already a line)

share|improve this answer
    
Thanks so much for your time - Much appreciated. –  B. VB. Apr 5 '12 at 20:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.