Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gethostbyname



Hi all,

the implementation of gethostbyname in darwin might be one of the causes of so much grief with lookupd.

If you feed an ip address to gethostbyname its behaviour differs a lot depending on the platform (see Landon Fuller email of 02/02/2002).
Is the darwin implementation reasonable? I would say no.

I played with the hostent command (from Stevens' UNIX Network Programming 1990)

on Darwin, for an IP with reverse lookup:

[ti:Downloads/stevens-1st-E/net] g% ./hostent 193.112.138.2
official host name: mailhost.cb1.com
alias: 2.138.112.193.in-addr.arpa
addr type = 2, addr length = 4
Internet address: 193.112.138.2


on FreeBSD 3.2:
[mailhost:net] g# ./hostent 193.112.138.2
official host name: 193.112.138.2
addr type = 2, addr length = 4
Internet address: 193.112.138.2

so far no problem, I do not care for the extra information.

But what happens if the reverse does not exist?

[ti:Downloads/stevens-1st-E/net] g% ./hostent 172.16.0.1
gethostbyname error for host: 172.16.0.1 (Unknown host)


[mailhost:net] g# ./hostent 172.16.0.1
official host name: 172.16.0.1
addr type = 2, addr length = 4
Internet address: 172.16.0.1

the difference here is that Darwin will block (waiting for DNS timeout), while FreeBSD will return immediately.

This can be very noticeable if, for instance, you are loading firewall rules, where it is quite common to block those reserved addresses from the external interface. Since there is no reverse for those, ipfw will block, and this can add up to quite a long time. A solution would be to make one's nameserver to pretend authority for those zones. But this is not a generally acceptable or implementable solution.

Wouldn't it be a good idea to change this behaviour, as it would relieve lookupd of some useless work?


Giuliano

--
H U M P H
|| |||
software

Java & C++ Server/Client/Human Interface applications on MacOS - MacOS X
http://www.humph.com/
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.