Answer the question
In order to leave comments, you need to log in
How to properly configure OpenVPN to route traffic sequentially through two servers?
Good afternoon!
There are 2 servers on the Internet on which OpenVPN is raised. The idea is to route all traffic from clients that connect to server 1 to server 2 and from there to the internet. Clients connect to eth0 of server 1. That is, the scheme is as follows (networks taking into account connections via OpenVPN):
Клиент <--(10.1.0.0/24)--> сервер 1 <--(10.2.0.0/24)--> сервер 2 <--(интернет).
push "redirect-gateway def1"
) is pushed from the first server to the client. How to configure OpenVPN to push the necessary routes with this scheme to the client and server 1 for the correct traffic routing? iptables -t nat -A POSTROUTING -s 10.1.0.0/24 -o eth0 -j SNAT --to-source 10.2.0.2
iptables -t nat -A POSTROUTING -s 10.2.0.0/24 -o eth0 -j SNAT --to-source EX IP
Answer the question
In order to leave comments, you need to log in
It is enough for clients to send the route through the first server (server 1), and configure routing on servers 1 and 2. Nat needs to be configured only on server 2, through which the traffic is already going to the Internet.
On the first server:
ip route add default via <server2-ip> dev tunX table 10
ip rule add from <clients-net> lookup 10 pref 10
ip route add <clients-net> via <server1-ip> dev tunY
iptables -t nat -A POSTROUTING --src <clients-net> -o <extiface> \
-j SNAT --to-source <extip>
1. Set up routes via ccd on the 1st and 2nd servers.
2. on the 2nd server you configure NAT.
do not forget about FORWARD - it should be in ACCEPT
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question