public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: Kerin Millar <kerframil@fastmail.co.uk>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] OT: default route dependent on dest port?
Date: Fri, 04 Oct 2013 22:49:24 +0100	[thread overview]
Message-ID: <524F37E4.6040106@fastmail.co.uk> (raw)
In-Reply-To: <l2n9vs$lt3$1@ger.gmane.org>

On 04/10/2013 21:55, Grant Edwards wrote:
> Let's posit two network interfaces net1 (192.168.x.y/16) and net2
> (172.16.a.b/16).  There's a NAT/gateway available on each of the
> networks. I want to use the 172.16 gateway for TCP connections to port
> 80 and the 192.168 gateway for everything else.
>
> I'm primarily following this example:
>
>    http://www.tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.netfilter.html
>
> My "main" routing table contains all directly accessible subnets plus
> a default route via the 192.168 gateway.
>
> I created a second route table named "pmain" which is identical to
> "main" except it has a different default route via the 172.16 gateway.
>
> My ip rules are:
>
>    0:      from all lookup local
>    10000:  from all fwmark 0x1 lookup pmain
>    32766:  from all lookup main
>    32767:  from all lookup default
>
> I then add an iptables rule like this:
>
>    iptables -A OUTPUT -t mangle -p tcp --dport 80 -j MARK --set-mark 1

It would help if you were to also supply the details of:

   * ip -f inet -o a s
   * ip route show table main
   * ip route show table pmain

>
> Now all TCP packets destined for port 80 are sent to the 172.16
> gateway, _but_ they're being sent with a 192.168 source address. The
> TCP stack is apparently unaware of the advanced routing tricks and
> thinks that the packets are going out via the 192.168 gateway.
>
> IOW I've succesfully re-routed TCP _packets_ but not the TCP
> _connection_.
>
> How do I tell the TCP stack that it's supposed to use the 172.16
> inteface/gateway for connections to port 80?

--Kerin


  reply	other threads:[~2013-10-04 21:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-04 20:55 [gentoo-user] OT: default route dependent on dest port? Grant Edwards
2013-10-04 21:49 ` Kerin Millar [this message]
2013-10-04 22:15   ` [gentoo-user] " Grant Edwards
2013-10-04 22:50     ` Grant Edwards
2013-10-04 23:08       ` Grant Edwards
2013-10-04 22:08 ` [gentoo-user] " Dragostin Yanev
2013-10-04 22:44   ` [gentoo-user] " Grant Edwards

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=524F37E4.6040106@fastmail.co.uk \
    --to=kerframil@fastmail.co.uk \
    --cc=gentoo-user@lists.gentoo.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