Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Capturing tcpdump for local traffic

3,309 views
Skip to first unread message

satish....@gmail.com

unread,
Jan 12, 2008, 7:51:59 AM1/12/08
to
Hi All,
I am somewhat new to tcpdump caturing. I have a server lisetener on a
linux box running on port say 5000. All the traffic to this port is
from another process on the same host and from any other host. My
question is can the traffic/packets for this port be captured? How?
tcpdump does not seem to be working in this case. when socket related
process run on the same host, does it mean that the packets do not go
via the network interfaces?

Thanks
-Satish

Martijn Lievaart

unread,
Jan 12, 2008, 9:57:15 AM1/12/08
to

Traffic from a host to the same host always goes over the loopback
interface, even if the IP used to connect belongs to another interface.

HTH,
M4

Scott Gifford

unread,
Jan 12, 2008, 11:52:09 AM1/12/08
to
satish....@gmail.com writes:

[...]

> when socket related process run on the same host, does it mean that
> the packets do not go via the network interfaces?

If they are going across the loopback interface, you may have to tell
tcpdump to read that interface. On Linux the interface is named lo,
so you can use "-i lo".

----Scott.

Barry Margolin

unread,
Jan 13, 2008, 10:43:06 PM1/13/08
to
In article <ly63xz0...@gfn.org>,
Scott Gifford <sgif...@suspectclass.com> wrote:

AFAIK this doesn't work on most operating systems.

--
Barry Margolin, bar...@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***

Ashish Shukla आशीष शुक्ल

unread,
Jan 14, 2008, 11:02:21 AM1/14/08
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>>>> "satish" == satish burnwal <satish....@gmail.com> writes:
satish> Hi All,
satish> I am somewhat new to tcpdump caturing. I have a server lisetener on a
satish> linux box running on port say 5000. All the traffic to this port is
satish> from another process on the same host and from any other host. My
satish> question is can the traffic/packets for this port be captured? How?
satish> tcpdump does not seem to be working in this case. when socket related
satish> process run on the same host, does it mean that the packets do not go
satish> via the network interfaces?

It'll be great if you've posted the command which you're
trying. Anyways, if both endpoints of the connection are on same box
then traffic is routed via loopback (lo) interface, so you need to
listen for traffic on 'lo' interface. Following commandline will help
you do this:

# tcpdump -i lo port 5000

satish> Thanks
satish> -Satish

HTH
- --
Ashish Shukla आशीष शुक्ल http://wahjava.wordpress.com/
·-- ·- ···· ·--- ·- ···- ·- ·--·-· --· -- ·- ·· ·-·· ·-·-·- -·-· --- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD4DBQFHi4eQHy+EEHYuXnQRAvquAJUY+36A+LvWG/Mn6FNO+h7Oh4eiAJ4zn6p1
EazVTEe9woExArrDqRkXiQ==
=bBhu
-----END PGP SIGNATURE-----

Rick Jones

unread,
Jan 14, 2008, 12:54:23 PM1/14/08
to
Barry Margolin <bar...@alum.mit.edu> wrote:
> AFAIK this doesn't work on most operating systems.

True, although IIRC Linux is an exception. On HP-UX at least, where
one indeed cannot run tcpdump against the loopback interface, if one
doesn't want to use nettl, for traffic to local IP's at least, (other
than 127.0.0.1) it is possible to set an ndd variable that will cause
the stack to send the packets to be looped-back by the driver rather
than by IP. This then makes them flow past the promiscuous tracing
taps. (Note that this does not cause them to be sent out onto the NIC
or network, only to be looped-back by the driver).

rick jones
--
firebug n, the idiot who tosses a lit cigarette out his car window
these opinions are mine, all mine; HP might not want them anyway... :)
feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH...

Scott Gifford

unread,
Jan 14, 2008, 1:19:47 PM1/14/08
to
Barry Margolin <bar...@alum.mit.edu> writes:

> In article <ly63xz0...@gfn.org>,
> Scott Gifford <sgif...@suspectclass.com> wrote:

[...]

>> If they are going across the loopback interface, you may have to tell
>> tcpdump to read that interface. On Linux the interface is named lo,
>> so you can use "-i lo".
>
> AFAIK this doesn't work on most operating systems.

Hi Barry,

I just tried it on Linux, kernel 2.4.20, tcpdump 3.7.2, libpcap 0.7.2
and it worked. It captured all of the traffic from the machine to
itself, not just that over 127/8, which is what a previous poster
predicted and I believe what the OP wanted. I have used this in the
past on Linux, I don't remember if I've used it on other OS's or not.

So, no guarantees, but it's worth a try.

----Scott.

satish....@gmail.com

unread,
Jan 16, 2008, 9:01:43 AM1/16/08
to
On Jan 14, 11:19 pm, Scott Gifford <sgiff...@suspectclass.com> wrote:
> Barry Margolin <bar...@alum.mit.edu> writes:
> > In article <ly63xz0yx2....@gfn.org>,

> > Scott Gifford <sgiff...@suspectclass.com> wrote:
>
> [...]
>
> >> If they are going across the loopback interface, you may have to tell
> >> tcpdump to read that interface. On Linux the interface is named lo,
> >> so you can use "-i lo".
>
> > AFAIK this doesn't work on most operating systems.
>
> Hi Barry,
>
> I just tried it on Linux, kernel 2.4.20, tcpdump 3.7.2, libpcap 0.7.2
> and it worked. It captured all of the traffic from the machine to
> itself, not just that over 127/8, which is what a previous poster
> predicted and I believe what the OP wanted. I have used this in the
> past on Linux, I don't remember if I've used it on other OS's or not.
>
> So, no guarantees, but it's worth a try.
>
> ----Scott.

Thank you very much guys.. It works fine with "-i lo" option.

Allan Wilson

unread,
Feb 12, 2008, 10:18:31 PM2/12/08
to
Barry Margolin wrote:
> In article <ly63xz0...@gfn.org>,
> Scott Gifford <sgif...@suspectclass.com> wrote:
>
>
>>satish....@gmail.com writes:
>>
>>[...]
>>
>>
>>>when socket related process run on the same host, does it mean that
>>>the packets do not go via the network interfaces?
>>
>>If they are going across the loopback interface, you may have to tell
>>tcpdump to read that interface. On Linux the interface is named lo,
>>so you can use "-i lo".
>
>
> AFAIK this doesn't work on most operating systems.
>
b
0 new messages