Source IP / INADDR_ANY
- From: "André Hänsel" <andre@xxxxxxxx>
- Date: 5 Mar 2007 18:18:35 -0800
Hi,
I'm wondering which IP address is used as the source IP of a TCP
connection.
I came across this issue when I was debugging problems with a box with
several IP aliases that could not connect to another box where it is
identified by its IP. (mysql_connect)
To connect libmysql.c calls socket() and then connect(), without any
bind() inbetween.
In ip(7) I found:
"When listen(2) or connect(2) are called on an unbound socket, it is
automatically bound to a random free port with the local address set
to INADDR_ANY."
So what does this INADDR_ANY mean? I guess, when there are multiple
interfaces but they point to different routes, the one which points to
my destination address is selected. (I did not verify this behaviour
yet.)
But what if there are just a few IP aliases that point all to the same
net. Googling for INADDR_ANY gave me (although unproven):
"When sending, a socket bound with INADDR_ANY binds to the default IP
address, which is that of the lowest-numbered interface."
However this is not the behaviour I see on my box, unless the
"interface numbering" is secretly rotated. ;)
Regards,
André
.
- Follow-Ups:
- Re: Source IP / INADDR_ANY
- From: Tauno Voipio
- Re: Source IP / INADDR_ANY
- Prev by Date: Re: setup eth0 in TurboLinux
- Next by Date: Re: [ot] same ip, different subnet mask.
- Previous by thread: [ot] same ip, different subnet mask.
- Next by thread: Re: Source IP / INADDR_ANY
- Index(es):
Relevant Pages
|