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'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
1  
maybe this will help : serverfault.com/questions/127636/… –  migabi Oct 19 '11 at 12:36
add comment

1 Answer

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 192.168.9.2 or 192.168.10.2 (depending on desired direction of the flow)

IP address assignment

HOST1

  • eth0 192.168.29.2/24 (the "virtual" address for this device will be 192.168.9.2)

  • eth1 192.168.30.2/24 (the "virtual" address for this device will be 192.168.10.2)

DUT

  • eth1 192.168.29.2/24
  • eth2 192.168.30.2/24

Static routes

HOST1

  • 192.168.10.2/24 via 192.168.29.1
  • 192.168.9.2/24 via 192.168.30.1

DUT

  • 192.168.9.2/24 via 192.168.29.2
  • 192.168.10.3/24 via 192.168.30.2

iptables rules on HOST1

POSTROUTING

  • SNAT packets destined for 192.168.9.2 to 192.168.10.2
  • SNAT packets destined for 192.168.10.2 to 192.168.9.2

PREROUTING

  • DNAT packets destined for 192.168.9.2 to 192.168.29.2
  • DNAT packets destined for 192.168.10.2 to 192.168.30.2
share|improve this answer
add comment

Your Answer

 
discard

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.