ndb 9.7 KB

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