localhost and how it gets Lost

Mark Andrews Mark_Andrews at isc.org
Mon Oct 17 22:59:35 UTC 2005


> 	If one does  dig at localhost  on a certain system using
> bind9.3.1, you get
> 
> 
> 
> ; <<>> DiG 9.3.1 <<>> @localhost localhost
> ; (1 server found)
> ;; global options:  printcmd
> ;; Got answer:
> ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43293
> ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
> 
> ;; QUESTION SECTION:
> ;localhost.			IN	A
> 
> ;; ANSWER SECTION:
> localhost.		608400	IN	A	127.0.0.1
> 
> 	It's there.  it is written as 
> 
> localhost.		608400	IN	A	127.0.0.1
> 
> 	If I use the host command, however, to lookup localhost I get
> a "host not found" error.  The system in question also has a nickname
> of localhost defined in /etc/hosts, but /etc/hosts stops being read
> after bootup.
> 
> 	Shouldn't localhost always return 127.0.0.1?
> 
> A reverse lookup of host 127.0.0.1 does return the absolute domain of
> localhost. so that part is working right.
> 
> 	The system I am working on uses FreeBSD UNIX.  
> Thank you.
> 
> Martin McCormick WB5AGZ  Stillwater, OK 
> OSU Information Technology Division Network Operations Group

	Some of the systems have a localhost zone and other systems don't.

	For most cases you can just have a localhost record in the zones
	on the search path (resolv.conf).  As localhost is unqualified
	the search algorithm comes into play and finds the entries there.
	It's also faster as you don't have to exhaust the search space.

	Don't forget to add both A 127.0.0.1 and AAAA ::1.

	You can add a localhost zone as a fallback if you want.  It will
	prevent accidental query leaks to the root servers.

	@ 3600 SOA @ <contact email>. 1 3600 1200 604800 3600
	@ 3600 NS @
	@ 3600 A 127.0.0.1
	@ 3600 AAAA ::1

	dig by default does not search.

	Mark

; <<>> DiG 9.4.0a1 <<>> +search localhost
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20580
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3

;; QUESTION SECTION:
;localhost.dv.isc.org.		IN	A

;; ANSWER SECTION:
localhost.dv.isc.org.	86400	IN	A	127.0.0.1

;; AUTHORITY SECTION:
dv.isc.org.		86400	IN	NS	bsdi1.dv.isc.org.
dv.isc.org.		86400	IN	NS	drugs.dv.isc.org.

;; ADDITIONAL SECTION:
bsdi1.dv.isc.org.	86400	IN	A	192.168.191.233
drugs.dv.isc.org.	86400	IN	A	192.168.191.236
drugs.dv.isc.org.	86400	IN	AAAA	2001:470:1f00:820:208:74ff:fe9f:eeae

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Oct 18 08:51:21 2005
;; MSG SIZE  rcvd: 154

--
Mark Andrews, ISC
1 Seymour St., Dundas Valley, NSW 2117, Australia
PHONE: +61 2 9871 4742                 INTERNET: Mark_Andrews at isc.org



More information about the bind-users mailing list