Printable Version of Topic

Click here to view this topic in its original format

Linuxhelp _ Technical Support _ Force originating traffic through virtual interface

Posted by: JMx Apr 15 2009, 02:19 PM


I am hoping that some will be able to help with the following issue I am having on what seems to be a derivative of Red Hat.

I want to have an interface eth0, eth1 and eth0:1 on the same subnet:



default gateway

I want to connect to different web servers, say and, but I want to force the originating IP address.

So, I want to get a routing table that looks like:

Dest Mask Gateway Interface eth1 eth0:1 eth0
(plus the usual ones)

So I can quite easily set this up and it works with the physical interfaces. However, I am having difficulties adding the eth0:1 route.

When I do "route add -host gw dev eth0:1" the line appears but with the "eth0" interface.
I do not believe the request will originate from the desired IP address.

Any ideas or pointers would be fantastic.

Thanks in advance.


Posted by: michaelk Apr 15 2009, 04:48 PM

Since eth0 and eth0:1 are on the same subnet I do not not see what you are trying to accomplish.

Posted by: JMx Apr 16 2009, 02:29 AM

As per post I am trying to source the client request from the IP address on eth0:1 and not from the IP address on eth0.

When the application passes the request down to the TCP/IP stack, it will find the first (most specific) match in the kernel routing table and then source it from the interface that is associated with. So I really want a way to force if from the virtual interface rather than the physcial interface.

This is a bit like using a virtual interface and IP address on a cluster.

Maybe I'll need to see if the application can handle the use of raw sockets and bypass the Linux TCP stack.

Powered by Invision Power Board (
© Invision Power Services (