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

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

1 Answer 1

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.