File: node30.html

package info (click to toggle)
rutebook 1.0-1
  • links: PTS
  • area: non-free
  • in suites: sarge
  • size: 9,476 kB
  • ctags: 1,112
  • sloc: makefile: 47
file content (1316 lines) | stat: -rw-r--r-- 49,989 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

<!--Converted with LaTeX2HTML 99.2beta8 (1.46)
original version by:  Nikos Drakos, CBLU, University of Leeds
* revised and updated by:  Marcus Hennecke, Ross Moore, Herb Swan
* with significant contributions from:
  Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
<HTML>
<HEAD>
<TITLE>27. DNS and Name Resolution</TITLE>
<META NAME="description" CONTENT="27. DNS and Name Resolution">
<META NAME="keywords" CONTENT="rute">
<META NAME="resource-type" CONTENT="document">
<META NAME="distribution" CONTENT="global">

<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="LaTeX2HTML v99.2beta8">
<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">

<LINK REL="STYLESHEET" HREF="rute.css">

<LINK REL="next" HREF="node31.html">
<LINK REL="previous" HREF="node29.html">
<LINK REL="up" HREF="rute.html">
<LINK REL="next" HREF="node31.html">
</HEAD>

<BODY BGCOLOR=#FFFFFF >
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<TR><TD align=left bgcolor="#000000">
<FONT COLOR=white>
&nbsp;<A HREF="http://www.icon.co.za/~psheer/rute-purchase.html"><FONT COLOR=white>Purchase</FONT></A>&nbsp;
</FONT>
</TD><TD align=center bgcolor="#000000">
<FONT COLOR=white>
Copyright&nbsp;&#169;&nbsp;2002&nbsp;Paul Sheer. <A HREF="copying.html"><FONT COLOR=white>Click here for copying permissions.</FONT></A>
</FONT>
</TD><TD align=right bgcolor="#000000">
<FONT COLOR=white>
&nbsp;<A HREF="http://www.icon.co.za/~psheer/rute-home.html"><FONT COLOR=white>Home</FONT></A>&nbsp;
</FONT>
</TD></TR>
<TR><TD colspan=2 align=left bgcolor="#ECEBF4">
<IMG SRC="va-btn-small-light-60.png">
</TD><TD align=right bgcolor="#ECEBF4">
<IMG SRC="sflogo2-steel-60.png">
</TD></TR>
</TABLE><BR>

<!--Navigation Panel-->
<A NAME="tex2html2312"
  HREF="node31.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html2308"
  HREF="rute.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html2302"
  HREF="node29.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html2310"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>  
<BR>
<B> Next:</B> <A NAME="tex2html2313"
  HREF="node31.html">28. Network File System,</A>
<B> Up:</B> <A NAME="tex2html2309"
  HREF="rute.html">rute</A>
<B> Previous:</B> <A NAME="tex2html2303"
  HREF="node29.html">26. TCP and UDP</A>
 &nbsp <B>  <A NAME="tex2html2311"
  HREF="node1.html">Contents</A></B> 
<BR>
<BR>
<!--End of Navigation Panel-->
<!--Table of Child-Links-->
<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>

<UL>
<LI><A NAME="tex2html2314"
  HREF="#SECTION003010000000000000000">27.1 Top-Level Domains (TLDs)</A>
<LI><A NAME="tex2html2315"
  HREF="#SECTION003020000000000000000">27.2 Resolving DNS Names to IP Addresses</A>
<UL>
<LI><A NAME="tex2html2316"
  HREF="#SECTION003021000000000000000">27.2.1 The Internet DNS infrastructure</A>
<LI><A NAME="tex2html2317"
  HREF="#SECTION003022000000000000000">27.2.2 The name resolution process</A>
</UL>
<LI><A NAME="tex2html2318"
  HREF="#SECTION003030000000000000000">27.3 Configuring Your Local Machine</A>
<LI><A NAME="tex2html2319"
  HREF="#SECTION003040000000000000000">27.4 Reverse Lookups</A>
<LI><A NAME="tex2html2320"
  HREF="#SECTION003050000000000000000">27.5 <I>Authoritative</I> for a Domain</A>
<LI><A NAME="tex2html2321"
  HREF="#SECTION003060000000000000000">27.6 The <TT>
<FONT COLOR="#0000ff">host</FONT></TT>, <TT>
<FONT COLOR="#0000ff">ping</FONT></TT>, and <TT>
<FONT COLOR="#0000ff">whois</FONT></TT> Command</A>
<LI><A NAME="tex2html2322"
  HREF="#SECTION003070000000000000000">27.7 The <TT>
<FONT COLOR="#0000ff">nslookup</FONT></TT> Command</A>
<UL>
<LI><A NAME="tex2html2323"
  HREF="#SECTION003071000000000000000">27.7.1 <TT>
<FONT COLOR="#0000ff">NS</FONT></TT>, <TT>
<FONT COLOR="#0000ff">MX</FONT></TT>, <TT>
<FONT COLOR="#0000ff">PTR</FONT></TT>, <TT>
<FONT COLOR="#0000ff">A</FONT></TT> and <TT>
<FONT COLOR="#0000ff">CNAME</FONT></TT> records</A>
</UL>
<LI><A NAME="tex2html2324"
  HREF="#SECTION003080000000000000000">27.8 The <TT>
<FONT COLOR="#0000ff">dig</FONT></TT> Command</A>
</UL>
<!--End of Table of Child-Links-->
<HR>

<H1><A NAME="SECTION003000000000000000000">
27. DNS and Name Resolution</A>
</H1>

<P>
<A NAME="chap:dns"></A><A NAME="chap:dnsclient"></A>We know that each computer on the Internet has its own IP address.
Although this address is sufficient to identify a computer for
purposes of transmitting packets, it is not particularly
accommodating to people. Also, if a computer were to be
relocated, we would like to still identify it by the same name.

<P>
Hence, each computer is given a descriptive textual name. The basic
textual name of a machine is called the
<I>unqualified host name</I> <FONT COLOR="#ffa500">[This is my own
terminology.]</FONT> and is usually less than eight characters and
contains only lowercase letters and numbers (and especially no
dots). Groups of computers have a <I>domain name</I>. The full
name of machine is <I>unqualified_host_name</I><TT>
<FONT COLOR="#0000ff">.</FONT></TT><I>domain_name</I> and
is called the <I>fully qualified host name</I> <FONT COLOR="#ffa500">[Standard terminology.]</FONT>or the <I>qualified host name</I>. <FONT COLOR="#ffa500">[My terminology.]</FONT> For example, my
computer is <TT>
<FONT COLOR="#0000ff">cericon</FONT></TT>. The domain name of my company is
<TT>
<FONT COLOR="#0000ff">cranzgot.co.za</FONT></TT>, and hence the qualified host name of my computer
is <TT>
<FONT COLOR="#0000ff">cericon.cranzgot.co.za</FONT></TT>, although the IP address
might be <TT>
<FONT COLOR="#0000ff">160.123.76.9</FONT></TT>.

<P>
Often the word <I>domain</I> is synonymous with
<I>domain name</I>, and the <I>host name</I> on its own
can mean either the qualified or unqualified host name.

<P>
This system of naming computers is called the <I>Domain
Name System (DNS)</I>

<P>

<H1><A NAME="SECTION003010000000000000000">
27.1 Top-Level Domains (TLDs)</A>
</H1>

<P>
Domains always end in a standard set of things. Here is a
complete list of things that the last bit of a domain can be.

<P>
<DL>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">.com</FONT></TT></STRONG></DT>
<DD>A U.S. or international <TT>
<FONT COLOR="#0000ff">com</FONT></TT>pany proper. In
fact, any organization might have a <TT>
<FONT COLOR="#0000ff">.com</FONT></TT> domain.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">.gov</FONT></TT></STRONG></DT>
<DD>A U.S. <TT>
<FONT COLOR="#0000ff">gov</FONT></TT>ernment organization.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">.edu</FONT></TT></STRONG></DT>
<DD>A U.S. university.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">.mil</FONT></TT></STRONG></DT>
<DD>A U.S. <TT>
<FONT COLOR="#0000ff">mil</FONT></TT>itary department.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">.int</FONT></TT></STRONG></DT>
<DD>An organization established by <TT>
<FONT COLOR="#0000ff">int</FONT></TT>ernational treaties.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">.org</FONT></TT></STRONG></DT>
<DD>A U.S. or nonprofit <TT>
<FONT COLOR="#0000ff">org</FONT></TT>anization. In fact, anyone
can have a <TT>
<FONT COLOR="#0000ff">.org</FONT></TT> domain.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">.net</FONT></TT></STRONG></DT>
<DD>An Internet service provider (ISP). In fact, any bandwidth reseller,
IT company, or any company at all might have a <TT>
<FONT COLOR="#0000ff">.net</FONT></TT> domain.
</DD>
</DL>

<P>
Besides the above, the domain could end in a two-letter country
code.

<P>
The complete list of country codes is given in Table <A HREF="node30.html#table:isocountrycodes">27.1</A>. The <TT>
<FONT COLOR="#0000ff">.us</FONT></TT>
domain is rarely used, since in the United States <TT>
<FONT COLOR="#0000ff">.com</FONT></TT>, <TT>
<FONT COLOR="#0000ff">.edu</FONT></TT>,
<TT>
<FONT COLOR="#0000ff">.org</FONT></TT>,  <TT>
<FONT COLOR="#0000ff">.mil</FONT></TT>, <TT>
<FONT COLOR="#0000ff">.gov</FONT></TT>, <TT>
<FONT COLOR="#0000ff">.int</FONT></TT>, or <TT>
<FONT COLOR="#0000ff">.net</FONT></TT>
are mostly used.

<P>
<BR><P></P>
<DIV ALIGN="CENTER"><A NAME="table:isocountrycodes"></A><A NAME="43692"></A>
<TABLE>
<CAPTION><STRONG>Table 27.1:</STRONG>
ISO country codes</CAPTION>
<TR><TD><IMG
 WIDTH="556" HEIGHT="1058" BORDER="0"
 SRC="img32.png"
 ALT="\begin{table}{\scriptsize\begin{tabularx}{1.0\textwidth}{\vert c @{ } X \vert c ...
...c}}} &amp; St. Vincent and the Grenadines &amp; &amp; \\
\hline
\end{tabularx}}
\end{table}"></TD></TR>
</TABLE>
</DIV><P></P>
<BR>

<P>
Within each country, a domain may have things before it for
better description. Each country may implement a different
structure. Some examples are:

<P>
<DL>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">.co.za</FONT></TT></STRONG></DT>
<DD>A South African <TT>
<FONT COLOR="#0000ff">co</FONT></TT>mpany.
(<TT>
<FONT COLOR="#0000ff">za</FONT></TT> = Zuid Afrika, from Dutch.)
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">.org.za</FONT></TT></STRONG></DT>
<DD>A South African nonprofit <TT>
<FONT COLOR="#0000ff">org</FONT></TT>anization.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">.ac.za</FONT></TT></STRONG></DT>
<DD>A South African <TT>
<FONT COLOR="#0000ff">ac</FONT></TT>ademic university.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">.edu.au</FONT></TT></STRONG></DT>
<DD>An <TT>
<FONT COLOR="#0000ff">au</FONT></TT>stralian tertiary <TT>
<FONT COLOR="#0000ff">edu</FONT></TT>cational institution.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">.gov.za</FONT></TT></STRONG></DT>
<DD>A South African <TT>
<FONT COLOR="#0000ff">gov</FONT></TT>ernment organization.
</DD>
</DL>

<P>
Note that a South African company might choose a <TT>
<FONT COLOR="#0000ff">.com</FONT></TT>
domain instead of a <TT>
<FONT COLOR="#0000ff">.co.za</FONT></TT> domain. The Internet has become
more commercialized than organized, meaning that anyone can
pretty much register any domain that is not already taken.

<P>

<H1><A NAME="SECTION003020000000000000000">
27.2 Resolving DNS Names to IP Addresses</A>
</H1>

<P>
In practice, a user will type a host name (say,
<TT>
<FONT COLOR="#0000ff">www.cranzgot.co.za</FONT></TT>) into some application like
a web browser. The
application has to then try find the IP address associated with
that name, in order to send packets to it. This section
describes the query structure used on the Internet so that
everyone can find out anyone else's IP address.

<P>
An obvious lookup infrastructure might involve distributing
a long table of host name vs. IP numbers to every machine
on the Internet. But as soon as you have more than a few
thousand machines, this approach becomes impossible.

<P>
Another imaginary infrastructure might have one huge computer on
the Internet somewhere whose IP address is known by everyone.
This computer would be responsible for servicing requests for IP
numbers, and the said application running on your local
machine would just query this big machine. Of course, with billions
of machines out there, this approach will obviously create far
too much network traffic. <FONT COLOR="#ffa500">[Actually, some Microsoft LANs kind
of work this way--that is, not very well.]</FONT>
<P>

<H2><A NAME="SECTION003021000000000000000">
27.2.1 The Internet DNS infrastructure</A>
</H2>

<P>
The DNS structure on the
Internet actually works like this.

<P>
There <I>are</I> computers that service requests for IP
numbers--millions of them. They are called <I>name servers</I>
(or <I>DNS servers</I>), and a request is called a 
<I>DNS lookup</I> (or just a <I>lookup</I>). However, each name
server only has information about a specific part of the
Internet, and they constantly query each other.

<P>
There are 13 <I>root</I> name servers on the Internet. <FONT COLOR="#ffa500">[This list can be
gotten from <I><TT><A NAME="tex2html42"
  HREF="ftp://ftp.rs.internic.net/domain/named.root">ftp://ftp.rs.internic.net/domain/named.root</A></TT></I>.]</FONT>
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>5</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>10</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>a.root-servers.net&nbsp;&nbsp;198.41.0.4</code><br>
<code>b.root-servers.net&nbsp;&nbsp;128.9.0.107</code><br>
<code>c.root-servers.net&nbsp;&nbsp;192.33.4.12</code><br>
<code>d.root-servers.net&nbsp;&nbsp;128.8.10.90</code><br>
<code>e.root-servers.net&nbsp;&nbsp;192.203.230.10</code><br>
<code>f.root-servers.net&nbsp;&nbsp;192.5.5.241</code><br>
<code>g.root-servers.net&nbsp;&nbsp;192.112.36.4</code><br>
<code>h.root-servers.net&nbsp;&nbsp;128.63.2.53</code><br>
<code>i.root-servers.net&nbsp;&nbsp;192.36.148.17</code><br>
<code>j.root-servers.net&nbsp;&nbsp;198.41.0.10</code><br>
<code>k.root-servers.net&nbsp;&nbsp;193.0.14.129&nbsp;</code><br>
<code>l.root-servers.net&nbsp;&nbsp;198.32.64.12</code><br>
<code>m.root-servers.net&nbsp;&nbsp;202.12.27.33</code><br>
</FONT></TD></TR></TABLE><P>

<P>
Each country also has a name server, and in turn each
organization has a name server. Each name server only has
information about machines in its own domain, as well as
information about other name servers. The root name servers
only have information on the IP addresses of the name servers
of <TT>
<FONT COLOR="#0000ff">.com</FONT></TT>, <TT>
<FONT COLOR="#0000ff">.edu</FONT></TT>, <TT>
<FONT COLOR="#0000ff">.za</FONT></TT>, etc. The <TT>
<FONT COLOR="#0000ff">.za</FONT></TT> name
server only has information on the IP addresses of the name
servers of <TT>
<FONT COLOR="#0000ff">.org.za</FONT></TT>, <TT>
<FONT COLOR="#0000ff">.ac.za</FONT></TT>,
<TT>
<FONT COLOR="#0000ff">.co.za</FONT></TT>, etc. The <TT>
<FONT COLOR="#0000ff">.co.za</FONT></TT> name server only has information
on the name servers of all South African companies, like <TT>
<FONT COLOR="#0000ff">.cranzgot.co.za</FONT></TT>,
<TT>
<FONT COLOR="#0000ff">.icon.co.za</FONT></TT>, <TT>
<FONT COLOR="#0000ff">.mweb.co.za</FONT></TT>, etc. The <TT>
<FONT COLOR="#0000ff">.cranzgot.co.za</FONT></TT>,
name server only has info on the machines at Cranzgot Systems,
like <TT>
<FONT COLOR="#0000ff">www.cranzgot.co.za</FONT></TT>.

<P>
Your own machine will defined in its configuration files a
name server that is geographically close to it. The
responsibilities of this name server will be to directly answer any
queries about its own domain that it has information about and
to answer any other queries by querying as many other
name servers on the Internet as is necessary.

<P>

<H2><A NAME="SECTION003022000000000000000">
27.2.2 The name resolution process</A>
</H2>

<P>
<A NAME="sec:nameresprocess"></A>Now our application is presented with
<TT>
<FONT COLOR="#0000ff">www.cranzgot.co.za</FONT></TT>. The following sequence of lookups
takes place to resolve this name into an IP address. This procedure
is called <I>host name resolution</I> and the algorithm that
performs this operation is called the <I>resolver</I>.

<P>

<OL>
<LI>The application checks certain special databases
on the local machine. If it can get an answer directly
from them, it proceeds no further.
</LI>
<LI>The application looks up a geographically close
name server from the local machine's configuration file.
Let's say this machine is called <TT>
<FONT COLOR="#0000ff">ns</FONT></TT>.
</LI>
<LI>The application queries <TT>
<FONT COLOR="#0000ff">ns</FONT></TT> with
``<TT>
<FONT COLOR="#0000ff">www.cranzgot.co.za</FONT></TT>?''.
</LI>
<LI><TT>
<FONT COLOR="#0000ff">ns</FONT></TT> determines whether that IP has
been recently looked up. If it has, there is no need to ask
further, since the result would be stored in a local cache.
</LI>
<LI><TT>
<FONT COLOR="#0000ff">ns</FONT></TT> checks whether the domain is local. That is,
whether it is a computer about which it has direct information. In this
case, this would only be true if the <TT>
<FONT COLOR="#0000ff">ns</FONT></TT> were <TT>
<FONT COLOR="#0000ff">cranzgot.co.za</FONT></TT>'s very
own name server.
</LI>
<LI><TT>
<FONT COLOR="#0000ff">ns</FONT></TT> strips out the TLD (top level domain) <TT>
<FONT COLOR="#0000ff">.za</FONT></TT>.
It queries a root name server, asking what name server is
responsible for <TT>
<FONT COLOR="#0000ff">.za</FONT></TT>. The answer will be
<TT>
<FONT COLOR="#0000ff">ucthpx.uct.ac.za</FONT></TT> of IP address <TT>
<FONT COLOR="#0000ff">137.158.128.1</FONT></TT>.
</LI>
<LI><TT>
<FONT COLOR="#0000ff">ns</FONT></TT> strips out the next highest domain <TT>
<FONT COLOR="#0000ff">co.za</FONT></TT>
It queries <TT>
<FONT COLOR="#0000ff">137.158.128.1</FONT></TT>, asking what name server is
responsible for <TT>
<FONT COLOR="#0000ff">.co.za</FONT></TT>. The answer will be
<TT>
<FONT COLOR="#0000ff">secdns1.posix.co.za</FONT></TT> of IP address <TT>
<FONT COLOR="#0000ff">160.124.112.10</FONT></TT>.
</LI>
<LI><TT>
<FONT COLOR="#0000ff">ns</FONT></TT> strips out the next highest domain <TT>
<FONT COLOR="#0000ff">cranzgot.co.za</FONT></TT>.
It queries <TT>
<FONT COLOR="#0000ff">160.124.112.10</FONT></TT>, asking what name server is
responsible for <TT>
<FONT COLOR="#0000ff">cranzgot.co.za</FONT></TT>. The answer will be
<TT>
<FONT COLOR="#0000ff">pizza.cranzgot.co.za</FONT></TT> of IP address <TT>
<FONT COLOR="#0000ff">196.28.123.1</FONT></TT>.
</LI>
<LI><TT>
<FONT COLOR="#0000ff">ns</FONT></TT> queries <TT>
<FONT COLOR="#0000ff">196.28.123.1</FONT></TT> asking
for the IP address of <TT>
<FONT COLOR="#0000ff">www.cranzgot.co.za</FONT></TT>. The answer
will be <TT>
<FONT COLOR="#0000ff">160.123.176.1</FONT></TT>.
</LI>
<LI><TT>
<FONT COLOR="#0000ff">ns</FONT></TT> returns the result to the application.
</LI>
<LI><TT>
<FONT COLOR="#0000ff">ns</FONT></TT> stores each of these results in a local
cache with an expiration date, to avoid having to look them up a second
time.
</LI>
</OL>

<P>

<H1><A NAME="SECTION003030000000000000000">
27.3 Configuring Your Local Machine</A>
</H1>

<P>
We referred to ``configuration files'' above. These are
actually the files: <TT>
<FONT COLOR="#0000ff">/etc/host.conf</FONT></TT>, <TT>
<FONT COLOR="#0000ff">/etc/hosts</FONT></TT>, and
<TT>
<FONT COLOR="#0000ff">/etc/resolv.conf</FONT></TT>. These are the three and only files that specify
how all applications are going to look up IP numbers; and have
nothing to do with the configuration files of the name server
daemon itself, even though a name server daemon might be
running on the local machine.

<P>
When an application needs to look up a host name, it goes through the
following procedure. <FONT COLOR="#ffa500">[What is actually happening is that
the application is making a <B>C</B> library call to the function
<TT>
<FONT COLOR="#0000ff">gethostbyname()</FONT></TT>, hence all these configuration files really
belong to the C library packages <TT>
<FONT COLOR="#0000ff">glibc</FONT></TT> or <TT>
<FONT COLOR="#0000ff">libc</FONT></TT>.
However, this is a detail you need not be concerned about.]</FONT> The
following are equivalent to steps 1, 2, and 3 above, with the details of the
configuration files filled in. The configuration files that
follow are taken from an actual installation.

<P>

<OL>
<LI>The application checks the file <TT>
<FONT COLOR="#0000ff">/etc/host.conf</FONT></TT>.
This file will usually have a line <TT>
<FONT COLOR="#0000ff">order hosts,bind</FONT></TT> in it, specifying that
it should first (<TT>
<FONT COLOR="#0000ff">hosts</FONT></TT>) check the local database file <TT>
<FONT COLOR="#0000ff">/etc/hosts</FONT></TT>, and then
(<TT>
<FONT COLOR="#0000ff">bind</FONT></TT>) query the name server specified in <TT>
<FONT COLOR="#0000ff">/etc/resolv.conf</FONT></TT>. The file
<TT>
<FONT COLOR="#0000ff">/etc/hosts</FONT></TT> contains a plain text list of IP addresses and
names. An example is given below. If the application can get an answer directly
from <TT>
<FONT COLOR="#0000ff">/etc/hosts</FONT></TT>, it proceeds no further.
</LI>
<LI>The application checks in the file <TT>
<FONT COLOR="#0000ff">/etc/resolv.conf</FONT></TT>
for a line <TT>
<FONT COLOR="#0000ff">nameserver &lt;nameserver&gt;</FONT></TT>. There can actually be
three of these lines so that if one name server fails, the application
can try the next in turn.
</LI>
<LI>The application sends to the name server a query with the host name.
If the host name is unqualified, then the application, before trying the
query, appends to the host name a local domain name. A line
<TT>
<FONT COLOR="#0000ff">search &lt;domain1&gt; &lt;domain2&gt; ... &lt;domainN&gt;</FONT></TT> may appear in the configuration
file to facilitate this. A query is made with each of <TT>
<FONT COLOR="#0000ff">&lt;domain1&gt;</FONT></TT>, <TT>
<FONT COLOR="#0000ff">&lt;domain2&gt;</FONT></TT>
etc. appended in turn until the query successfully returns an IP. This
just saves you having to type in the full host name for computers within
your own organization.
</LI>
<LI>The name server proceeds with the hierarchical queries described
from step 4 onward.
</LI>
</OL>

<P>
<A NAME="page:etchostsexample"></A>The <TT>
<FONT COLOR="#0000ff">/etc/hosts</FONT></TT> file should look something like this<A NAME="page:hostsfile"></A>:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>127.0.0.1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;localhost.localdomain&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;localhost</code><br>
<code>192.168.3.9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cericon.cranzgot.co.za&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cericon</code><br>
<code>192.168.3.10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pepper.cranzgot.co.za&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pepper</code><br>
<code>192.168.2.1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;onion.cranzgot.co.za&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;onion</code><br>
</FONT></TD></TR></TABLE><P>

<P>
The hosts <TT>
<FONT COLOR="#0000ff">pepper</FONT></TT>, <TT>
<FONT COLOR="#0000ff">cericon</FONT></TT>, and <TT>
<FONT COLOR="#0000ff">onion</FONT></TT> are the
hosts that this machine has the most communication with, and hence are
listed here. <TT>
<FONT COLOR="#0000ff">cericon</FONT></TT> is the local machine and must be listed. You
can list any hosts to which you want fast lookups, or hosts that might
need to be known in spite of name servers being down.

<P>
The <TT>
<FONT COLOR="#0000ff">/etc/host.conf</FONT></TT> might look like this. All of the lines
are optional:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>5</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>order&nbsp;&nbsp;&nbsp;&nbsp;hosts,&nbsp;bind,&nbsp;nis</code><br>
<code>trim&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;some.domain</code><br>
<code>spoofalert</code><br>
<code>nospoof</code><br>
<code>multi&nbsp;&nbsp;&nbsp;&nbsp;on</code><br>
<code>reorder</code><br>
</FONT></TD></TR></TABLE><P>

<P>
<DL>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">order</FONT></TT></STRONG></DT>
<DD>The order in which lookups are done. Don't try fiddling
with this value. It never seems to have any effect. You should leave it
as <TT>
<FONT COLOR="#0000ff">order hosts,bind</FONT></TT> (or <TT>
<FONT COLOR="#0000ff">order hosts,bind,nis</FONT></TT> if you are
using NIS--search for the <TT>
<FONT COLOR="#0000ff">NIS-HOWTO</FONT></TT> on the web.)
Once again, <TT>
<FONT COLOR="#0000ff">bind</FONT></TT> means to then go and check the <TT>
<FONT COLOR="#0000ff">/etc/resolv.conf</FONT></TT>
which holds the name server query options.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">trim</FONT></TT></STRONG></DT>
<DD>Strip the domain <TT>
<FONT COLOR="#0000ff">some.domain</FONT></TT> from the end
of a host name before trying a lookup. You will probably never require this
feature.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">spoofalert</FONT></TT></STRONG></DT>
<DD>Try reverse lookups on a host name after looking up
the IP (i.e., do a query to find the name from the IP). If this query
does not return the correct result, it could mean that some machine is trying
to make it look like it is someone it really isn't. This is a hacker's
trick called <I>spoofing</I>. <TT>
<FONT COLOR="#0000ff">spoofalert</FONT></TT> warns you of such attempts in
your log file <TT>
<FONT COLOR="#0000ff">/var/log/messages</FONT></TT>.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">nospoof</FONT></TT></STRONG></DT>
<DD>Disallow results that fail the spoof test.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">multi on</FONT></TT></STRONG></DT>
<DD>Return more than one result if there are aliases.
Actually, a host can have several IP numbers, and an IP number
can have several host names. Consider a computer that might
want more than one name (<TT>
<FONT COLOR="#0000ff">ftp.cranzgot.co.za</FONT></TT> and
<TT>
<FONT COLOR="#0000ff">www.cranzgot.co.za</FONT></TT> are the same machine.) Or a machine that
has several networking cards and an IP address for each.
This option should always be turned on. <TT>
<FONT COLOR="#0000ff">multi off</FONT></TT> is the alternative.
Most applications use only the first value returned.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">reorder</FONT></TT></STRONG></DT>
<DD>If more than one
IP is returned by a lookup, then sort that list according to
the IP that has the most convenient network route.
</DD>
</DL>

<P>
Despite this array of options, an <TT>
<FONT COLOR="#0000ff">/etc/host.conf</FONT></TT>
file almost always looks simply like

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>order&nbsp;&nbsp;&nbsp;&nbsp;hosts,&nbsp;bind</code><br>
<code>multi&nbsp;&nbsp;&nbsp;&nbsp;on</code><br>
</FONT></TD></TR></TABLE><P>

<P>
The <TT>
<FONT COLOR="#0000ff">/etc/resolv.conf</FONT></TT> file could look something like this:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>5</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>nameserver&nbsp;192.168.2.1</code><br>
<code>nameserver&nbsp;160.123.76.1</code><br>
<code>nameserver&nbsp;196.41.0.131</code><br>
<code>search&nbsp;cranzgot.co.za&nbsp;ct.cranzgot.co.za&nbsp;uct.ac.za</code><br>
<code>sortlist&nbsp;192.168.3.0/255.255.255.0&nbsp;192.168.2.0/255.255.255.0</code><br>
<code>options&nbsp;ndots:1&nbsp;timeout:30&nbsp;attempts:2&nbsp;rotate&nbsp;no-check-names&nbsp;inet6</code><br>
</FONT></TD></TR></TABLE><P>

<P>
<DL>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">nameserver</FONT></TT></STRONG></DT>
<DD>Specifies a name server to query.
No more than three may be listed. The point of having more than one
is to safeguard against a name server being down; the next in
the list will then be queried.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">search</FONT></TT></STRONG></DT>
<DD>If given a host name with less than <TT>
<FONT COLOR="#0000ff">ndots</FONT></TT>
dots (i.e., <TT>
<FONT COLOR="#0000ff">1</FONT></TT> in this case), add each of the domains in turn
to the host name, trying a lookup with each. This option allows you to type in
an unqualified host name and the application work out what organization
it is belongs to from the search list. You can have up to six domains,
but then queries would be time consuming.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">domain</FONT></TT></STRONG></DT>
<DD>The line ``<TT>
<FONT COLOR="#0000ff">domain ct.cranzgot.co.za</FONT></TT>'' is the
same as ``<TT>
<FONT COLOR="#0000ff">search ct.cranzgot.co.za cranzgot.co.za co.za</FONT></TT>''. Always
use <TT>
<FONT COLOR="#0000ff">search</FONT></TT> explicitly instead of <TT>
<FONT COLOR="#0000ff">domain</FONT></TT> to reduce
the number of queries to a minimum.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">sortlist</FONT></TT></STRONG></DT>
<DD>If more than one host is returned, sort them
according to the following <I>network</I><TT>
<FONT COLOR="#0000ff">/</FONT></TT><I>mask</I>s.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">options</FONT></TT></STRONG></DT>
<DD>Various additional parameters can be specified in this one line:
<DL>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">ndots</FONT></TT></STRONG></DT>
<DD>Explained under <TT>
<FONT COLOR="#0000ff">search</FONT></TT>
above. The default is <TT>
<FONT COLOR="#0000ff">1</FONT></TT>.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">timeout</FONT></TT></STRONG></DT>
<DD>How long to wait before considering a query
to have failed. The default is 30 seconds.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">attempts</FONT></TT></STRONG></DT>
<DD>Number of attempts to make before failing.
The default is 2. This means that a down name server will cause
your application to wait 1 full minute before deciding that it
can't resolve the IP.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">rotate</FONT></TT></STRONG></DT>
<DD>Try the name servers in round robin fashion.
This distributes load across name servers.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">no-check-names</FONT></TT></STRONG></DT>
<DD>Don't check for invalid characters in
host names.
</DD>
<DT><STRONG><TT>
<FONT COLOR="#0000ff">inet6</FONT></TT></STRONG></DT>
<DD>The man page for <TT>
<FONT COLOR="#0000ff">resolv.conf</FONT></TT> (<TT>
<FONT COLOR="#0000ff">resolver</FONT></TT>(5)) says:
<PRE>
      inet6     sets RES_USE_INET6 in _res.options .  This has the ef-
                fect of trying a AAAA query before an A query inside
                the gethostbyname function, and of mapping IPv4 re-
                sponses in IPv6 ``tunnelled form'' if no AAAA records
                are found but an A record set exists.
</PRE>
An <TT>
<FONT COLOR="#0000ff">AAAA</FONT></TT> query is a 128-bit
``next generation,'' or ``IPV6'' Internet address.
</DD>
</DL>
</DD>
</DL>

<P>
Despite this array of options, an <TT>
<FONT COLOR="#0000ff">/etc/resolv.conf</FONT></TT> file almost always looks simply like:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>nameserver&nbsp;192.168.2.254</code><br>
<code>search&nbsp;cranzgot.co.za</code><br>
</FONT></TD></TR></TABLE><P>

<P>

<H1><A NAME="SECTION003040000000000000000">
27.4 Reverse Lookups</A>
</H1>

<P>
A <I>reverse lookup</I>, mentioned under <TT>
<FONT COLOR="#0000ff">nospoof</FONT></TT>, is the
determining of the host name from the IP address. The course of queries is
similar to forward lookups using part of the IP address to find out what
machines are responsible for what ranges of IP address.

<P>
A <I>forward lookup</I> is an ordinary lookup of the IP address from the
host name.

<P>

<H1><A NAME="SECTION003050000000000000000">
27.5 <I>Authoritative</I> for a Domain</A>
</H1>

<P>
I have emphasized that name servers only hold information
for their own domains. Any other information they may have
about another domain is cached, temporary data that has an
expiration date attached to it.

<P>
The domain that a name server has information about is said to
be the domain that a name server is <I>authoritative</I> for.
Alternatively we say: ``a name server is <I>authoritative</I>
for the domain.'' For instance, the server
<TT>
<FONT COLOR="#0000ff">ns2.cranzgot.co.za</FONT></TT> is authoritative for the domain
<TT>
<FONT COLOR="#0000ff">cranzgot.co.za</FONT></TT>. Hence, lookups from anywhere on the Internet having the domain
<TT>
<FONT COLOR="#0000ff">cranzgot.co.za</FONT></TT> ultimately are the responsibility of
<TT>
<FONT COLOR="#0000ff">ns2.cranzgot.co.za</FONT></TT>, and originate (albeit through a long
series of caches) from the host <TT>
<FONT COLOR="#0000ff">ns2.cranzgot.co.za</FONT></TT>.

<P>

<H1><A NAME="SECTION003060000000000000000">
27.6 The <TT>
<FONT COLOR="#0000ff">host</FONT></TT>, <TT>
<FONT COLOR="#0000ff">ping</FONT></TT>, and <TT>
<FONT COLOR="#0000ff">whois</FONT></TT> Command</A>
</H1>

<P>
The command <TT>
<FONT COLOR="#0000ff">host</FONT></TT> looks up a host name or an IP address, by doing
a name server query. Try

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>host&nbsp;www.cnn.com</code><br>
</FONT></TD></TR></TABLE><P>
for an example of a host with lots of IP address. Keep typing <TT>
<FONT COLOR="#0000ff">host</FONT></TT>
over and over. Notice that the order of the hosts keeps changing randomly.
This reordering distributes load among the many <TT>
<FONT COLOR="#0000ff">cnn.com</FONT></TT> servers.

<P>
Now, pick one of the IP addresses and type

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>host&nbsp;&#060;ip-address&#062;</code><br>
</FONT></TD></TR></TABLE><P>
This command will return the host name <TT>
<FONT COLOR="#0000ff">cnn.com</FONT></TT>.

<P>
Note that the <TT>
<FONT COLOR="#0000ff">host</FONT></TT> command is not
available on all U<SMALL>NIX</SMALL> systems.

<P>
The <TT>
<FONT COLOR="#0000ff">ping</FONT></TT> command has nothing directly to do with DNS
but is a quick way of getting an IP address and at the same
time checking whether a host is responding. It is often used as the acid
test for network and DNS connectivity. See Section <A HREF="node28.html#sec:ping">25.10.1</A>.

<P>
Now enter:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>whois&nbsp;cnn.com@rs.internic.net</code><br>
</FONT></TD></TR></TABLE><P>
(Note that original BSD <TT>
<FONT COLOR="#0000ff">whois</FONT></TT> worked like <TT>
<FONT COLOR="#0000ff">whois -h &lt;host&gt; &lt;user&gt;</FONT></TT>.)
You will get a response like this:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>5</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>10</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>15</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>20</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>[rs.internic.net]</code><br>
<code>&nbsp;</code><br>
<code>Whois&nbsp;Server&nbsp;Version&nbsp;1.1</code><br>
<code>&nbsp;</code><br>
<code>Domain&nbsp;names&nbsp;in&nbsp;the&nbsp;.com,&nbsp;.net,&nbsp;and&nbsp;.org&nbsp;domains&nbsp;can&nbsp;now&nbsp;be&nbsp;registered</code><br>
<code>with&nbsp;many&nbsp;different&nbsp;competing&nbsp;registrars.&nbsp;Go&nbsp;to&nbsp;http://www.internic.net</code><br>
<code>for&nbsp;detailed&nbsp;information.</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;&nbsp;&nbsp;Domain&nbsp;Name:&nbsp;CNN.COM</code><br>
<code>&nbsp;&nbsp;&nbsp;Registrar:&nbsp;NETWORK&nbsp;SOLUTIONS,&nbsp;INC.</code><br>
<code>&nbsp;&nbsp;&nbsp;Whois&nbsp;Server:&nbsp;whois.networksolutions.com</code><br>
<code>&nbsp;&nbsp;&nbsp;Referral&nbsp;URL:&nbsp;www.networksolutions.com</code><br>
<code>&nbsp;&nbsp;&nbsp;Name&nbsp;Server:&nbsp;NS-01A.ANS.NET</code><br>
<code>&nbsp;&nbsp;&nbsp;Name&nbsp;Server:&nbsp;NS-01B.ANS.NET</code><br>
<code>&nbsp;&nbsp;&nbsp;Name&nbsp;Server:&nbsp;NS-02A.ANS.NET</code><br>
<code>&nbsp;&nbsp;&nbsp;Name&nbsp;Server:&nbsp;NS-02B.ANS.NET</code><br>
<code>&nbsp;&nbsp;&nbsp;Updated&nbsp;Date:&nbsp;22-sep-1999</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&#062;&#062;&#062;&nbsp;Last&nbsp;update&nbsp;of&nbsp;whois&nbsp;database:&nbsp;Thu,&nbsp;20&nbsp;Jan&nbsp;00&nbsp;01:39:07&nbsp;EST&nbsp;&#060;&#060;&#060;</code><br>
<code>&nbsp;</code><br>
<code>The&nbsp;Registry&nbsp;database&nbsp;contains&nbsp;ONLY&nbsp;.COM,&nbsp;.NET,&nbsp;.ORG,&nbsp;.EDU&nbsp;domains&nbsp;and</code><br>
<code>Registrars.</code><br>
</FONT></TD></TR></TABLE><P>

<P>
(Internic happens to have this database of <TT>
<FONT COLOR="#0000ff">.com</FONT></TT>, <TT>
<FONT COLOR="#0000ff">.net</FONT></TT>, <TT>
<FONT COLOR="#0000ff">.org</FONT></TT>,
and <TT>
<FONT COLOR="#0000ff">.edu</FONT></TT> domains.)

<P>

<H1><A NAME="SECTION003070000000000000000">
27.7 The <TT>
<FONT COLOR="#0000ff">nslookup</FONT></TT> Command</A>
</H1>

<P>

<TT>
<FONT COLOR="#0000ff">nslookup</FONT></TT> is a program to interactively query a name server.
If you run

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>nslookup</code><br>
</FONT></TD></TR></TABLE><P>
you will get a <TT>
<FONT COLOR="#0000ff">&gt;</FONT></TT> prompt at which you can type commands.
If you type in a host name, <TT>
<FONT COLOR="#0000ff">nslookup</FONT></TT> will return its
IP address(s), and visa versa. Also, typing

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>help</code><br>
</FONT></TD></TR></TABLE><P>
any time will return a complete list of commands. By default,
<TT>
<FONT COLOR="#0000ff">nslookup</FONT></TT> uses the first name server listed in <TT>
<FONT COLOR="#0000ff">/etc/resolv.conf</FONT></TT>
for all its queries. However, the command

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>server&nbsp;&#060;nameserver&#062;</code><br>
</FONT></TD></TR></TABLE><P>
will force <TT>
<FONT COLOR="#0000ff">nslookup</FONT></TT> to connect to a name server of your choice.

<P>

<H2><A NAME="SECTION003071000000000000000">
27.7.1 <TT>
<FONT COLOR="#0000ff">NS</FONT></TT>, <TT>
<FONT COLOR="#0000ff">MX</FONT></TT>, <TT>
<FONT COLOR="#0000ff">PTR</FONT></TT>, <TT>
<FONT COLOR="#0000ff">A</FONT></TT> and <TT>
<FONT COLOR="#0000ff">CNAME</FONT></TT> records</A>
</H2>

<P>
<A NAME="sec:nsmxrecords"></A>
<P>
The word <I>record</I> is a piece of DNS information.

<P>
Now enter the command:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>set&nbsp;type=NS</code><br>
</FONT></TD></TR></TABLE><P>
This tells <TT>
<FONT COLOR="#0000ff">nslookup</FONT></TT> to return the second type of
information that a DNS can deliver: <I>the authoritative name
server for a domain</I> or the <TT>
<FONT COLOR="#0000ff">NS</FONT></TT> record
of the domain. You can enter any domain here. For instance, if you enter

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>set&nbsp;type=NS</code><br>
<code>cnn.com</code><br>
</FONT></TD></TR></TABLE><P>
<TT>
<FONT COLOR="#0000ff">nslookup</FONT></TT> returns

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>5</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>10</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>Non-authoritative&nbsp;answer:</code><br>
<code>cnn.com&nbsp;nameserver&nbsp;=&nbsp;NS-02B.ANS.NET</code><br>
<code>cnn.com&nbsp;nameserver&nbsp;=&nbsp;NS-02A.ANS.NET</code><br>
<code>cnn.com&nbsp;nameserver&nbsp;=&nbsp;NS-01B.ANS.NET</code><br>
<code>cnn.com&nbsp;nameserver&nbsp;=&nbsp;NS-01A.ANS.NET</code><br>
<code>&nbsp;</code><br>
<code>Authoritative&nbsp;answers&nbsp;can&nbsp;be&nbsp;found&nbsp;from:</code><br>
<code>NS-02B.ANS.NET&nbsp;&nbsp;internet&nbsp;address&nbsp;=&nbsp;207.24.245.178</code><br>
<code>NS-02A.ANS.NET&nbsp;&nbsp;internet&nbsp;address&nbsp;=&nbsp;207.24.245.179</code><br>
<code>NS-01B.ANS.NET&nbsp;&nbsp;internet&nbsp;address&nbsp;=&nbsp;199.221.47.8</code><br>
<code>NS-01A.ANS.NET&nbsp;&nbsp;internet&nbsp;address&nbsp;=&nbsp;199.221.47.7</code><br>
</FONT></TD></TR></TABLE><P>
This output tells us that four name servers are authoritative for the
domain <TT>
<FONT COLOR="#0000ff">cnn.com</FONT></TT> (one plus three backups). It also tells us
that it did not get this answer from an authoritative source, but through
a cached source. It also tells us what name servers are
authoritative for this very information.

<P>
Now, switch to a name server that <I>is</I> authoritative for <TT>
<FONT COLOR="#0000ff">cnn.com</FONT></TT>:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>server&nbsp;NS-02B.ANS.NET</code><br>
</FONT></TD></TR></TABLE><P>
and run the same query:

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>cnn.com</code><br>
</FONT></TD></TR></TABLE><P>
The new result is somewhat more emphatic, but no different.

<P>
There are only a few other kinds of records that you can
get from a name server. Try

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>set&nbsp;type=MX</code><br>
<code>cnn.com</code><br>
</FONT></TD></TR></TABLE><P>
to get the so-called <I><TT>
<FONT COLOR="#0000ff">MX</FONT></TT> record</I> for that domain. The <TT>
<FONT COLOR="#0000ff">MX</FONT></TT>
record is the server responsible for handling mail destined to
that domain. <TT>
<FONT COLOR="#0000ff">MX</FONT></TT> records also have a priority (usually
10 or 20). This tells any mail server to try the 20 one should
the 10 one fail, and so on. There are usually only one or two <TT>
<FONT COLOR="#0000ff">MX</FONT></TT> records.
Mail is actually the only Internet service handled by
DNS. (For instance, there is no such thing as a NEWSX record for
news, or a WX record for web pages, whatever kind of
information we may like such records to hold.)

<P>
Also try

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<code>&nbsp;</code><br>
<font size="-1"><code>5</code></font><code>&nbsp;</code><br>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>set&nbsp;type=PTR</code><br>
<code>&#060;ip-address&#062;</code><br>
<code>set&nbsp;type=A</code><br>
<code>&#060;hostname&#062;</code><br>
<code>set&nbsp;type=CNAME</code><br>
<code>&#060;hostname&#062;</code><br>
</FONT></TD></TR></TABLE><P>
So-called <TT>
<FONT COLOR="#0000ff">PTR</FONT></TT> records are reverse lookups, or
<TT>
<FONT COLOR="#0000ff">P</FONT></TT><I>oin</I><TT>
<FONT COLOR="#0000ff">T</FONT></TT><I>e</I><TT>
<FONT COLOR="#0000ff">R</FONT></TT><I>s</I> to
host names. So-called <TT>
<FONT COLOR="#0000ff">A</FONT></TT> records are forward lookups
(the default type of lookup when you first invoke
<TT>
<FONT COLOR="#0000ff">nslookup</FONT></TT> and the type of lookup the first half of this
chapter was most concerned with), or <TT>
<FONT COLOR="#0000ff">A</FONT></TT><I>ddress</I> lookups.
So-called <TT>
<FONT COLOR="#0000ff">CNAME</FONT></TT> records are lookups of
<TT>
<FONT COLOR="#0000ff">C</FONT></TT><I>anonical</I> <TT>
<FONT COLOR="#0000ff">NAME</FONT></TT><I>s</I>. DNS allows
you to alias a computer to many different names, even though
each has one <I>real</I> name (called the <I>canonical</I> name).
<TT>
<FONT COLOR="#0000ff">CNAME</FONT></TT> lookups returns the machine name proper.
<BR>

<P>

<H1><A NAME="SECTION003080000000000000000">
27.8 The <TT>
<FONT COLOR="#0000ff">dig</FONT></TT> Command</A>
</H1>

<P>
<TT>
<FONT COLOR="#0000ff">dig</FONT></TT> stands for <I>domain information groper</I>.
It sends single requests to a DNS server for testing or scripting
purposes (it is similar to <TT>
<FONT COLOR="#0000ff">nslookup</FONT></TT>, but
non-interactive).

<P>
It is usually used like,

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>dig&nbsp;@&#060;server&#062;&nbsp;&#060;domain&#062;&nbsp;&#060;query-type&#062;</code><br>
</FONT></TD></TR></TABLE><P>
where <TT>
<FONT COLOR="#0000ff">&lt;server&gt;</FONT></TT> is the machine running the DNS daemon
to query, <TT>
<FONT COLOR="#0000ff">&lt;domain&gt;</FONT></TT> is the domain of interest and 
<TT>
<FONT COLOR="#0000ff">&lt;query-type&gt;</FONT></TT> is one of <TT>
<FONT COLOR="#0000ff">A</FONT></TT>, <TT>
<FONT COLOR="#0000ff">ANY</FONT></TT>, <TT>
<FONT COLOR="#0000ff">MX</FONT></TT>,
<TT>
<FONT COLOR="#0000ff">NS</FONT></TT>, <TT>
<FONT COLOR="#0000ff">SOA</FONT></TT>, <TT>
<FONT COLOR="#0000ff">HINFO</FONT></TT>,
or <TT>
<FONT COLOR="#0000ff">AXFR</FONT></TT>--of
these, you can read about the non-obvious ones in <TT>
<FONT COLOR="#0000ff">dig</FONT></TT>(1).
<TT>
<FONT COLOR="#0000ff">dig</FONT></TT> can also be used to test an Internet connection.
See Section <A HREF="node23.html#sec:internconntest">20.7.4</A>. 

<P>
Useful is the <TT>
<FONT COLOR="#0000ff">AXFR</FONT></TT> record. For instance

<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code>&nbsp;</code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>dig&nbsp;@dns.dial-up.net&nbsp;icon.co.za&nbsp;AXFR</code><br>
</FONT></TD></TR></TABLE><P>
lists the entire domain of one of our local ISPs.

<P>

<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html2312"
  HREF="node31.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A> 
<A NAME="tex2html2308"
  HREF="rute.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A> 
<A NAME="tex2html2302"
  HREF="node29.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A> 
<A NAME="tex2html2310"
  HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>  
<BR>
<B> Next:</B> <A NAME="tex2html2313"
  HREF="node31.html">28. Network File System,</A>
<B> Up:</B> <A NAME="tex2html2309"
  HREF="rute.html">rute</A>
<B> Previous:</B> <A NAME="tex2html2303"
  HREF="node29.html">26. TCP and UDP</A>
 &nbsp <B>  <A NAME="tex2html2311"
  HREF="node1.html">Contents</A></B> 
<!--End of Navigation Panel-->

</BODY>
</HTML>