Newsgroups: comp.os.linux.networking Date: Wed, 22 Oct 2003 16:14:53 -0700
> I was trying to give an alias name to a foreign host. E.g., in my > /etc/hosts there are 2 entries. > > 127.0.0.1 test2 > google.com gg > > I hope that I can use "gg" as a short cut for google, in my caching > only name server environment. Thanks
/etc/hosts doesn't work that way:
IP_address canonical_hostname aliases
Consult the man page for further information.
ynotssor
> > I've successfully setup my local caching only name server for my dial up > > connection. Also, according to the faq, I add the forward section to the > > dns option section. It also works fine. > > > > However, I noticed that my local setting, which are in my /etc/hosts, > > are no longer valid. How to tell my DNS server to refer to my /etc/hosts > > first, then its cache, and last forward unknown host to my ISP's dns > > server? > > Hmm... to be more precisely: > > I was trying to give an alias name to a foreign host. E.g., in my > /etc/hosts there are 2 entries. > > 127.0.0.1 test2 > google.com gg > > I hope that I can use "gg" as a short cut for google, in my caching only > name server environment. Thanks
127.0.0.1 should always be localhost. If you want to assign your actual hostname to an IP, either use a LAN nic IP, or an extra loopback IP like 127.0.0.2 if you have no real interface that is always up. Your second line is invalid. See 'man hosts' for proper format.
While /etc/hosts may be used by programs that use gethostbyname(), it will not work for things that use DNS only (like nslookup or host command). If you wanted to set up such an alias for google you would need to add a properly configured zone for "gg" to work with your named (like gg. as CNAME for www.google.com. including trailing dots). See the DNS HOWTO. But do not expect something like that in a URL to work for name based virtual hosts, which serve different content based on Host header from browser.
David Efflandt