LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-06-2014, 08:29 AM   #1
mgai7755
Member
 
Registered: Apr 2011
Posts: 51

Rep: Reputation: 10
iptables : DNAT to openvpn tunnel doesn't work


Hi,

I use this rule to redirect ip traffic coming on port 143 to go to address 10.9.0.10, same port, which is at the other end of an established VPN tunnel.

Code:
-A PREROUTING -p tcp -m tcp --dport 143 -j DNAT --to-destination 10.9.0.10:143
Result :

Code:
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
DNAT       tcp  --  anywhere             anywhere            tcp dpt:imap2 to:10.9.0.10:143
It doesn't work. The port looks open (connection isn't immediately refused), but the connection times out.

A tcpdump on the tun0 interface shows no activity at all on port 143.

Connecting directly (telnet 10.9.0.10 143) works.

Help anybody ?

Thanks

Matt

Last edited by mgai7755; 02-06-2014 at 08:50 AM.
 
Old 02-06-2014, 09:26 AM   #2
mgai7755
Member
 
Registered: Apr 2011
Posts: 51

Original Poster
Rep: Reputation: 10
Ok, reply to self.

1°) enable forwarding looks mandatory :

Code:
sudo sysctl -w net.ipv4.ip_forward=1
2°) it is needed to add a way back for the packets using those two lines :

Code:
sudo iptables -A FORWARD --in-interface eth0 -j ACCEPT # accepts packets
sudo iptables -t nat -A POSTROUTING --out-interface tun0 -j MASQUERADE # provides a way back from the server
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] OpenVPN doesn't work slaka Linux - Networking 2 11-12-2012 01:52 PM
[SOLVED] iptables doesn't work well without OpenVPN pedrokoma Linux - Networking 3 06-02-2011 08:41 AM
[SOLVED] Routing across a multi-homed router from a openvpn tunnel: ping works ssh doesn't. skyanvil Linux - Networking 1 08-17-2010 11:26 AM
simple DNAT iptables rule doesn't work. firatkucuk Linux - Networking 2 10-22-2007 02:35 AM
iptables DNAT of pop3 won't work danGynn Linux - Networking 0 02-26-2004 12:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration