How to force a connection to go out of machine?

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Thu May 16 21:23:43 UTC 2013


On Thu, May 16, 2013 at 02:14:53PM -0400, William Park wrote:
> I'm getting 2MB/s wireless throughput on N750 dual-band router.  So,
> something is wrong somewhere.  In order to test more throughly, I need
> to force a connection to actually go out of the machine.  How do I do
> that?
> 
> Say, I have 2 interfaces connected to a router:
>     - wlan0 = 192.168.1.3 -- wireless
>     - eth0 = 192.168.1.100  -- long cable
> Normally, the machine simply route the connection internally.  But, I
> need it to go to the router on "wlan0" and then back to me on "eth0",
> and vice versa.

If your kernel is 3.x or so, then this might do what you want.  Example is
from the git commit that added the feature.

commit eed2a12f1ed9aabf0676f4d0db34aad51976c5c6
Author: Mahesh Bandewar <maheshb-hpIqsD4AKlfQT0dZR+AlfA at public.gmane.org>
Date:   Wed May 4 15:30:11 2011 +0000

     net: Allow ethtool to set interface in loopback mode.

     This patch enables ethtool to set the loopback mode on a given interface.
     By configuring the interface in loopback mode in conjunction with a policy
     route / rule, a userland application can stress the egress / ingress path
     exposing the flows of the change in progress and potentially help developer(s)
     understand the impact of those changes without even sending a packet out
     on the network.

     Following set of commands illustrates one such example -
         a) ip -4 addr add 192.168.1.1/24 dev eth1
         b) ip -4 rule add from all iif eth1 lookup 250
         c) ip -4 route add local 0/0 dev lo proto kernel scope host table 250
         d) arp -Ds 192.168.1.100 eth1
         e) arp -Ds 192.168.1.200 eth1
         f) sysctl -w net.ipv4.ip_nonlocal_bind=1
         g) sysctl -w net.ipv4.conf.all.accept_local=1
         # Assuming that the machine has 8 cores
         h) taskset 000f netserver -L 192.168.1.200
         i) taskset 00f0 netperf -t TCP_CRR -L 192.168.1.100 -H 192.168.1.200 -l 30

Hope that makes sense.

It basicly allows you to send packets with a source IP that doesn't belong
to the box, and to receiver packets claiming to be from the box itself.

Nifty magic.

Normally you don't want a system to allow this, hence the need for
sysctl changes.

-- 
Len Sorensen
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list