RE: Forcing packets through an interface in a multihomed machine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, Gilad

I remember that setsockopt(SO_BINDTODEVICE) will need root privilege. so can the hijack you mentioned work?

Regards, xwz

-----Original Message-----
From: linux-net-owner@vger.kernel.org
[mailto:linux-net-owner@vger.kernel.org]On Behalf Of Gilad Ben-Yossef
Sent: 2004å1æ26æ 20:33
To: C Jagadish; linux-net@vger.kernel.org
Subject: Re: Forcing packets through an interface in a multihomed
machine


Howdie,

On Monday 26 January 2004 13:49, C Jagadish wrote:
> Hi,
>
>         How do I route packets to destination "A" through an interface
>         differnet from the entry in the routing table?     ( In RedHat
> Linux 7.2)

I don't think you can do this exactly.

However, you can limit a packet to go through a specific interface assuming 
you have a route through it even though normally this will not be the route 
chosen, by using the SO_BINDTODEVICE socket options.

Attached is small example that creates a shared library that if preloaded 
(using LD_PRELOAD) will hijack all the socket() system calls and set this 
option on all sockets created, thus enabling to limit any executable to use a 
specific interface in a similar fashion to way the ping program -r option 
does for ping.

It's a rather crude example, if you plan to make real use of it make sure to 
handle error conditions in saner fashion. A better way to choose the 
interface to route packets to is also a good idea :-)


Cheers,
Gilad


-- 
Gilad Ben-Yossef <gilad@codefidence.com>
Codefidence. A name you can trust (tm)
http://www.codefidence.com

"The future is here,  it's just not evenly distributed yet." 
	- William Gibson
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux