# arp -s fnord 00:00:c0:a1:42:e0 pub
The proxy ARP entry may be removed again by invoking:
# arp -d fnord
Chapter 6. Name Service and Resolver Configuration
As we discussed in Chapter 2, Issues of TCP/IP Networking, TCP/IP networking may rely on different schemes to convert names into addresses. The simplest way is a host table stored in /etc/hosts . This is useful only for small LANs that are run by one single administrator and otherwise have no IP traffic with the outside world. The format of the hosts file has already been described in Chapter 5, Configuring TCP/IP Networking.
Alternatively, you can use the Berkeley Internet Name Domain service (BIND) for resolving hostnames to IP addresses. Configuring BIND can be a real chore, but once you've done it, you can easily make changes in the network topology. On Linux, as on many other Unixish systems, name service is provided through a program called named. At startup, it loads a set of master files into its internal cache and waits for queries from remote or local user processes. There are different ways to set up BIND, and not all require you to run a name server on every host.
This chapter can do little more than give a rough sketch of how DNS works and how to operate a name server. It should be sufficient if you have a small LAN and an Internet uplink. For the most current information, you may want to check the documentation contained in the BIND source package, which supplies manual pages, release notes, and the BIND Operator's Guide (BOG). Don't let this name scare you off; it's actually a very useful document. For a more comprehensive coverage of DNS and associated issues, you may find DNS and BIND by Paul Albitz and Cricket Liu (O'Reilly) a useful reference. DNS questions may be answered in a newsgroup called comp.protocols.tcp-ip.domains. For technical details, the Domain Name System is defined by RFC numbers 1033, 1034, and 1035.
The term resolver refers not to a special application, but to the resolver library. This is a collection of functions that can be found in the standard C library. The central routines are gethostbyname(2) and gethostbyaddr(2) , which look up all IP addresses associated with a host name, and vice versa. They may be configured to simply look up the information in hosts , to query a number of DNS name servers, or to use the hosts database of Network Information Service (NIS).
The resolver functions read configuration files when they are invoked. From these configuration files, they determine what databases to query, in which order, and other details relevant to how you've configured your environment. The older Linux standard library, libc, used /etc/host.conf as its master configuration file, but Version 2 of the GNU standard library, glibc, uses /etc/nsswitch.conf . We'll describe each in turn, since both are commonly used.
The /etc/host.conf tells the older Linux standard library resolver functions which services to use, and in what order.
Options in host.conf must appear on separate lines. Fields may be separated by white space (spaces or tabs). A hash sign ( # ) introduces a comment that extends to the next newline. The following options are available:
order
This option determines the order in which the resolving services are tried. Valid options are bind for querying the name server, hosts for lookups in /etc/hosts , and nis for NIS lookups. Any or all of them may be specified. The order in which they appear on the line determines the order in which the respective services are tried.
multi
multi takes on or off as options. This determines if a host in /etc/hosts is allowed to have several IP addresses, which is usually referred to as being "multi-homed." The default is off. This flag has no effect on DNS or NIS queries.
nospoof
As we'll explain in the section "Reverse Lookups", DNS allows you to find the hostname belonging to an IP address by using the in-addr.arpa domain. Attempts by name servers to supply a false hostname are called spoofing . To guard against this, the resolver can be configured to check whether the original IP address is in fact associated with the obtained hostname. If not, the name is rejected and an error is returned. This behavior is turned on by setting nospoof on.
alert
This option takes on or off as arguments. If it is turned on, any spoof attempts will cause the resolver to log a message to the syslog facility.
trim
This option takes an argument specifying a domain name that will be removed from hostnames before lookup. This is useful for hosts entries, for which you might only want to specify hostnames without a local domain. If you specify your local domain name here, it will be removed from a lookup of a host with the local domain name appended, thus allowing the lookup in /etc/hosts to succeed. The domain name you add must end with the (.) character (e.g.,: linux.org.au.) if trim is to work correctly.
trim options accumulate; you can consider your host as being local to several domains.
A sample file for vlager is shown in Example 6.1.
Example 6.1: Sample host.conf File
# /etc/host.conf
# We have named running, but no NIS (yet)
order bind,hosts
# Allow multiple addrs
multi on
# Guard against spoof attempts
nospoof on
# Trim local domain (not really necessary).
trim vbrew.com.
Resolver environment variables
The settings from host.conf may be overridden using a number of environment variables:
RESOLV_HOST_CONF
This variable specifies a file to be read instead of /etc/host.conf .
RESOLV_SERV_ORDER
This variable overrides the order option given in host.conf . Services are given as hosts , bind , and nis , separated by a space, comma, colon, or semicolon.
RESOLV_SPOOF_CHECK
This variable determines the measures taken against spoofing. It is completely disabled by off . The values warn and warn off enable spoof checking by turning logging on and off, respectively. A value of * turns on spoof checks, but leaves the logging facility as defined in host.conf .
RESOLV_MULTI
This variable uses a value of on or off to override the multi options from host.conf .
RESOLV_OVERRIDE_TRIM_DOMAINS
This variable specifies a list of trim domains that override those given in host.conf . Trim domains were explained earlier when we discussed the trim keyword.
RESOLV_ADD_TRIM_DOMAINS
This variable specifies a list of trim domains that are added to those given in host.conf .
Version 2 of the GNU standard library includes a more powerful and flexible replacement for the older host.conf mechanism. The concept of the name service has been extended to include a variety of different types of information. Configuration options for all of the different functions that query these databases have been brought back into a single configuration file; the nsswitch.conf file.
The nsswitch.conf file allows the system administrator to configure a wide variety of different databases. We'll limit our discussion to options that relate to host and network IP address resolution. You can easily find more information about the other features by reading the GNU standard library documentation.
Читать дальше