Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Vigneswaran R <vignesh@atc.tcs.com>
To: netfilter@vger.kernel.org, Nikolaus Rath <Nikolaus@rath.org>
Subject: Re: Wrong routing when combining ip rule with SNAT
Date: Thu, 19 Sep 2013 14:55:38 +0530	[thread overview]
Message-ID: <523AC312.4080300@atc.tcs.com> (raw)
In-Reply-To: <87r4cmc922.fsf@rath.org>

On 09/18/2013 11:21 PM, Nikolaus Rath wrote:
> Vigneswaran R <vignesh@atc.tcs.com> writes:
>> On 09/17/2013 06:28 AM, Nikolaus Rath wrote:
>>> Hi Eliezer,
>>>
>>> I have a VPN connection, and I want to tunnel everything through the VPN
>>> node -- except, of course, the VPN connection itself.
>>>
>>> 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?
>>>
>>> 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. But maybe there's an easier way?
>> * What is the internal IP of the VPN node? Is it 192.168.12.1 (and
>> ebox is the VPN node)?
>>
>> * How the nodes are connected? Is it something like,
>>
>>     vostro <---> ebox <---> [Internet]
>>
>> If so, where is 192.168.17.1 located.
> Ok, you asked for it. Here's my attempt at ASCII art :-).
>
>
> vostro  <--[192.168.17.0/24]--> evil-nat-dpi-firewall-box
>    ^                                        ^
>    |                                        |
>    |                                    [Internet]
>    |                                        |
>    |                                        |
>    `---[192.168.12.0/24]---> ebox <---------'

This is better :-)

> So vostro is connected to some local network (e.g. 192.168.17.0/24, but
> that changes depending on where I am) and to the VPN
> (192.168.12.0/24). The local network is connected to the internet using
> some (typically overly restricive) NAT box. ebox is connected to the
> internet and to the VPN. I'm establishing the VPN by setting up an HTTP
> tunnel through the internet to ebox.
>
> Once the tunnel is established, I want that almost packet goes from
> vostro to the internet to go through the VPN -- including packets
> destined for ebox's public ip, but excluding packets that are destined
> to port 80 of ebox's public ip (because they form the tunnel itself).

Ok. It seems using SNAT as suggested by Pascal on another mai, is 
better. So, overall,

* Mark the packets destined to VPN_EXT_IP:80 to differentiate it from 
the rest of the traffic
* Reroute the rest of the traffic via 'rath' Interface, using policy routing
* SNAT/MASQUERADE the packets going out via 'rath' Interface to have the 
correct source IP


Regards,
Vignesh
>
>
> Best,
> Nikolaus
>    


      reply	other threads:[~2013-09-19  9:25 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
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 [this message]

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=523AC312.4080300@atc.tcs.com \
    --to=vignesh@atc.tcs.com \
    --cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox