Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Ray Leach <spoons@rchq.co.za>
To: pierre.juhen@wanadoo.fr
Cc: Netfilter <netfilter@lists.netfilter.org>
Subject: Re: Multi ISP router/firewall ...
Date: Wed, 28 Mar 2007 07:51:58 +0200	[thread overview]
Message-ID: <1175061118.21066.34.camel@rayw.internal> (raw)
In-Reply-To: <3564089.276511175009558150.JavaMail.www@wwinf1504>

On Tue, 2007-03-27 at 17:32 +0200, Pierre JUHEN wrote:
> Suggested reading : http://www.ssi.bg/~ja/nano.txt
> 
> It explains how the routing is done.
> 
> Using the ROUTE patch, you force the routing outside the 
> routing table.
> 
> When a packet comes back on an established connection,
> the kernel lookup in the cache, with the input interface 
> as part of the matching.
> 
> Since in the cache, you have the other interface (ISP1)
> for this connection, it doesn't route the packet.
> 
> You should use something else than the ROUTE target, for example
> what is explained in nano.txt.
> 
> 

Hi

I tried both methods - iptables using the ROUTE target as well as using
iptables to mark the packets, then using iproute2 to lookup and route
using a table with an ip fwmark rule.

In both cases, the traffic is routed out and return traffic comes back
in the correct interface, but it does not get NATed backed to the
client.

iptables -A FORWARD -i eth0 -p tcp --dport 80 -s 10.0.0.3 -j ACCEPT
iptables -A FORWARD -i eth4 -p tcp --sport 80 -d 10.0.0.3 -j ACCEPT

iptables -A FORWARD -t mangle -p tcp --dport 80 -s 10.0.0.3 -j MARK
--set-mark 0x4

iptables -A POSTROUTING -t nat -o eth4 -p tcp --dport 80 -s 10.0.0.3 -j
SNAT --to 10.1.0.2

ip rule del fwmark 4 table 4 priority 32000
ip route flush table 4
ip route add table 4 default via 10.1.0.1
ip rule add fwmark 4 table 4 priority 32000
ip route flush cache


What am I doing wrong?

Looking in /proc/net/ip_conntrack I can find an entry for http traffic
from machine at ip 10.0.0.3 created by the SNAT rule above. When the
traffic returns back in eth4 it seems to disappear on the firewall ...

Regards

Ray

> 
> > Message du 27/03/07 14:54
> > De : "Ray Leach" <spoons@rchq.co.za>
> > A : "Netfilter" <netfilter@lists.netfilter.org>
> > Copie à : 
> > Objet : Multi ISP router/firewall ...
> > 
> > Hi All
> > 
> > I've been trying to configure a router/firewall with 5 zones (2 of which
> > are ISP links) unsuccessfully.
> > 
> > So far I've managed to patch the kernel with the ROUTE target, and I've
> > got rules as follows:
> > 
> > FORWARD chain filter table:
> > ACCEPT     0    --  ethxx0 eth4    10.0.0.0/24    0.0.0.0/0           
> > ACCEPT     0    --  eth4   ethxx0  0.0.0.0/0      10.0.0.0/24
> > 
> > FORWARD chain mangle table:
> > ROUTE      tcp  --  *      *       10.0.0.67    !192.168.1.0/24      tcp
> > dpts:80:90 ROUTE oif:eth4 continue
> > 
> > 
> > POSTROUTING chain nat table:
> > SNAT       0    --  *      eth4    0.0.0.0/0    0.0.0.0/0  to:10.1.0.2
> > 
> > 
> > ethxx0 is my internal LAN
> > eth4 is my 2nd ISP connection
> > 10.0.0.67 is my workstation
> > 10.1.0.2 is the ip bound to eth4
> > 
> > The other ISP link is working, we host around 12 websites on servers in
> > our DMZ, we have outgoing web browsing, email, MSN, etc. using various
> > nat rules for that interface, they all work.
> > 
> > I can see using tcpdump that the packets are leaving my workstation,
> > being mangles to change the route, going out the 2nd ISP link, coming
> > back into the 2nd ISP link, but then they disappear.
> > 
> > My forwarding rules as shown above do not show any traffic.
> > 
> > This has me stumped.
> > 
> > As I've stated, I have nat (both SNAT and DNAT) working on the other ISP
> > interface on the same machine.
> > 
> > Where should I start looking?
> > 
> > Regards
> > 
> > Ray
> > -- 
> > Raymond Leach
> > RCHQ Hobbies (http://www.rchq.co.za/)
> > (T)+27-82-575-6975 (F)+27-86-652-2773
> > 
> > 
> > 
> >
> 
> 
> 
-- 
Raymond Leach
RCHQ Hobbies (http://www.rchq.co.za/)
(T)+27-82-575-6975 (F)+27-86-652-2773



  reply	other threads:[~2007-03-28  5:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-27 15:32 Multi ISP router/firewall Pierre JUHEN
2007-03-28  5:51 ` Ray Leach [this message]
2007-03-28  6:18   ` Jan Engelhardt
2007-03-28  6:43     ` Ray Leach
2007-03-28 11:42       ` Raymond Leach
2007-03-28 12:21       ` Ray Leach
2007-03-28 17:15         ` Jan Engelhardt
  -- strict thread matches above, loose matches on Subject: below --
2007-03-27 12:52 Ray Leach

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=1175061118.21066.34.camel@rayw.internal \
    --to=spoons@rchq.co.za \
    --cc=netfilter@lists.netfilter.org \
    --cc=pierre.juhen@wanadoo.fr \
    /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