Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

closed as unclear what you're asking by Braiam, Anthon, Ramesh, slm Nov 10 '14 at 16:47

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the 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 '14 at 10:41
Have you considered port sniffing? And later maybe tcpreplay? It would not be real-time mirroring though. – LatinSuD Jun 24 '14 at 10:17

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

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