[NTLUG:Discuss] can I use *.domaon.com in /etc/hosts?

Greg Edwards greg at nas-inet.com
Tue Dec 3 08:17:28 CST 2002


Bug Hunter wrote:
> 
>   you can also do this:
> 
> 192.168.1.9 foo.1
> 192.168.1.9 foo.2
> 192.168.1.9 foo.3
> 192.168.1.9 foo.4
> 
> 
>>Quoting m m <llliiilll at hotmail.com>:
>>
>>
>>>Hi All:
>>>
>>>I do think that we can use *.domaon.com in /etc/hosts, right?
>>>what is the way too define/assign multiple host name in /etc/hosts except 
>>>use DNS or NIS.
>>>
>>>thanks
>>
>>If I understand the question, you can do this:
>>
>>192.168.1.9 nighthawk.dyndns.org nightscape.shadowland.net nightscape
>>
>>and similar things.  This is what I've done for my web/mail/database server
>>that sits behind the firewall.
>>
>>yes. that is my question. what about if you have 1000 host/domain name?
>>again, do not use DNS or other application, use /etc/hosts files only.
>>
>>what I want to know is if we can use * in /etc/hosts file?
>>
>>
>>Ed
>>

Sorry, as stated by others, /etc/hosts does not use wildcards.  For that 
kind of volume in host names I'd strongly recommend that you don't use 
/etc/hosts.

A couple problems you'll face include keeping copies on each machine 
that needs to access these addresses.  You'll pay a performance hit on 
lookups.  A DNS server will cache names and addresses where the resolver 
won't.  Every time a search is needed from the /etc/hosts file it must 
be read from the top to the requested name.  When a dozen or so names 
are checked it's no big deal.  When you've got 1000 names and the 
machine your really looking for is the last then you can imagine what 25 
accesses will cost in processing time.

I think a good rule of thumb is to only have physical hosts in the 
/etc/hosts file with an alias on only 1 nic for that host.  If you have 
a network that will be growing or already has a half dozen hosts run an 
NIS server and only have 1 /etc/hosts table (on the server) to maintain. 
  If you want to keep Internet and intranet addresses from mixing run 2 
DNS servers.  Make one server master to the outside and one master to 
the inside.  They can have the same host names in them with different 
IPs to allow intranet access without knowledge of the Internet addresses.

-- 
Greg Edwards
New Age Software, Inc.
http://www.nas-inet.com





More information about the Discuss mailing list