LinuxSA Mailing list archives
Index:
[thread]
[date]
[subject]
[author]
From: Daryl Tester <dt@picknowl.com.au>
To : linuxsa@linuxsa.org.au
Date: Mon, 17 Apr 2000 09:08:36 +0930
Re: BIND
Richard Sharpe wrote:
> At 10:21 PM 4/16/00 +0930, Don Collins wrote:
>> I think you are supposed to replace 0.0.0.0 with 127.0.0.1 for it
>> to do local nameserver caching correctly.
> The address 0.0.0.0 sometimes means 'this computer'.
In an odd kind of way. While I'm not 100% au fait with the semantics,
I've always understood that '0.0.0.0' binds to the first interface on
a Unix host (where "first" can sometimes be "arbitrary").
For example (under Python):
>>> from socket import socket, AF_INET, SOCK_STREAM
>>> s = socket(AF_INET, SOCK_STREAM)
>>> s.bind('0.0.0.0', 5001)
>>> s.getsockname()
('0.0.0.0', 5001)
>>> s.getpeername()
Traceback (innermost last):
File "<stdin>", line 1, in ?
socket.error: (107, 'Transport endpoint is not connected')
(The exception occurs because we're obviously not connected, so there can't
be a remote connection, as you would expect)
>>> s.connect('0.0.0.0', 23)
>>> s.getsockname()
('127.0.0.1', 5001)
>>> s.getpeername()
('127.0.0.1', 23)
>>> s.close()
Magically, we're now on the local loopback interface. Python's socket
library is just a thin OO wrapping around the traditional C socket
library, so there's no trickery that Python is doing. You could telnet
to 0.0.0.0 and then netstat -tn for the same results.
I've always specified the IP address explicitly, because I've come
across some Unices where it doesn't always use the loopback interface,
but instead binds to some random IP address on a multihomed machine,
and then you start getting really obscure errors from nslookup (pedantic
program that it is).
Regards,
Daryl Tester
--
LinuxSA WWW: http://www.linuxsa.org.au/ IRC: #linuxsa on irc.linux.org.au
To unsubscribe from the LinuxSA list:
mail linuxsa-request@linuxsa.org.au with "unsubscribe" as the subject
Index:
[thread]
[date]
[subject]
[author]
Return to the LinuxSA Mailing List Information Page