etcresolv.conf


/etc/resolv.conf

The resolver helps map host names to IP addresses, and vice versa, and is configured via /etc/resolv.conf. While OpenBSD's /etc/resolv.conf supports a wide variety of options, two basic sorts of entry are sufficient to get the system working properly: a domain or domain search list, and nameserver entries.

Domain or Domain Search Settings

When you're working on machines on your own network, you don't want to have to type the whole hostname. If you have 30 web servers, after all, typing "ssh www23.mycompany.com" gets old. The "domain" and "search" keywords tell the resolver the default domain.

Specifying the Local Domain

The "domain" keyword tells the resolver one domain to check. For example, to specify AbsoluteOpenBSD.com as the local domain, enter this:

 domain    AbsoluteOpenBSD.com 

Once the local domain is specified, any command that would ordinarily require a domain name, but doesn't get one, will assume that it's within AbsoluteOpenBSD.com instead. Were I to type "ping www", the resolver would append the domain name to the query and tell ping(8) to try the IP address of www.AbsoluteOpenBSD.com.

Specifying a List of Domains

Alternatively, I can use the "search" keyword to specify a list of domains to try. I own several domains and use them for different parts of my work, and I might want the system to try them all.

 search AbsoluteOpenBSD.com blackhelicopters.org stenchmaster.com 

In this case, the resolver will check all three of these domain names in the order they appear, until it finds a match. For example, if I enter "ping petulance" it will try to find petulance.AbsoluteOpenBSD.org. If that fails, it will search for petulance.blackhelicopters.org, the next domain in the list. Finally, it will check for petulance.stenchmaster.com. If no such host exists in any of these domains, the command will eventually fail.

The Nameserver List

Now that the resolver knows which domains to check by default, you need to tell it which nameservers to use. Nameservers should each be listed on a single line, in the order of preference. The nameservers will be tried in order.

 nameserver 127.0.0.1 nameserver 192.168.170.3 nameserver 209.88.133.4 

Note that the first entry on this list is the loopback IP, 127.0.0.1 and means "localhost." You'll need this entry if the machine is a nameserver, because it tells the resolver to look at the local machine. While in some instances you might not want to use the local nameserver, in most cases it's a waste of network bandwidth to do otherwise.

With a domain or search keyword and a nameserver list, your machine will be able to match host names and IP addresses. For more on /etc/resolv.conf, check resolv.conf(5).




Absolute Openbsd(c) Unix for the Practical Paranoid
Absolute OpenBSD: Unix for the Practical Paranoid
ISBN: 1886411999
EAN: 2147483647
Year: 2005
Pages: 298

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net