From: Nikolaus Rath <Nikolaus@rath.org>
To: netfilter@vger.kernel.org
Subject: Re: Wrong routing when combining ip rule with SNAT
Date: Tue, 17 Sep 2013 17:55:51 -0700 [thread overview]
Message-ID: <87k3ifymlk.fsf@vostro.rath.org> (raw)
In-Reply-To: 5238E484.80802@plouf.fr.eu.org
Pascal Hambourg <pascal@plouf.fr.eu.org> writes:
> Alex Bligh a écrit :
>>
>> I don't think you need iptables. The way I've always done it is:
>> * Default route to the VPN device
>> * /32 route for the VPN endpoint out the physical interface to
>> the previous default route
>
> This does not meet the following OP's requirement :
>
>>> The hard part is to also tunnel non-VPN connections to the VPN node
>>> itself. In other words how do I make sure that every connection to the
>>> external ip of the VPN node is tunneled through its internal ip --
>>> except for the packets that form the tunnel itself?
>
> However I am not sure this is a sensible requirement.
Why not? For example, the VPN node also acts as my mailserver. So
whenever I encounter firewalls that e.g. block everything but port 443
and 80, I have to establish a tunnel to be able to connect to port 25,
and then change the mail server name in my MUA to the internal name on
the VPN. Then, if I'm at a different location where I do not need the
VPN, I have to change it back to the public hostname.
That is rather annoying, and I could avoid it if I somehow get
the smtp connections to use the VPN gateway as well.
Admittedly, I could just run the VPN all the time, but I don't think
this makes the whole idea unsensible.
>>> My idea was install a default route to the internal ip of the VPN node,
>>> use iptables to mark the VPN connections and then set up a special
>>> routing table for those.
>
> Sounds good. Make sure that packets related to the VPN connection (e.g.
> ICMP error messages) are routed outside the tunnel too. I guess that can
> be done with connmark (connection mark).
Well, that was the idea that led to my original question. It doesn't
work, because the packets go out with the wrong source ip
address. Apparently, at the time that the source ip address is
determined, the connection hasn't been marked yet, so it takes the
source ip from the wrong routing table.
Best,
-Nikolaus
--
»Time flies like an arrow, fruit flies like a Banana.«
PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C
next prev parent reply other threads:[~2013-09-18 0:55 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-13 5:10 Wrong routing when combining ip rule with SNAT Nikolaus Rath
2013-09-13 6:26 ` Vigneswaran R
2013-09-13 16:09 ` Nikolaus Rath
2013-09-13 22:03 ` Nikolaus Rath
2013-09-14 13:41 ` Pascal Hambourg
2013-09-14 15:40 ` Nikolaus Rath
2013-09-14 17:17 ` Pascal Hambourg
2013-09-16 7:14 ` Vigneswaran R
2013-09-16 23:38 ` Eliezer Croitoru
2013-09-17 0:58 ` Nikolaus Rath
2013-09-17 12:35 ` Alex Bligh
2013-09-17 23:23 ` Pascal Hambourg
2013-09-18 0:55 ` Nikolaus Rath [this message]
2013-09-18 7:58 ` Alex Bligh
2013-09-18 17:38 ` Nikolaus Rath
2013-09-18 20:11 ` Alex Bligh
2013-09-19 2:29 ` Nikolaus Rath
2013-09-17 21:58 ` Eliezer Croitoru
2013-09-18 0:58 ` Nikolaus Rath
2013-09-18 5:54 ` Vigneswaran R
2013-09-18 17:51 ` Nikolaus Rath
2013-09-19 9:25 ` Vigneswaran R
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k3ifymlk.fsf@vostro.rath.org \
--to=nikolaus@rath.org \
--cc=netfilter@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.