Linux Netfilter discussions
 help / color / mirror / Atom feed
From: "Gáspár Lajos" <swifty@freemail.hu>
To: Elison Niven <elison.niven@gmail.com>
Cc: netfilter@vger.kernel.org, elison.niven@matrixtelesol.com
Subject: Re: Get source IP of packet through PREROUTING CHAIN
Date: Tue, 11 Aug 2009 14:36:11 +0200	[thread overview]
Message-ID: <4A8165BB.7060702@freemail.hu> (raw)
In-Reply-To: <21df6cb70908102139i1f0f21besc94740ed507615da@mail.gmail.com>

Hi Elison,

The conntrack subsystem knows about every connection.
So maybe you need to check that.

Elison Niven írta:
> Hi List,
>
> I have two interfaces eth0 and eth1 on my machine.
>
> My machine has eth0 = 192.168.1.100 and eth1 = 172.16.1.100
>
> The scenario is that I will be receiving packets at port 10000 on eth0
> of my machine. I do not know from which IP the packets are being
> received (Can be any machine - I do not need to apply a source address
> matching rule).
>   
You may not know the source IP, but your machine will, because it sees 
the packets coming from eth0's network.
> I need to forward these packets to another machine B that I do so with
> this rule:
>
> iptables -t nat -I PREROUTING -i eth0 -p udp \
>        --dport 10000 -j DNAT --to-destination 172.16.1.200
>
> Note that I have not added any -s option to the rule for source
> address matching.
>
> This also works properly. Now I need to _know_ the source IP and
> source Port of the packets that are being received at port 10000 on
> eth0. (For example to send some data back to the _same_machine_ that
> is sending packets at port 10000)
>   
Again. If the conntrack (in your machine) knows the source IP/port 
numbers then it will automagically replace them on the backroute.
It may be also a problem if your response packets are not SNAT-ed. (In 
the case the sender machines sending the packets directly to your machine.)
> How do I achieve this?
>
> Best Regards,
> Elison
>   
Swifty

  reply	other threads:[~2009-08-11 12:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-11  4:39 Get source IP of packet through PREROUTING CHAIN Elison Niven
2009-08-11 12:36 ` Gáspár Lajos [this message]
2009-08-11 13:37   ` Elison Niven
2009-08-11 13:44     ` Christoph A.

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=4A8165BB.7060702@freemail.hu \
    --to=swifty@freemail.hu \
    --cc=elison.niven@gmail.com \
    --cc=elison.niven@matrixtelesol.com \
    --cc=netfilter@vger.kernel.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