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'm currently testing the routing performance of a hardware device (DUT - Device Under Test) with the following setup (all addresses start with 192.168.):

eth0 (29.2) <---> eth1 (29.1)  eth2 (30.1) <---> eth0 (30.2)
HOST1             |~~~~~~~~~DUT~~~~~~~~~~|       HOST2

Iperf is working just fine in this setup.

However, I want to get rid of HOST2, since another Ethernet card is available on HOST1. This is what I want to achieve:

eth0 (29.2) <---> eth1 (29.1)  eth2 (30.1) <---> eth1 (30.2)
HOST1             |~~~~~~~~~DUT~~~~~~~~~~|       HOST1

How can I configure the Linux routing on HOST1 such that the packets from eth0 to eth1 would go through the DUT and not internally though the kernel?

I'm running Debian with a 3.0 kernel. The iproute2 version is ss110629.

share|improve this question
maybe this will help : serverfault.com/questions/127636/… – migabi Oct 19 '11 at 12:36

Routing combined with snat/dnat should do the trick. The basic idea here is to assign each device on HOST1 a second, "virtual" ip address in a second subnet. The virtual addresses are translated into the actual ones just before/after they leave/enter host1. Use the following setup and direct iperf traffic at or (depending on desired direction of the flow)

IP address assignment


  • eth0 (the "virtual" address for this device will be

  • eth1 (the "virtual" address for this device will be


  • eth1
  • eth2

Static routes


  • via
  • via


  • via
  • via

iptables rules on HOST1


  • SNAT packets destined for to
  • SNAT packets destined for to


  • DNAT packets destined for to
  • DNAT packets destined for to
share|improve this answer

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.