RE: route & bind

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

 



Martijn

Thanks for the information, but can you further describe how to config route to let it pay attention to the source ip address?

Following your idea, I checked the SOL_DONTROUTE & MSG_DONTROUTE, and write a sample udp program that use MSG_DONTROUTE,
but still don't work.

Searching the Internet, I find below article by Neil Brown, http://www.cs.helsinki.fi/linux/linux-kernel/2003-07/0711.html.
And I think what I am looking for is very similar to that describled in this article, that is applications have full control on sending which packet over which interface, 
using no routing information at all.

So is this possible on linux, for both udp & tcp, and in a not-very-complicated way?

Thanks, Xia Weizhong

-----Original Message-----
From: Martijn van Oosterhout [mailto:kleptog@svana.org]
Sent: 2004?1?15? 14:54
To: Xia Wei-Zhong-W20079
Cc: linux-net@vger.kernel.org
Subject: Re: route & bind


On Thu, Jan 15, 2004 at 02:40:49PM +0800, Xia Wei-Zhong-W20079 wrote:
> Hi
> 
> This can be a silly question, but I still want to hear what you will say.
> 
> For an IP host with multiple network interfaces, can I only use bind to send out packets? 
> I mean by bind a socket to the local IP address of an interface.
> 
> I test this on my linux box, seems it does not work.
> 
> So what does the bind system call really do? and do you know any way other than 
> setting up the routes to make the IP packet go through the correct interface?

The bind system call sets the source IP address (and possibly the port) of the
outgoing packets. This will be the address used by the other end to send
replies. It has absolutly no affect on the routing unless the routing is
configured to pay attention to the source ip address. Which is definitly not
the default.

If you don't use bind, the kernel will pick an IP address for you, usually
based upon the route used to send the packet.

So the answer to your question is, use the routing tables to direct the
packets the way you want. If you want to have the source ip address affect
that, configure it that way.

-- 
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> (... have gone from d-i being barely usable even by its developers
> anywhere, to being about 20% done. Sweet. And the last 80% usually takes
> 20% of the time, too, right?) -- Anthony Towns, debian-devel-announce
-
: 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