nonamed.8
来自「minix操作系统最新版本(3.1.1)的源代码」· 8 代码 · 共 307 行
8
307 行
.\" These numbers should match those in nonamed.c:.ds ST "two seconds".ds MT "four seconds".ds LT "five minutes".ds HT "one hour".ds NI "256".TH NONAMED 8.SH NAMEnonamed \- not a name daemon, but acts like one.SH SYNOPSIS.B nonamed.RB [ \-qs ].RB [ \-d [\fIlevel\fP]].RB [ \-p.IR port ].SH DESCRIPTION.de SP.if t .sp 0.4.if n .sp...B Nonamedis not a name daemon. It can answer simple queries from.BR /etc/hosts ,but anything else is relayed to a real name daemon..B Nonamedmaintaines a small cache of replies it has seen from a name daemon, and willuse this cache to minimize traffic if the machine is permanently connectedto the Internet, or to answer requests if the machine is often disconnectedfrom the Internet, i.e. a computer at home..PPOn startup.B nonamedsends a simple query to each of its name servers to see if one is up. Thisis repeated every \*(LT in an "at home" situation, or when necessary if thecurrent name daemon doesn't respond. The first name server to answer isused as the current name server to answer queries..PPIf no name servers are found in the DHCP data or.BR /etc/hoststhen only the hosts file is used to answer queries, and any query for a namenot in that file gets a failure response..PP.B Nonamedaccepts both UDP and TCP queries under Minix-vmd. Under standard MINIX 3only UDP queries are accepted. \*(NI relayed UDP queries can be outstandingbefore it forgets where the first one came from..PPUsing the hosts file,.B nonamedcan answer simple DNS queries to translate a host name to an IP address, oran IP address to a host name. Suppose.B /etc/hostslooks like this:.PP.RS.ta +15n.nf10.0.0.1 flotsam.cs.vu.nl\0www10.0.0.2 jetsam.cs.vu.nl.fi.RE.PPThen queries for the host names listed can be answered with the IP addressesto the left of them. An alias like "www" above is seen as a CNAME for thefirst host name on the line, in the same domain as the first host name ifunqualified (no dots). A reverse lookup for an IP address on the left isanswered by the first host name on the right. If more than one match ispossible then all matches are put in the answer, so all IP addresses ofmultihomed hosts can be listed by multiple entries in the hosts file..PPRequests for names like "flotsam.cs.vu.nl.cs.vu.nl" that are often generatedon a domain search for an already fully qualified domain nameare recognized and made to fail. This kludge avoids a lot of unnecessaryrequests to possibly unreachable name servers and client timeouts..PPThe name "localhost" in any domain is given the IP address 127.0.0.1..PP.B Nonamedemploys several timeouts for efficient operation:.PPIf no UDP reply is seen in \*(MT then a new search is started for a nameserver in the hope of finding one that does work.A failing TCP connection will also invoke a search, theTCP connection is then made to the new name server. A client using UDP willretry eventually, a client using TCP will notice nothing but a short delay.If a TCP connection fails after 5 tries then an answer is sought in thehosts file, and failing that the connection is closed..PPAny TCP operation is given \*(LT to show any action before the connection isaborted..PPUDP replies from a name server are put in a cache of by default 8 (16-bitsystem) or 16 kilobytes (32-bit system). New queries arefirst sought in the cache, and if found answered from the cache. An entryin the cache is expired when the resource record with the smallest TTL (timeto live) expires, unless its expire time is artificially extended by the"%stale" parameter (see below). An answer from the cache has all TTLsappropriately lowered, and the AA bit ("answer authoritive") is cleared.Any request answered by stale data is refreshed as soon as.B nonamednotices that one of the external name daemons is reachable..PPData is only cached if it is has "no error" result code, or a "no suchdomain" result code with a SOA record in the name server section, and allrecords have a nonzero TTL. The %stale parameter has no effect on thedecision to cache a result..PPThe cache is rewritten to the cache file \*(LT after a new entry has beenadded. Mere changes to the order in the cache don't cause a rewrite..SS Configuration through /etc/hostsThe real name servers, stale data extension, and cache size can beconfigured by special entries in the hosts file. For example:.PP.RS.ta +\w'172.16.24.3'u+2m +\w'%nameserver'u+2m.nf86400 %ttl # Answers from this file get this TTL2419200 %stale # Stale data may linger on for 4 weeks32768 %memory # 32k cache size10.0.0.1 %nameserver # flotsam172.16.24.3 %nameserver # dns1.example.com172.16.24.6 %nameserver # dns2.example.com.SP10.0.0.1 flotsam.home.example.com\0www10.0.0.2 jetsam.home.example.com.fi.RE.PPIn this example we have two machines, flotsam and jetsam, that are at home.Answers from the hosts file get a TTL of one day, by default this is \*(HT.Normally there is no connection to the Internet, so any stale data in thecache is allowed to linger on for 2419200 seconds (4 weeks) before it isfinally discarded. The cache size is set to 32 kilobytes. The first nameserver is the flotsam. On the flotsam itself this entry is ignored, but thejetsam will now run its requests through flotsam if possible. This meansthat both flotsam and jetsam use the cache of the flotsam. The othernameserver entries are external name servers of the Internet provider..PPIf no nameservers are listed in the hosts file then they are obtained fromdata gathered by DHCP. This is the preferred situation..PPIf the hosts file contains a line that says:.PP.RS.BI include " file".RE.PPThen the current hosts file is closed and the file named is read next..SS "Automatic calling"If your connection to the Internet is set up on demand, either in softwareon the machine that has the modem, or by a special box such as an ISDNrouter, then you need to filter the name server probes that.B nonamedsends out every \*(LT to see if a real name daemon is reachable. Theseprobes need to be recognized as packets that must not trigger a call, andthat must not keep the line up. You can either filter all IP packetsdestined for port 53 decimal (the.B domainport). This may be a bit too much, the first packet out is often a normalDNS request (not a probe), so you may want to do better. A probe by.B nonamedis a nonrecursive request for the name servers of the root domain. Youcan recognize them by looking at the flags, they are all off. Here is atypical probe in hex (twenty octets per line), followed by the names ofinteresting fields, and the octets values you should look for:.PP.RS.nf45 00 00 2D C8 19 00 00 1D 11 53 18 AC 10 66 41 AC 10 18 0300 35 00 35 00 19 79 93 00 00 00 00 00 01 00 00 00 00 00 0000 00 02 00 01.SPip ip ip ip ip ip ip ip ip ip ip ip si si si si di di di disp sp dp dp xx xx xx xx id id fl fl qd qd an an ns ns ar ardn ty ty cl cl.SP45 xx xx xx xx xx xx xx xx 11 xx xx xx xx xx xx xx xx xx xxxx xx 00 35 xx xx xx xx xx xx 00 00 xx xx xx xx xx xx xx xxxx xx xx xx xx.SP.fi(ip = IP header, si = source IP, di = dest IP, sp = source port, dp = destport, id = DNS ID, fl = DNS flags, qd = query count, an = answer count, ns =nameserver count, ar = additional records count, dn = domain (""), ty = type(NS), cl = class (IN).).RE.PPSo if a packet has octets 45, 11, 00 35, and 00 00 at the appropriate placesthen don't let it cause a call. Read the documentation of your software/routerto find out how to do this. Hopefully it is possible to view the contents ofthe packet that triggered the last call. If so you simply let.B nonamedbring up the line once with a probe..SS "Remote information"The program version and name servers it is working with can be obtained with:.PP.RShost \-r \-v \-c chaos \-t txt version.bind. \fIserver\fP.RE.PP.I Serveris the name or IP address of the host whose name server you want to knowthis of.(This call is really an undocumented hack to ask the version numbers of theBIND name daemon. It just had to be implemented for.B nonamedas well.).PPThe % variables in the hosts file can be viewed like this:.PP.RShost \-r \-t a %nameserver. \fIserver\fP.RE.PPDon't forget the dot at the end of the name. %ttl and %stale will be shownas a dotted quad, e.g. 0.36.234.0. The proper value can be computed as 36 *65536 + 234 * 256 + 0 = 2419200..SH OPTIONSThe options are only useful when debugging.BR nonamed ,although it can be very instructive to watch DNS queries being done..TP.BR \-d [\fIlevel\fP]Set debugging level to.I level(by default.BR 1 .)Debug mode 1 makes.B nonameddecode and display the DNS queries and replies that it receives, sends andrelays. In debug mode 2 it prints tracing information about the internaljobs it executes. In debug mode 3 it core dumps when an error causes it toexit. The debugging level may also be increased by 1 at runtime by sendingsignal.B SIGUSR1or turned off (set to 0) with.BR SIGUSR2 ..TP.RB [ \-p " \fIport\fP]Port to listen on instead of the normal.B domainport..TP.RB [ \-q ]Read the cache file with the debug level set to 2, causing its contents tobe printed, then exit..TP.RB [ \-s ]Run single: ignore hosts or cache file, only use the DHCP information. Thisallows another.B nonamedto be run on a different interface to serve a few programs that run there..SH FILES.TP 15n/etc/hostsHosts to address translation table and configuration file..TP/usr/run/nonamed.pidProcess ID of the currently running.BR nonamed ..TP/usr/adm/nonamed.cacheCopy of the cache. Read when the program starts, written \*(LT aftersomething has been added to it, and written when a SIGTERM signal isreceived, which is normally sent at system shutdown..TP/usr/adm/dhcp.cacheData gathered by the DHCP daemon. Among lots of other junk it lists nameservers that we should use..SH "SEE ALSO".BR gethostbyname (3),.BR resolver (3),.BR hosts (5),.BR inet (8),.BR boot (8),.BR inetd (8),.BR dhcpd (8)..SP.BR RFC-1034and.BR RFC-1035 ..SH NOTESDo not use the %stale parameter for a PC that is directly connected to theInternet. You run the risk of getting wrong answers, a risk that is onlyworth taking for a system that is mostly disconnected from the Internet..PPYou can specify one or more remote name servers in.B /etc/resolv.confso that nonamed isn't needed. This will save memory, but you'll lose.BR nonamed 'scache and its "offline" tricks. That's no problem if you can use aneighbouring name daemon on another PC at home..PPThe default cache size seems to be more than enough for normal use, but ifyou do decide to make it larger then don't forget to increase the stack sizeof the program under standard MINIX 3..PPDon't let two.BR nonamed 'sforward queries to each other. They will pingpong a query over thenetwork as fast as they can..SH BUGSThe idea of serving "stale DNS data" will probably make some puristsviolently sick....SH AUTHORKees J. Bot (kjb@cs.vu.nl)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?