Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have set up an application that listens constantly to a port for network packets, and I would like to create another one that receives the same network packets ( for use as a test bed). Getting the packets sent to 2 different ports on the machine is not an option, so I was wondering if there is a way to set up a "port-mirror". Basically, is there an easy way to make all traffic received on port XXXXX also copy to port XXXXX + 1?

I know there is a similar question here, but I don't quite understand the suggested solution.

Barring that, is there another easy way to simulate network data to test some code with that I am overlooking? Any tips would be appreciated. Thanks!

share|improve this question
Have you read Send duplicate packets over two Internet connections and Copying packets from an interface to another ? It won't get easier than typing a few iptables commands. What is your kernel version? –  Gilles Mar 7 '12 at 0:00
According to uname -rs, I'm on 2.6.32. –  SuperTron Mar 7 '12 at 20:23
Ok then, have you tried the xtables addon? If you have and ran into problems, tell us how far you got, copy-paste your configuration files and the commands you ran and any error message you got. –  Gilles Mar 7 '12 at 21:02
fclose.com/816/port-forwarding-using-iptables your are looking for port forwarding and not mirroring. I bet your question has dozens of duplicate on unix SO and power user –  Kiwy Jan 13 at 10:41
have a look at openvswitch running a TAP openvswitch.org . openvswitch.org/pipermail/discuss/2012-July/007730.html –  rMistero Apr 19 at 3:50

1 Answer 1

You might take a look at nc(1), a network swiss army knife of sorts.

share|improve this answer
How would you manage to get nc duplicate packets? –  lgeorget May 10 '13 at 19:09
It wouldn't. This answer is a red herring. –  Catskul Nov 5 '13 at 23:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.