Answer the question
In order to leave comments, you need to log in
How to forward port through openvpn?
Two jabber servers (vps). Both have only eth0 with external static ip and lo respectively. An openvpn (tun) tunnel has been raised between the servers. Nothing is written in ccd (an empty file), route and iroute are also not registered (there are no locales behind the servers). Both servers see each other perfectly, through tun, pings go, ssh works from one to the other.
Few configurations:
Server 1 - eth0 - xxx.xxx.xxx.xxx, tun0 - 10.8.37.1, iptables v1.4.14
Server 2 - eth0 - yyy.yyy.yyy.yyy, tun0 - 10.8.37.2, iptables v1.4.4
net .ipv4.ip_forward=1 - on both machines
The task is to forward the port from server2:5222 to server1:12001. In other words, to have access to 10.8.37.1:5222 via yyy.yyy.yyy.yyy:12001.
Records on server2 type:
iptables -t nat -A PREROUTING -i eth0 -p tcp -m tcp --dport 12001 -j DNAT --to-destination 10.8.37.1:5222
iptables -A FORWARD -d 10.8.37.1/32 -p tcp -m tcp --dport 5222 -j ACCEPT
does not work.
Answer the question
In order to leave comments, you need to log in
As a result, it worked like this:
iptables -t nat -A PREROUTING -d yyy.yyy.yyy.yyy -p tcp -m tcp --dport 12001 -j DNAT --to-destination 10.8.37.1:5222
iptables -t nat -A POSTROUTING -d 10.8.37.1 -p tcp -m tcp --dport 5222 -j SNAT --to-source 10.8.37.2
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question