I want to redirect connection to port 22 to my openvpn binded port, on 60001.
Openvpn is running on server on 60001
server:~$ sudo netstat -apn | grep openvpn
udp 0 0 67.xx.xx.137:60001 0.0.0.0:* 4301/openvpn
I redirect on server port 22 to 60001
server:~$ sudo iptables -F -t nat
server:~$ sudo iptables -A PREROUTING -t nat -p udp --dport 22 -j REDIRECT --to-ports 60001
I start openvpn client (openvpn.conf is correct, it works with remote IP 22 replaced with remote IP 60001)
client:~$ ./openvpn openvpn.conf
Tue Apr 27 00:42:50 2010 OpenVPN 2.1.1 i686-pc-linux-gnu [SSL] [EPOLL] built on Mar 23 2010
Tue Apr 27 00:42:50 2010 UDPv4 link local (bound): [undef]:1194
Tue Apr 27 00:42:50 2010 UDPv4 link remote: 67.xx.xx.137:22
Tue Apr 27 00:42:52 2010 read UDPv4 [ECONNREFUSED]: Connection refused (code=111)
Tue Apr 27 00:42:55 2010 read UDPv4 [ECONNREFUSED]: Connection refused (code=111)
...
Connection fail. tcpdump capture on server side is:
server:~$ sudo tcpdump -n udp port 21 or port 60001
listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
10:48:32.880307 IP 84.xx.xx.27.1194 > 67.xx.xx.137.21: UDP, length 14
10:48:35.039317 IP 84.xx.xx.27.1194 > 67.xx.xx.137.21: UDP, length 14
10:48:37.196800 IP 84.xx.xx.27.1194 > 67.xx.xx.137.21: UDP, length 14
So the packets arrive, but it doesn't connect. Openvpn.conf is correct, and openvpn client/server are working correctly, because if i replace remote IP 22 with remote IP 60001 all works. What's wrong with this redirection?