I have a dual port ethernet NIC and let's say I have connected both ports in a loop and assigned the following IPs to the 2 ethernet interfaces:

  • eth2 ->
  • eth3 ->

I want to send traffic from 1 of the ports to the other over the physical network, e.g. ping from However, the TCP/IP stack in the Linux kernel recognizes that these two addresses are local and instead sends the traffic to the loopback adapter, so the traffic never hits the physical network.

The closest I have to a solution is Anastasov's send-to-self patch, which unfortunately, has been discontinued since kernel 3.6 so it won't work on Ubuntu 13.10 (kernel 3.11) for me. I've tried rewriting the patch for 3.11, but I can't seem to locate these in the Ubuntu distro:

  • include/linux/inetdevice.h
  • net/ipv4/devinet.c
  • net/ipv4/fib_frontend.c
  • net/ipv4/route.c
  • Documentation/networking/ip-sysctl.txt

Is there a way I can get the send-to-self patch to work, or an alternative solution?

  • In oder to know whether an alternative solution seems to make sense we need to know what the aim of this approach is. – Hauke Laging Mar 29 '14 at 0:09
  • I want to experiment with the NIC to test its performance, e.g. flood it with 14.88 Mpps (10 Gb) of traffic and see if it drops packets, or do a simple ping test from port-to-port without buying another of the exact same NIC. (This is for a particle physics research project, so our budget is limited.) – elleciel Mar 29 '14 at 0:16
  • @Braiam: Yes - found the files there - how should I go about patching my Ubuntu distro with the kernel source though? – elleciel Mar 29 '14 at 0:18

I haven't tried that yet but I guess there are several possibilities for workarounds:

virtual machines

Solve the IP stack problem by separating at least one of the NICs from the host's IP stack: Assign it to a virtual machine. For performance tests this may be rather not desirable, though. But if there is enough CPU power maybe the additional software layer does not become a bottleneck (but how do you know?).

different target addresses

You want the packet transferred on layer 2 only for a NIC performance test, I guess. So you may use IP packets with a different IP address (a non-local one so that the packets are sent over the wire in any case). And then you cheat: You use ip neigh for creating a permanent ARP entry which maps this fake IP address to the other NICs MAC address.

You could even make IP connections that way. But you would have to use iptables with SNAT and DNAT so that both NICs believe they are talking to one of the two necessary fake IPs.

raw access

If you are willing to do some non-trivial programming then you can open raw sockets and create the Ethernet frames yourself. This would probably be the fastest solution.


Create a network namespace and move one of interfaces into it:

ip netns add test
ip link set eth1 netns test

Start a shell in the new namespace:

ip netns exec test bash

Then proceed as if you had two machines. When finished exit the shell and delete the namespace:

ip netns del test
  • This should be marked as the answer. – Andi Jay Mar 15 at 21:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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