Logging inbound NAT packets

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
david.woodward
DD-WRT Novice


Joined: 12 Mar 2011
Posts: 6

PostPosted: Tue Mar 15, 2011 3:35    Post subject: Logging inbound NAT packets Reply with quote
I'm experimenting with remote logging options and was going to try to log inbound (accepted) packets, but I can't seem to find a FORWARD filter that will give me this data.

The specific section of my firewall script that I think should give me what I want is as follows:

Code:

#Log outbound packets
iptables -I FORWARD -i $guestif -o $wanif -s $guestsubnet -m state --state NEW -j logaccept
#Log inbound packets
iptables -I FORWARD -i $wanif -o $guestif -d $guestsubnet -m state --state ESTABLISHED,RELATED -j logaccept


However in my logs all I ever get is the outbound packets even though the output from "iptables -t filter -vnL" suggest the inbound rule is successfully matching/processing packets as seen below.

Code:

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
.
.
.
  576  437K logaccept  0    --  vlan2  wl0.1   0.0.0.0/0            192.168.22.0/24     state RELATED,ESTABLISHED
   42  2528 logaccept  0    --  wl0.1  vlan2   192.168.22.0/24      0.0.0.0/0           state NEW
.
.
.


I suspect this is because the inbound packets are not truly destined for wl0.1 until after nat/POSTROUTING has translated them.

Is there anyway to log the correlating inbound traffic for outbound traffic that is NAT'd?

Thanks in advance,
David
Sponsor
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Tue Mar 15, 2011 5:28    Post subject: Reply with quote
You overlooked the rules in the logaccept chain. Only new connections are logged by the logging chains, but your inbound rule is sending established/related traffic to the logaccept chain.
_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
david.woodward
DD-WRT Novice


Joined: 12 Mar 2011
Posts: 6

PostPosted: Tue Mar 15, 2011 11:58    Post subject: Reply with quote
I see.

I seem to remember reading somewhere that we can create our own chains, right? Perhaps I can create my own "logacceptall" chain. Thanks for pointing me in the right direction.
david.woodward
DD-WRT Novice


Joined: 12 Mar 2011
Posts: 6

PostPosted: Wed Mar 16, 2011 1:19    Post subject: Reply with quote
So, I've got logging for the inbound packets now, but I'm a little curious.

The chain for "logaccept" looks like this:

Code:

Chain logaccept (10 references)
 pkts bytes target     prot opt in     out     source               destination         
 1239 64474 LOG        0    --  *      *       0.0.0.0/0            0.0.0.0/0           state NEW LOG flags 7 level 4 prefix `ACCEPT '
 1239 64474 ACCEPT     0    --  *      *       0.0.0.0/0            0.0.0.0/0           


So, in my firewall commands I have:

Code:

iptables -I FORWARD -i $wanif -o $guestif -d $guestsubnet -m state --state ESTABLISHED,RELATED -j LOG --log-prefix 'ACCEPT ' --log-level 4


Which reproduces everyting except the "flags 7" portion of the "logaccept" chain. What is flags? I've been looking online at all the documentation I could find and I don't see anything that references this at all.

Thanks again,
David
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum