Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 -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.


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.


target     prot opt source               destination         

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

target     prot opt source               destination         
MASQUERADE  all  --           
MASQUERADE  all  --           
MASQUERADE  all  --           
MASQUERADE  all  --    
share|improve this question
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
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
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
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 "" 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 "" 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

Your Answer


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.