Linux Netfilter discussions
 help / color / mirror / Atom feed
From: "federico.disante" <federico.disante@duet.it>
To: netfilter@vger.kernel.org
Subject: LOG natted packet.
Date: Tue, 14 May 2013 17:37:17 +0200	[thread overview]
Message-ID: <0c9a093fffc283dd8d4ea216e32a6763@duet.it> (raw)

Hi,

I'm the admin of a linux based router/firewall, that protects a LAN.

I would like to log the path follwed by a response packet of a
source-natted connection.

In the interfarce (eth1) connected to the ADSL modem, connected to
internet, the box does source nat, with the following rule

iptables -t nat -I POSTROUTING 1 -o eth1 -j SNAT --to-source 192.168.1.128

To log the packets back flow from the internet (from the host whose ip is
4.5.6.7) to the LAN, I write the following rules:

iptables -t mangle -I PREROUTING 1 -p tcp -s 4.5.6.7 -j LOG --log-prefix
"Packet_back_in_pre_mangle"

iptables -t nat -I PREROUTING 1 -p tcp -s 4.5.6.7 -j LOG --log-prefix
"Packet_back_in_pre_nat"
         
iptables -t mangle -I FORWARD 1 -p tcp -s 4.5.6.7 -j LOG --log-prefix
"Packet_back_in_forw_mangle"

The problem I have is that the LOG in the PREROUTING chain does not output
nothing. From the syslog I get the following

May 14 17:14:25 LinuxBasedFirewall kernel: [3651139.713796]
Packet_back_in_pre_mangle IN=eth1 OUT=
MAC=00:e0:18:b1:16:82:00:60:3b:29:f1:3f:08:00 SRC=4.5.6.7 DST=192.168.1.128
LEN=44 TOS=0x00 PREC=0x00 TTL=54 ID=0 DF PROTO=TCP SPT=443 DPT=1263
WINDOW=14600 RES=0x00 ACK SYN URGP=0

May 14 17:14:25 LinuxBasedFirewall kernel: [3651139.713892]
Packet_back_in_forw_mangle IN=eth1 OUT=eth1 SRC=4.5.6.7 DST=192.168.10.192
LEN=44 TOS=0x00 PREC=0x00 TTL=53 ID=0 DF PROTO=TCP SPT=443 DPT=1263
WINDOW=14600 RES=0x00 ACK SYN URGP=0 MARK=0x1e

The log clearly show the back translation of the source natted packet
(from the natted ip 192.168.1.128 to the original source ip
192.168.10.192).

My question is: why I do not get the log from the nat table in the
PREROUTING chain? It seems the packet disappears in the nat table in the
PREROUTING chain and reappears in the mangle table in the FORWARD chain!
Any suggestions?

Thank you,
Federico

             reply	other threads:[~2013-05-14 15:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-14 15:37 federico.disante [this message]
2013-05-14 23:48 ` LOG natted packet Pascal Hambourg
     [not found]   ` <CANQgTc+SdLpTrF2Ob=_OywDfLZn7UQkMPQHyaRrPngqimqb=vg@mail.gmail.com>
2013-05-15 14:50     ` Federico Di Sante

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=0c9a093fffc283dd8d4ea216e32a6763@duet.it \
    --to=federico.disante@duet.it \
    --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