Using tap0 with Tcpreplay

This thread on the Wireshark mailing list brought up the issue of not being able to use Tcpreplay with the loopback interface on FreeBSD, e.g.:

orr:/root# tcpreplay -i lo0 /data/lpc/1.lpc
sending out lo0
processing file: /data/lpc/1.lpc
Unable to send packet: Address family not supported by protocol family

Here is an alternative: use tap0.

orr:/root# ifconfig tap0
ifconfig: interface tap0 does not exist
orr:/root# dd if=/dev/tap0 of=/dev/null bs=1500 &
[1] 9468
orr:/root# ifconfig tap0 up
orr:/root# ifconfig tap0
tap0: flags=8843 mtu 1500
inet6 fe80::2bd:1dff:fe2d:4d00%tap0 prefixlen 64 scopeid 0x5
ether 00:bd:1d:2d:4d:00
Opened by PID 9468
orr:/root# tcpreplay -i tap0 /data/lpc/1.lpc
sending out tap0
processing file: /data/lpc/1.lpc
Actual: 71 packets (6860 bytes) sent in 6.15 seconds
Rated: 1115.0 bps, 0.01 Mbps/sec, 11.54 pps

In a second window, sniff with Tcpdump or whatever program you want:

orr:/root# tcpdump -n -i tap0 -s 1515
tcpdump: WARNING: tap0: no IPv4 address assigned
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on tap0, link-type EN10MB (Ethernet), capture size 1515 bytes
10:25:16.211443 00:0d:28:6c:f5:4f > 01:00:0c:cc:cc:cd sap aa ui/C
10:25:17.567563 IP >
P 1293772727:1293772779(52) ack 478395919 win 64444

I discussed this in my first book and in my network security monitoring class.


Netfortius said…
Wow! That was fast and comprehensive - thank you, Richard.

Interestingly enough, that does not seem to work on my BSD "flavor" (which is at the basis of MacOSX):

pwrbk:~/scm$ sudo dd if=/dev/tap0 of=/dev/null bs=1500 &
[1] 3398
pwrbk:~/scm$ dd: /dev/tap0: No such file or directory

[1]+ Exit 1 sudo dd if=/dev/tap0 of=/dev/null bs=1500

... thus, consequently:

pwrbk:~/remote-mac scm$ ifconfig tap0 up
ifconfig: interface tap0 does not exist

Do you have a tap0 in your BSD /dev ?

Thanks again,

MacOS X is not a BSD "flavor." Mac OS X uses BSD userland tools. The kernel is Mach-based.
Netfortius said…
... just following up on my own comment ;) Should have googled harder before posting :(

This may work - I will give it a shot right now:

Thanks again, Richard!
Anonymous said…
thanks, it work from my BSD
but how to adding the device imto permanent device
so if my computer reboot not to write the command first

Popular posts from this blog

Zeek in Action Videos

MITRE ATT&CK Tactics Are Not Tactics

New Book! The Best of TaoSecurity Blog, Volume 4