allow multi-in multi-out traffic relay

the main idea is to set mark to packets from different interfaces, and snat them according the marks.

here is the saved config file:

# set mark to traffic from different interface/ip

*mangle
-A PREROUTING -d 10.2.64.127 -j MARK –set-mark 1
-A PREROUTING -d 10.2.64.247 -j MARK –set-mark 2
COMMIT

# rewrite the destination

*nat
-A PREROUTING -d 10.2.64.127 -j DNAT –to 10.2.65.72
-A PREROUTING -d 10.2.64.247 -j DNAT –to 10.2.65.72

# snat according mark

-A POSTROUTING -m mark –mark 1 -j SNAT –to 10.2.64.127
-A POSTROUTING -m mark –mark 2 -j SNAT –to 10.2.64.247
COMMIT

http://www.tldp.org/HOWTO/Adv-Routing-HOWTO/lartc.netfilter.html

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s