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 a VPS(with OpenVZ virtualisation) set up with OpenVPN. Clients can connect to the server and the server can ping and access clients.

But clients does not have access to the internet through openvpn, therefore I want to add the following iptables line:

iptables -t nat -A POSTROUTING -j SNAT --to-source <venet's IP>

This allows the openvpn clients to access the internet, but when I add this line the server can no longer ping clients or e.g. ssh into clients, is there a way to fix this?

share|improve this question
up vote 0 down vote accepted

Using the following line fixed my problem:

iptables -t nat -A POSTROUTING -d ! -j SNAT --to-source=<ip on internet>

Where is the ip of the OpenVPN subnet.

share|improve this answer

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.