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
Attachment:
pgp00143.pgp
Description: PGP signature