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 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
add comment

1 Answer

up vote 0 down vote accepted

Using the following line fixed my problem:

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

Where 10.8.0.0 is the ip of the OpenVPN subnet.

share|improve this answer
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.