Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 12-15-2012, 02:42 PM   #1
LQ Newbie
Registered: Jun 2010
Posts: 2

Rep: Reputation: 0
Loop back IP packets to a NIC?

Hi Folks,

In order to do efficient bidirectional network testing, I would like to return all IP packets incoming to e.g. eth0, i.e. sapping source and destination address of all incomming packets and return them to eth0. Is this possible using iptables and NAT? Of course this can be done for a single port in user space but the gut feeling is that it should be possible and more efficient if done in the same way as conventional NAT.

Old 12-17-2012, 03:30 PM   #2
Registered: Mar 2008
Posts: 17,101

Rep: Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552Reputation: 2552
Create a loopback cable? Many loopback issues within a nic are not true full nic tests. The nic actually may never get the packet or only into half the nic and then returned to system.
Old 12-19-2012, 11:18 AM   #3
LQ Newbie
Registered: Jun 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Well, a loopback cable is not really IP-savy.

I tried:

iptables -t nat -A PREROUTING -p tcp -m tcp -d -j DNAT --to-destination

where is the reflector machine (the one I am issuing the command on) and is the machine to receive the redirected packets, i.e. the sender. However, no success... (to test I telnet and would expect to connect to

Any better ideas or do I miss something?
Old 01-04-2013, 03:17 AM   #4
Registered: Aug 2005
Location: Malaysia - KULMY / CNXTH
Distribution: Slackware, Fedora, FreeBSD, Sun O/S 5.10, CentOS
Posts: 780
Blog Entries: 6

Rep: Reputation: 75
IMO you need to do redirect port or call port forward for each program,
eg, telnet run on port 23 and create iptables rules this way

$IPT -t nat -I PREROUTING -p tcp -d --dport 23 -j DNAT --to
$IPT -t nat -I PREROUTING -p tcp -d --dport 23 -j DNAT --to
try it


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Packets go out one tunnel, come back another, then are dropped Atomicmongoose Linux - Networking 2 12-06-2010 07:35 PM
How to adjust routing of external packets to one NIC instead of another NIC? rfreiberger Linux - Newbie 3 04-14-2010 02:20 PM
loop packets out tap0 like an access point cr13 Linux - Networking 0 07-12-2007 03:42 AM
Forwarding packets between two NIC madhavann Linux - Networking 6 02-17-2006 11:23 PM
Why one nic accept packets destined for second nic gibcomp Linux - Networking 2 09-09-2004 01:21 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 12:13 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration