ndb 9.1 KB

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