Linux Netfilter discussions
 help / color / mirror / Atom feed
From: "Gáspár Lajos" <swifty@freemail.hu>
To: Matevz Langus <matevz.langus@borea.si>
Cc: netfilter@lists.netfilter.org
Subject: Re: how to change ip source address of incoming packets
Date: Wed, 15 Nov 2006 10:31:44 +0100	[thread overview]
Message-ID: <455ADE80.8080003@freemail.hu> (raw)
In-Reply-To: <30B51F1D-F230-4F45-BDB6-050DBB82AC3E@borea.si>

Matevz Langus írta:
> To easy to be true. Tried this one already. I get this:
>
> iptables v1.3.5: Can't use -i with POSTROUTING
>
:-D Right :-D
Okay, then try this:

iptables -t mangle -A PREROUTING -j CONNMARK -i eth0.10 -s 192.168.1.1 
-d $firewal_virtual_ip_on_10 --set-mark 1
iptables -t mangle -A PREROUTING -j CONNMARK -i eth0.11 -s 192.168.1.1 
-d $firewal_virtual_ip_on_11 --set-mark 2
...
iptables -t nat -A PREROUTING -j DNAT -m connmark --mark 1 
--to-destination $firewal_real_ip_on_10
iptables -t nat -A PREROUTING -j DNAT -m connmark --mark 2 
--to-destination $firewal_real_ip_on_11
...


iptables -t mangle -A OUTPUT -j CONNMARK -d 192.168.10.1 --set-mark 1
iptables -t mangle -A OUTPUT -j CONNMARK -d 192.168.11.1 --set-mark 2
...

iptables -t nat -A OUTPUT -j DNAT -m mark ! --mark 0 --to-destination 
192.168.1.1

iptables -t mangle -A POSTROUTING -j ROUTE -m mark --mark 1 --oif  eth0.10
iptables -t mangle -A POSTROUTING -j ROUTE -m mark --mark 2 --oif  eth0.11
...
iptables -t nat -A POSTROUTING -j SNAT -m mark --mark 1 --to-source 
$firewal_virtual_ip_on_10
iptables -t nat -A POSTROUTING -j SNAT -m mark --mark 2 --to-source 
$firewal_virtual_ip_on_12
...

With this scenario the devices on the VLANs can only talk to the firewall...

> Matevz
>
> On Nov 15, 2006, at 9:13 AM, Gáspár Lajos wrote:
>
>> iptables -t nat -A POSTROUTING -j SNAT -i eth0.10 -s 192.168.1.1 
>> --to-source 192.168.10.1
>
>



  reply	other threads:[~2006-11-15  9:31 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-15  7:15 how to change ip source address of incoming packets Matevz Langus
2006-11-15  8:13 ` Gáspár Lajos
2006-11-15  8:25   ` Matevz Langus
2006-11-15  9:31     ` Gáspár Lajos [this message]
2006-11-15  9:35       ` Gáspár Lajos

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=455ADE80.8080003@freemail.hu \
    --to=swifty@freemail.hu \
    --cc=matevz.langus@borea.si \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox