Skip to contentSkip to conversation

tcpdump and Iptables

DISCUSSION CC 4 participants 7 messages Sep 2, 2004 – Sep 3, 2004

lore
Share & tools
lore

CC

author
#0 lore raw

Hi,

I think I've asked this before here, but I don't remember what the answer was.

If I have iptables running and I do a
tcpdump -i eth0, at what point is
tcpdump listening to the connection?

I'm trying to troubleshoot my firewall, but am not seeing the right behaviour as the packets that I'm trying to block by the following command:

$IPTABLES -A FORWARD -i eth1 -p tcp \
             -d 192.168.7.1 -j DROP

But I still get tcp packets going to 192.168.7.1.

And wouldn't :

$IPTABLES -A FORWARD -i eth1 -p tcp \
            -s 192.168.7.1 -j DROP

in effect disables all access to the internet for machine IP 192.168.7.1?

But my main query is about the relationship between the packets that TCPDUMP sees and where the packets are within the packet filtering process.

Thanks

#1 lore raw
Quoted 8 lines · CC

Hi,

I think I've asked this before here, but I
don't remember what the answer was.

If I have iptables running and I do a
tcpdump -i eth0, at what point is
tcpdump listening to the connection?

tcpdump operates at the BPF layer, which is below netfilter.

if the the inbound interface is eth0; packets that will eventually be dropped by netfilter will be captured by tcpdump.

if you're trying to see whether packets make it *through* the firewall--tcpdump on the exiting interface.

-j

Signature · 1 line
Jason Opperisano <[email protected]>
#2 lore raw
In reply to CC
Quoted 2 lines · CC

If I have iptables running and I do a tcpdump -i eth0, at what point
is tcpdump listening to the connection?

tcpdump will see the packets before IPTables does anything to them.

Signature · 1 line
mors omnia vincit
author
#3 lore raw
Quoted 9 lines · Nick Drage
Quoted 2 lines · CC

If I have iptables running and I do a tcpdump -i eth0, at what point
is tcpdump listening to the connection?

tcpdump will see the packets before IPTables does anything to them.

Thanks NIck for the info. Exactly what I wanted to know.

Edmund

#4 lore raw
Quoted 8 lines · cc
Quoted 4 lines · Nick Drage
Quoted 2 lines

If I have iptables running and I do a tcpdump -i eth0, at what
point is tcpdump listening to the connection?

tcpdump will see the packets before IPTables does anything to them.

Thanks NIck for the info. Exactly what I wanted to know.

Thanks... though Jason's explanation was rather better :)

tcpdump is an excellent tool, but ( excuse me if I'm stating the obvious ), don't underestimate the usefulness of the logging rules in IPTables combined with

tail -f /var/log/$logfile | grep $string_you_are_looking_for

Signature · 1 line
mors omnia vincit
#5 lore raw
In reply to Nick Drage
Quoted 6 lines · Nick Drage
Quoted 2 lines · CC

If I have iptables running and I do a tcpdump -i eth0, at what point
is tcpdump listening to the connection?

tcpdump will see the packets before IPTables does anything to them.

If that's true (I don't doubt it) then I have a question:
Where in the routing process does tcpdump see the traffic? It can be very important to know it for some studies.

Signature · 12 lines
Jose Maria Lopez Hernandez
Director Tecnico de bgSEC
[email protected]
bgSEC Seguridad y Consultoria de Sistemas Informaticos
http://www.bgsec.com
ESPAÑA

The only people for me are the mad ones -- the ones who are mad to live,
mad to talk, mad to be saved, desirous of everything at the same time,
the ones who never yawn or say a commonplace thing, but burn, burn, burn
like fabulous yellow Roman candles.
                -- Jack Kerouac, "On the Road"
#6 lore raw
In reply to CC
Quoted 14 lines · CC

Hi,

I think I've asked this before here, but I don't remember what the answer was.

If I have iptables running and I do a
tcpdump -i eth0, at what point is
tcpdump listening to the connection?

I'm trying to troubleshoot my firewall, but am not seeing the right behaviour as the packets that I'm trying to block by the following command:

Quoted 5 lines
$IPTABLES -A FORWARD -i eth1 -p tcp \
              -d 192.168.7.1 -j DROP

But I still get tcp packets going to 192.168.7.1.

Wouldn't it work if you use -o eth1 instead of
-i eth1. Where it's situated 192.168.7.1? If
the routes says it has to go through eth1 to
get to 192.168.7.1 then you need -o.

Or maybe you have packets routed through other
interfaces, not eth1. Or maybe the packets
are being originated in the same firewall, so
the FORWARD rule does not apply.

Quoted 16 lines

And wouldn't :

$IPTABLES -A FORWARD -i eth1 -p tcp \
             -s 192.168.7.1 -j DROP

in effect disables all access to the internet for machine IP 192.168.7.1?

But my main query is about the relationship between the packets that TCPDUMP sees and where the packets are within the packet filtering process.

Thanks

Signature · 12 lines
Jose Maria Lopez Hernandez
Director Tecnico de bgSEC
[email protected]
bgSEC Seguridad y Consultoria de Sistemas Informaticos
http://www.bgsec.com
ESPAÑA

The only people for me are the mad ones -- the ones who are mad to live,
mad to talk, mad to be saved, desirous of everything at the same time,
the ones who never yawn or say a commonplace thing, but burn, burn, burn
like fabulous yellow Roman candles.
                -- Jack Kerouac, "On the Road"