From: Jason Opperisano <opie@817west.com>
To: netfilter@lists.netfilter.org
Subject: Re: Two NICS with same IP and same client IP
Date: Wed, 2 Feb 2005 15:56:11 -0500 [thread overview]
Message-ID: <20050202205611.GA1221@bender.817west.com> (raw)
In-Reply-To: <61246.57.66.65.39.1107336931.squirrel@57.66.65.39>
On Wed, Feb 02, 2005 at 09:35:31AM -0000, Hervé wrote:
> Hello,
>
> I have a weird setup I would like to make work: I have two identical
> subnets connected to one machine via two different NICs, like this:
>
> Server | | Client 1
> eth0:192.168.100.1 |---------| 192.168.100.2
> | | Client 2
> eth1:192.168.100.1 |------------------------------| 192.168.100.2
>
> These two machines only access an NFS share on the server, but I assume
> this is irrelevant: the problem is to route the packets back through the
> interface the request came from (I am not trying to access the boxes
> _from_ the server).
aight--this comes with no warranty expressed nor implied, and no
guarantee that it won't burn down your house or that it will even work
at all... this is off the top of my head, and other than typing the
commands on a test machine to validate the syntax, i have not tested
this one iota... i also don't believe that you *_have_* to do this--i
think you secretly just want to do this, because you think you should be
able to... ;-)
here goes--it obviously requires iproute2, and the CONNMARK patch from
POM:
---BEGIN STUFF I DON'T WANNA HEAR COMMENTS ABOUT---
# start fresh
ip addr flush dev eth0
ip addr flush dev eth1
# add the same IP to each NIC
ip addr add 192.168.100.1/24 brd + dev eth0
ip addr add 192.168.100.1/24 brd + dev eth1
# add two new route tables to hold our local network routes
# (this only needs to be done once)
echo 200 zero >> /etc/iproute2/rt_tables
echo 201 one >> /etc/iproute2/rt_tables
# start fresh
for t in mangle nat filter; do
iptables -t $t -F
iptables -t $t -X
iptables -t $t -Z
done
# restore the connmark on each packet as it comes in off the wire
iptables -t mangle -A PREROUTING -j CONNMARK --restore-mark
# if a packet isn't marked, mark it based off the inbound NIC
iptables -t mangle -A PREROUTING -i eth0 -m connmark --mark 0 \
-j CONNMARK --set-mark 1
iptables -t mangle -A PREROUTING -i eth1 -m connmark --mark 0 \
-j CONNMARK --set-mark 2
# restore the mark on locally-generated reply packets
# before the outbound route lookup
iptables -t mangle -A OUTPUT -j CONNMARK --restore-mark
# add local network route for each NIC in its routing table
ip route add 192.168.100.0/24 dev eth0 src 192.168.100.1 table zero
ip route add 192.168.100.0/24 dev eth1 src 192.168.100.1 table one
# add rules to lookup routes based on the netfilter mark
ip rule add fwmark 1 table zero
ip rule add fwmark 2 table one
# disable reverse path filtering on the duplicate NICs
sysctl -w net.ipv4.conf.eth0.rp_filter=0
sysctl -w net.ipv4.conf.eth1.rp_filter=0
# start clean
ip route flush cache
---END STUFF I DON'T WANNA HEAR COMMENTS ABOUT---
just a thought--hope it doesn't lead you too astray.
i feel so dirty...
-j
--
"You couldn't fool your mother on the foolingest day of your life if
you had an electrified fooling machine."
--The Simpsons
next prev parent reply other threads:[~2005-02-02 20:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-02 9:35 Two NICS with same IP and same client IP Hervé
2005-02-02 9:48 ` Raphael Jacquot
[not found] ` <5172.57.66.65.39.1107338261.squirrel@57.66.65.39>
2005-02-02 10:28 ` Raphael Jacquot
2005-02-02 14:12 ` Jason Opperisano
2005-02-02 14:32 ` Hervé
2005-02-02 14:41 ` Jason Opperisano
2005-02-02 16:53 ` Hervé
2005-02-02 14:44 ` Raphael Jacquot
2005-02-02 16:40 ` Hervé
2005-02-02 16:22 ` Tom Eastep
2005-02-02 20:56 ` Jason Opperisano [this message]
-- strict thread matches above, loose matches on Subject: below --
2005-02-02 16:26 Hudson Delbert J Contr 61 CS/SCBN
2005-02-02 16:49 ` Tom Eastep
2005-02-02 16:47 Gary W. Smith
2005-02-02 16:51 ` Raphael Jacquot
[not found] ` <27594E8BA9D5CA458F5EF87D88B6B48F019948@pxtvjoexd01.pxt.primeexalia.co m>
2005-02-02 16:57 ` Hervé
2005-02-02 16:57 ` Hervé
[not found] ` <18348031.1107363459685.JavaMail.rct@kale>
2005-02-02 18:41 ` Bob Tellefson
2005-02-02 20:47 ` Hervé
2005-02-02 22:22 Hudson Delbert J Contr 61 CS/SCBN
2005-02-02 22:29 ` Jason Opperisano
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=20050202205611.GA1221@bender.817west.com \
--to=opie@817west.com \
--cc=netfilter@lists.netfilter.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.