ndb 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. .TH NDB 8
  2. .SH NAME
  3. query, ipquery, mkhash, mkdb, mkhosts, cs, csquery, dns, dnsquery, dnsdebug \- network database
  4. .SH SYNOPSIS
  5. .B ndb/query
  6. [
  7. .B -f
  8. .I dbfile
  9. ]
  10. .I "attr value"
  11. [
  12. .I rattr
  13. ]
  14. .br
  15. .B ndb/ipquery
  16. .I "attr value"
  17. .I rattr...
  18. .br
  19. .B ndb/mkhash
  20. .I "file attr"
  21. .br
  22. .B ndb/mkdb
  23. .br
  24. .B ndb/mkhosts
  25. [
  26. .I domain
  27. [
  28. .I dbfile
  29. ] ]
  30. .br
  31. .B ndb/cs
  32. [
  33. .B -n
  34. ] [
  35. .B -f
  36. .I dbfile
  37. ] [
  38. .B -x
  39. .I netmtpt
  40. ]
  41. .br
  42. .B ndb/csquery
  43. [
  44. .B -s
  45. ]
  46. [
  47. .I server
  48. [
  49. .I addr...
  50. ]
  51. ]
  52. .br
  53. .B ndb/dns
  54. [
  55. .B -norRs
  56. ] [
  57. .B -a
  58. .I maxage
  59. ] [
  60. .B -f
  61. .I dbfile
  62. ] [
  63. .B -N
  64. .I target
  65. ] [
  66. .B -x
  67. .I netmtpt
  68. ] [
  69. .B -z
  70. .I program
  71. ]
  72. .br
  73. .B ndb/dnsquery
  74. .br
  75. .B ndb/dnsdebug
  76. [
  77. .B -rx
  78. ] [
  79. .B -f
  80. .I dbfile
  81. ] [ [
  82. .BI @ server
  83. ]
  84. .I domain-name
  85. [
  86. .I type
  87. ] ]
  88. .SH DESCRIPTION
  89. The network database holds administrative information used by
  90. network programs such as
  91. .IR dhcpd (8),
  92. .IR ipconfig (8),
  93. .IR con (1),
  94. etc.
  95. .PP
  96. .I Ndb/query
  97. searches the database for an attribute of type
  98. .I attr
  99. and value
  100. .IR value .
  101. If
  102. .I rattr
  103. is not specified, all entries matched by the search are returned.
  104. If
  105. .I rattr
  106. is specified, the value of the first pair with attribute
  107. .I rattr
  108. of all the matched entries is returned.
  109. .PP
  110. .I Ndb/ipquery
  111. uses
  112. .I ndbipinfo
  113. (see
  114. .IR ndb (2))
  115. to search for the values of the attributes
  116. .I rattr
  117. corresponding to the system
  118. with entries of attribute type
  119. .I attr
  120. and
  121. value
  122. .IR value .
  123. .SS "Database maintenance"
  124. .I Ndb/mkhash
  125. creates a hash file for all entries with attribute
  126. .I attr
  127. in database file
  128. .IR file .
  129. The hash files are used by
  130. .I ndb/query
  131. and by the ndb library routines.
  132. .PP
  133. .I Ndb/mkdb
  134. is used in concert with
  135. .IR awk (1)
  136. scripts to convert
  137. uucp systems files and IP host files
  138. into database files.
  139. It is very specific to the situation at Murray Hill.
  140. .PP
  141. When the database files change underfoot,
  142. .I ndb/cs
  143. and
  144. .I ndb/dns
  145. track them properly. Nonetheless, to keep the database searches efficient
  146. it is necessary to run
  147. .I ndb/mkhash
  148. whenever the files are modified.
  149. It may be profitable to control this by a frequent
  150. .IR cron (8)
  151. job.
  152. .PP
  153. .I Ndb/mkhosts
  154. generates a BSD style
  155. .BR hosts ,
  156. .BR hosts.txt ,
  157. and
  158. .B hosts.equiv
  159. files from an ndb data base file specified on the
  160. command line (default
  161. .BR /lib/ndb/local ).
  162. For local reasons the files are called
  163. .BR hosts.1127 ,
  164. .BR astro.txt ,
  165. and
  166. .BR hosts.equiv .
  167. .SS "Connection service"
  168. .I Ndb/cs
  169. is a server used by
  170. .IR dial (2)
  171. to translate network names.
  172. It is started at boot time.
  173. It finds out what networks are configured
  174. by looking for
  175. .B /net/*/clone
  176. when it starts.
  177. It can also be told about networks by writing to
  178. .B /net/cs
  179. a message of the form:
  180. .IP
  181. .B "add net1 net2 ..."
  182. .PP
  183. .I Ndb/cs
  184. also sets the system name in
  185. .B /dev/sysname
  186. if it can figure it out.
  187. The options are:
  188. .TF -n
  189. .TP
  190. .B -f
  191. supplies the name of the data base file to use,
  192. default
  193. .BR /lib/ndb/local .
  194. .TP
  195. .B -n
  196. causes cs to do nothing but set the system name.
  197. .TP
  198. .B -x
  199. specifies the mount point of the
  200. network.
  201. .PD
  202. .PP
  203. .I Ndb/csquery
  204. can be used to query
  205. .I ndb/cs
  206. to see how it resolves addresses.
  207. .I Ndb/csquery
  208. prompts for addresses and prints out what
  209. .I ndb/cs
  210. returns.
  211. .I Server
  212. defaults to
  213. .BR /net/cs .
  214. If any
  215. .I addrs
  216. are specified,
  217. .I ndb/csquery
  218. prints their translations and immediately exits.
  219. The exit status will be nil only if all addresses
  220. were successfully translated
  221. The
  222. .B -s
  223. flag sets exit status without printing any results.
  224. .SS "Domain name service"
  225. .I Ndb/dns
  226. is a server used by
  227. .I ndb/cs
  228. and by remote systems to translate Internet domain names.
  229. .I Ndb/dns
  230. is started at boot time.
  231. By default
  232. .I dns
  233. serves only requests written to
  234. .BR /net/dns .
  235. Programs must
  236. .I seek
  237. to offset 0 before reading or writing
  238. .B /net/dns
  239. or
  240. .BR /net/cs .
  241. The options are:
  242. .TF -n
  243. .TP
  244. .B -a
  245. sets the maximum time in seconds that an unreferenced
  246. domain name will remain cached.
  247. The default is one hour (3600).
  248. .TP
  249. .B -f
  250. supplies the name of the data base file to use,
  251. default
  252. .BR /lib/ndb/local .
  253. .TP
  254. .B -n
  255. whenever a zone that we serve changes, send UDP NOTIFY
  256. messages to any dns slaves for that zone
  257. (see the
  258. .L dnsslave
  259. attribute below).
  260. .TP
  261. .B -N
  262. sets the goal for the number of domain names cached to
  263. .I target
  264. rather than the default of 8,000.
  265. .TP
  266. .B -r
  267. send `recursive' queries, asking the other servers
  268. to complete lookups.
  269. .TP
  270. .B -R
  271. ignore the `recursive' bit on incoming requests.
  272. Do not complete lookups on behalf of remote systems.
  273. .TP
  274. .B -s
  275. also cache DNS answers in memory,
  276. and answer domain requests sent to UDP port 53.
  277. .TP
  278. .B -x
  279. specifies the mount point of the
  280. network.
  281. .TP
  282. .B -z
  283. whenever we receive a UDP NOTIFY message, run
  284. .I program
  285. with the domain name of the area as its argument.
  286. .PD
  287. .PP
  288. When the
  289. .B -r
  290. option is specified, the servers used come from the
  291. .I dns
  292. attribute in the database. For example, to specify a set of dns servers that
  293. will resolve requests for systems on the network
  294. .IR mh-net :
  295. .IP
  296. .EX
  297. ipnet=mh-net ip=135.104.0.0 ipmask=255.255.0.0
  298. dns=ns1.cs.bell-labs.com
  299. dns=ns2.cs.bell-labs.com
  300. dom=ns1.cs.bell-labs.com ip=135.104.1.11
  301. dom=ns2.cs.bell-labs.com ip=135.104.1.12
  302. .EE
  303. .LP
  304. The server for a domain is indicated by a database entry containing
  305. both a
  306. .I dom
  307. and a
  308. .I ns
  309. attribute.
  310. .IP
  311. .EX
  312. dom=
  313. ns=A.ROOT-SERVERS.NET
  314. ns=B.ROOT-SERVERS.NET
  315. ns=C.ROOT-SERVERS.NET
  316. dom=A.ROOT-SERVERS.NET ip=198.41.0.4
  317. dom=B.ROOT-SERVERS.NET ip=128.9.0.107
  318. dom=C.ROOT-SERVERS.NET ip=192.33.4.12
  319. .EE
  320. .LP
  321. The last three lines provide a mapping for the
  322. server names to their ip addresses. This is only
  323. a hint and will be superseded from whatever is learned
  324. from servers owning the domain.
  325. .SS "Authoritative Name Servers"
  326. You can also serve a subtree of the domain name space from the local
  327. database. You indicate subtrees that you would like to serve by adding an
  328. .B soa=
  329. attribute to the root entry.
  330. For example, the Bell Labs CS research domain is:
  331. .IP
  332. .EX
  333. dom=cs.bell-labs.com soa=
  334. refresh=3600 ttl=3600
  335. ns=plan9.bell-labs.com
  336. ns=ns1.cs.bell-labs.com
  337. ns=ns2.cs.bell-labs.com
  338. mb=presotto@plan9.bell-labs.com
  339. mx=mail.research.bell-labs.com pref=20
  340. mx=plan9.bell-labs.com pref=10
  341. dnsslave=nslocum.cs.bell-labs.com
  342. dnsslave=vex.cs.bell-labs.com
  343. .EE
  344. .LP
  345. Here, the
  346. .B mb
  347. entry is the mail address of the person responsible for the
  348. domain (default
  349. .BR postmaster ).
  350. The
  351. .B mx
  352. entries list mail exchangers for the domain name and
  353. .B refresh
  354. and
  355. .B ttl
  356. define the area refresh interval and the minimum TTL for
  357. records in this domain.
  358. The
  359. .B dnsslave
  360. entries specify slave DNS servers that should be notified
  361. when the domain changes. The notification also requires
  362. the
  363. .B -n
  364. flag.
  365. .SS "Reverse Domains"
  366. You can also serve reverse lookups (returning the name that
  367. goes with an IP address) by adding an
  368. .B soa=
  369. attribute to the entry defining the root of the reverse space.
  370. For example, to provide reverse lookup for all addresses in
  371. starting with 135.104 you must have a record like:
  372. .IP
  373. .EX
  374. dom=104.135.in-addr.arpa soa=
  375. refresh=3600 ttl=3600
  376. ns=plan9.bell-labs.com
  377. ns=ns1.cs.bell-labs.com
  378. ns=ns2.cs.bell-labs.com
  379. .EE
  380. .LP
  381. Notice the form of the reverse address, i.e., it's the bytes of the
  382. address range you are serving reversed and with
  383. .B .in-addr.arpa
  384. appended. This is a standard form for a domain name in an IPv4 PTR record.
  385. .PP
  386. If such an entry exists in the database, reverse addresses will
  387. automatically be generated from any IP addresses in the database
  388. that are under this root. For example
  389. .IP
  390. .EX
  391. dom=ns1.cs.bell-labs.com ip=135.104.1.11
  392. .EE
  393. .LP
  394. will automatically create both forward and reverse entries for
  395. .B ns1.cs.bell-labs.com .
  396. Unlike other DNS servers, there's no way to generate
  397. inconsistent forward and reverse entries.
  398. .SS "Delegating Name Service Authority"
  399. Delegation of a further subtree to another set of name servers
  400. is indicated by an
  401. .B soa=delegated
  402. attribute.
  403. .IP
  404. .EX
  405. dom=bignose.cs.research.bell-labs.com
  406. soa=delegated
  407. ns=anna.cs.research.bell-labs.com
  408. ns=dj.cs.research.bell-labs.com
  409. .EE
  410. .LP
  411. Nameservers within the delegated domain (as in this example)
  412. must have their IP addresses listed elsewhere in
  413. .I ndb
  414. files.
  415. .SS "Wildcards, MX and CNAME records"
  416. Wild-carded domain names can also be used.
  417. For example, to specify a mail forwarder for all Bell Labs research systems:
  418. .IP
  419. .EX
  420. dom=*.research.bell-labs.com
  421. mx=research.bell-labs.com
  422. .EE
  423. .LP
  424. `Cname' aliases may be established by adding a
  425. .B cname
  426. attribute giving the real domain name;
  427. the name attached to the
  428. .B dom
  429. attribute is the alias.
  430. `Cname' aliases are severely restricted;
  431. the aliases may have no other attributes than
  432. .B dom
  433. and are daily further restricted in their use by new RFCs.
  434. .IP
  435. .EX
  436. cname=anna.cs.bell-labs.com dom=www.cs.bell-labs.com
  437. .EE
  438. .PP
  439. makes
  440. .BI www. ...
  441. a synonym for the canonical name
  442. .BI anna. ... .
  443. .SS "DNS Queries and Debugging"
  444. .I Ndb/dnsquery
  445. can be used to query
  446. .I ndb/dns
  447. to see how it resolves requests.
  448. .I Ndb/dnsquery
  449. prompts for commands of the form
  450. .IP
  451. .I "domain-name request-type"
  452. .LP
  453. where
  454. .I request-type
  455. can be
  456. .BR ip ,
  457. .BR mx ,
  458. .BR ns ,
  459. .BR cname ,
  460. .BR ptr ....
  461. In the case of the inverse query type,
  462. .BR ptr ,
  463. .I dnsquery
  464. will reverse the ip address and tack on the
  465. .B .in-addr.arpa
  466. for you.
  467. .PP
  468. .I Ndb/dnsdebug
  469. is like
  470. .I ndb/dnsquery
  471. but bypasses the local server.
  472. It communicates via UDP with the domain name servers
  473. in the same way that the local resolver would and displays
  474. all packets received.
  475. The query can be specified on the command line or
  476. can be prompted for.
  477. The queries look like those of
  478. .I ndb/dnsquery
  479. with one addition.
  480. .I Ndb/dnsdebug
  481. can be directed to query a particular name server by
  482. the command
  483. .BI @ name-server\f1.
  484. From that point on, all queries go to that name server
  485. rather than being resolved by
  486. .IR dnsdebug .
  487. The
  488. .B @
  489. command returns query resolution to
  490. .IR dnsdebug .
  491. Finally, any command preceded by a
  492. .BI @ name-server
  493. sets the name server only for that command.
  494. .PP
  495. Normally
  496. .I dnsdebug
  497. uses the
  498. .B /net
  499. interface and the database file
  500. .BR /lib/ndb/local.
  501. The
  502. .B -f
  503. option supplies the name of the data base file to use.
  504. The
  505. .B -r
  506. option is the same as for
  507. .IR ndb/dns .
  508. The
  509. .B -x
  510. option directs
  511. .I dnsdebug
  512. to use the
  513. .B /net.alt
  514. interface and
  515. .B /lib/ndb/external
  516. database file.
  517. .SH EXAMPLES
  518. .EX
  519. % ndb/query sys helix
  520. sys=helix dom=helix.research.bell-labs.com bootf=/mips/9powerboot
  521. ip=135.104.117.31 ether=080069020427
  522. proto=il
  523. % ndb/dnsquery
  524. > plan9.bell-labs.com ip
  525. plan9.bell-labs.com ip 204.178.31.2
  526. > 204.178.31.2 ptr
  527. 2.31.178.204.in-addr.arpa ptr plan9.bell-labs.com
  528. 2.31.178.204.in-addr.arpa ptr ampl.com
  529. >
  530. .EE
  531. .SH FILES
  532. .TF /lib/ndb/local.*xxx
  533. .TP
  534. .B /lib/ndb/local
  535. first database file searched
  536. .TP
  537. .B /lib/ndb/local.*
  538. hash files for
  539. .B /lib/ndb/local
  540. .TP
  541. .B /srv/cs
  542. service file for
  543. .I ndb/cs
  544. .TP
  545. .B /net/cs
  546. where
  547. .B /srv/cs
  548. gets mounted
  549. .TP
  550. .B /srv/dns
  551. service file for
  552. .I ndb/dns
  553. .TP
  554. .B /net/dns
  555. where
  556. .B /srv/dns
  557. gets mounted
  558. .SH SOURCE
  559. .B /sys/src/cmd/ndb
  560. .SH SEE ALSO
  561. .IR ndb (2),
  562. .IR ndb (6)
  563. .SH BUGS
  564. .I Ndb
  565. databases are case-sensitive;
  566. ethernet addresses must be in lower-case hexadecimal.