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 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550
|
<!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>25. Introduction to IP</TITLE>
<META NAME="description" CONTENT="25. Introduction to IP">
<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="node29.html">
<LINK REL="previous" HREF="node27.html">
<LINK REL="up" HREF="rute.html">
<LINK REL="next" HREF="node29.html">
</HEAD>
<BODY BGCOLOR=#FFFFFF >
<TABLE width="100%" border="0" cellspacing="0" cellpadding="0">
<TR><TD align=left bgcolor="#000000">
<FONT COLOR=white>
<A HREF="http://www.icon.co.za/~psheer/rute-purchase.html"><FONT COLOR=white>Purchase</FONT></A>
</FONT>
</TD><TD align=center bgcolor="#000000">
<FONT COLOR=white>
Copyright © 2002 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>
<A HREF="http://www.icon.co.za/~psheer/rute-home.html"><FONT COLOR=white>Home</FONT></A>
</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="tex2html2268"
HREF="node29.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A>
<A NAME="tex2html2264"
HREF="rute.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A>
<A NAME="tex2html2258"
HREF="node27.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A>
<A NAME="tex2html2266"
HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>
<BR>
<B> Next:</B> <A NAME="tex2html2269"
HREF="node29.html">26. TCP and UDP</A>
<B> Up:</B> <A NAME="tex2html2265"
HREF="rute.html">rute</A>
<B> Previous:</B> <A NAME="tex2html2259"
HREF="node27.html">24. Source and Binary</A>
  <B> <A NAME="tex2html2267"
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="tex2html2270"
HREF="#SECTION002810000000000000000">25.1 Internet Communication</A>
<LI><A NAME="tex2html2271"
HREF="#SECTION002820000000000000000">25.2 Special IP Addresses</A>
<LI><A NAME="tex2html2272"
HREF="#SECTION002830000000000000000">25.3 Network Masks and Addresses</A>
<LI><A NAME="tex2html2273"
HREF="#SECTION002840000000000000000">25.4 Computers on a LAN</A>
<LI><A NAME="tex2html2274"
HREF="#SECTION002850000000000000000">25.5 Configuring Interfaces</A>
<LI><A NAME="tex2html2275"
HREF="#SECTION002860000000000000000">25.6 Configuring Routing</A>
<LI><A NAME="tex2html2276"
HREF="#SECTION002870000000000000000">25.7 Configuring Startup Scripts</A>
<UL>
<LI><A NAME="tex2html2277"
HREF="#SECTION002871000000000000000">25.7.1 RedHat networking scripts</A>
<LI><A NAME="tex2html2278"
HREF="#SECTION002872000000000000000">25.7.2 Debian networking scripts</A>
</UL>
<LI><A NAME="tex2html2279"
HREF="#SECTION002880000000000000000">25.8 Complex Routing -- a Many-Hop Example</A>
<LI><A NAME="tex2html2280"
HREF="#SECTION002890000000000000000">25.9 Interface Aliasing -- Many IPs on One Physical Card</A>
<LI><A NAME="tex2html2281"
HREF="#SECTION0028100000000000000000">25.10 Diagnostic Utilities</A>
<UL>
<LI><A NAME="tex2html2282"
HREF="#SECTION0028101000000000000000">25.10.1 <TT>
<FONT COLOR="#0000ff">ping</FONT></TT></A>
<LI><A NAME="tex2html2283"
HREF="#SECTION0028102000000000000000">25.10.2 <TT>
<FONT COLOR="#0000ff">traceroute</FONT></TT></A>
<LI><A NAME="tex2html2284"
HREF="#SECTION0028103000000000000000">25.10.3 <TT>
<FONT COLOR="#0000ff">tcpdump</FONT></TT></A>
</UL></UL>
<!--End of Table of Child-Links-->
<HR>
<H1><A NAME="SECTION002800000000000000000">
25. Introduction to IP</A>
</H1>
<P>
<A NAME="chap:introtoip"></A><A NAME="chap:ip"></A><I>IP</I> stands for <I>Internet Protocol</I>. It is the method by which data
is transmitted over the Internet.
<P>
<H1><A NAME="SECTION002810000000000000000">
25.1 Internet Communication</A>
</H1>
<P>
At a hardware level, network cards are capable
of transmitting <I>packets</I> (also called <I>datagrams</I>) of data between
one another. A packet contains a small block of, say, 1 kilobyte of data (in
contrast to serial lines, which transmit continuously).
All Internet communication
occurs through transmission of packets, which travel intact, even between machines
on opposite sides of the world.
<P>
Each packet contains a header of 24 bytes or more which precedes the data. Hence,
slightly more than the said 1 kilobyte of data would be found on the wire. When
a packet is transmitted, the header would obviously contain the destination
machine. Each machine is hence given a unique <I>IP address</I>--a
32-bit number. There are no machines on the Internet that do
not have an IP address.
<P>
The header bytes are shown in Table <A HREF="node28.html#table:ipheader">25.1</A>.
<P>
<A NAME="40317"></A>
<TABLE CELLPADDING=1 BORDER="1">
<CAPTION><STRONG>Table 25.1:</STRONG>
IP header bytes</CAPTION>
<TR><TD ALIGN="LEFT"><A NAME="table:ipheader"></A><B>Bytes</B></TD>
<TH ALIGN="LEFT"><B>Description</B></TH>
</TR>
<TR><TD ALIGN="LEFT">0</TD>
<TD ALIGN="LEFT">bits 0-3: Version, bits 4-7: Internet Header Length (IHL)</TD>
</TR>
<TR><TD ALIGN="LEFT">1</TD>
<TD ALIGN="LEFT">Type of service (TOS)</TD>
</TR>
<TR><TD ALIGN="LEFT">2-3</TD>
<TD ALIGN="LEFT">Length</TD>
</TR>
<TR><TD ALIGN="LEFT">4-5</TD>
<TD ALIGN="LEFT">Identification</TD>
</TR>
<TR><TD ALIGN="LEFT">6-7</TD>
<TD ALIGN="LEFT">bits 0-3: Flags, bits 4-15: Offset</TD>
</TR>
<TR><TD ALIGN="LEFT">8</TD>
<TD ALIGN="LEFT">Time to live (TTL)</TD>
</TR>
<TR><TD ALIGN="LEFT">9</TD>
<TD ALIGN="LEFT">Type</TD>
</TR>
<TR><TD ALIGN="LEFT">10-11</TD>
<TD ALIGN="LEFT">Checksum</TD>
</TR>
<TR><TD ALIGN="LEFT">12-15</TD>
<TD ALIGN="LEFT">Source IP address</TD>
</TR>
<TR><TD ALIGN="LEFT">16-19</TD>
<TD ALIGN="LEFT">Destination IP address</TD>
</TR>
<TR><TD ALIGN="LEFT">20-IHL*4-1</TD>
<TD ALIGN="LEFT">Options + padding to round up to four bytes</TD>
</TR>
<TR><TD ALIGN="CENTER" COLSPAN=2>Data begins at IHL*4 and ends at Length-1</TD>
</TR>
</TABLE>
<P>
<B>Version</B> for the mean time is 4, although <I>IP Next Generation</I>
(version 6) is in the (slow) process of deployment. <B>IHL</B> is the length of
the header divided by 4. <B>TOS</B> (<I>Type of Service</I>) is a somewhat esoteric field for tuning
performance and is not explained here. The <B>Length</B> field is the length
in bytes of the entire packet including the header. The <B>Source</B> and
<B>Destination</B> are the IP addresses <I>from</I> and <I>to</I> which the packet
is coming/going.
<P>
<A NAME="sec:lan"></A>
<P>
The above description constitutes the view of the Internet that a machine has.
However, physically, the Internet
consists of many small high-speed networks (like those of a company or a university)
called <I>Local Area Networks</I>, or <I>LAN</I>s.
These are all connected to each other
by lower-speed long distance links. On a LAN, the <I>raw</I> medium of transmission is not a packet but
an Ethernet <I>frame</I>. Frames are analogous to packets (having both a header
and a data portion) but are sized to
be efficient with particular hardware. IP packets are encapsulated within frames,
where the IP packet fits within the <B>Data</B> part of the frame. A frame
may, however, be too small to hold an entire IP packet, in which case the IP packet
is split into several smaller packets. This group of smaller IP packets is then
given an identifying number, and each smaller packet will then have the <B>Identification</B>
field set with that number and the <B>Offset</B> field set to indicate its
position within the actual packet. On the other side of the connection, the destination machine
will reconstruct a packet from all the smaller subpackets that have the same
<B>Identification</B> field.
<P>
The convention for writing an IP address in human readable form is
<I>dotted decimal</I> notation like <TT>
<FONT COLOR="#0000ff">152.2.254.81</FONT></TT>, where
each number is a byte and is hence in the range of 0 to 255.
Hence the entire address <I>space</I> is in the range of
<TT>
<FONT COLOR="#0000ff">0.0.0.0</FONT></TT> to
<TT>
<FONT COLOR="#0000ff">255.255.255.255</FONT></TT>. To further organize
the assignment of addresses, each 32-bit address is divided into
two parts, a <I>network</I> and a <I>host</I> part of the
address, as shown in Figure <A HREF="node28.html#fig:ipaddressclasses">25.1</A>.
<P>
<P></P>
<DIV ALIGN="CENTER"><A NAME="fig:ipaddressclasses"></A><A NAME="40666"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 25.1:</STRONG>
IP address classes</CAPTION>
<TR><TD><IMG
WIDTH="556" HEIGHT="119" BORDER="0"
SRC="img27.png"
ALT="\begin{figure}\begin{center}
\setlength{\unitlength}{2.400000pt}\begin{picture}(...
...}\}
% put(96.00,21.50)\{ circle*\{1.20\}\}
\end{picture}\end{center}\end{figure}"></TD></TR>
</TABLE>
</DIV><P></P>
<P>
The network part of the address designates the LAN, and the host part the particular
machine on the LAN. Now, because it was unknown at the time of specification
whether there would one day be more LANs or more machines per LAN, three different
classes of address were created.
<P>
<I>Class A</I> addresses begin with the first
bit of the network part set to 0 (hence, a Class A address always has the first
dotted decimal number less than <TT>
<FONT COLOR="#0000ff">128</FONT></TT>). The next 7 bits give the identity of the
LAN, and the remaining 24 bits give the identity of an actual machine on that
LAN. A Class B address begins with a 1 and then a 0 (first decimal number is <TT>
<FONT COLOR="#0000ff">128</FONT></TT>
through <TT>
<FONT COLOR="#0000ff">191</FONT></TT>). The next 14 bits give the LAN, and the remaining 16 bits give the
machine. Most universities, like the address above, are Class B addresses.
Lastly, Class C addresses start with a 1 1 0 (first decimal number is <TT>
<FONT COLOR="#0000ff">192</FONT></TT> through
<TT>
<FONT COLOR="#0000ff">223</FONT></TT>), and the next 21 bits and then the next 8 bits are the LAN and machine,
respectively. Small companies tend use Class C addresses.
<P>
In practice, few organizations require Class A addresses. A university
or large company might use a Class B address but then would have its own
further subdivisions, like using the third dotted decimal as a department (bits
16 through 23) and the last dotted decimal (bits 24 through 31) as the machine
within that department. In this way the LAN becomes a micro-Internet in itself. Here,
the LAN is called a <I>network</I> and the various departments are each called
a <I>subnet</I>.
<P>
<H1><A NAME="SECTION002820000000000000000">
25.2 Special IP Addresses</A>
</H1>
<P>
Some special-purposes IP addresses are never used
on the open Internet. <TT>
<FONT COLOR="#0000ff">192.168.0.0</FONT></TT> through <TT>
<FONT COLOR="#0000ff">192.168.255.255</FONT></TT> are private
addresses perhaps used inside a local LAN that does not communicate directly with
the Internet. <TT>
<FONT COLOR="#0000ff">127.0.0.0</FONT></TT> through <TT>
<FONT COLOR="#0000ff">127.255.255.255</FONT></TT> are used for communication
with the <I>localhost</I>--that is, the machine itself. Usually, <TT>
<FONT COLOR="#0000ff">127.0.0.1</FONT></TT>
is an IP address pointing to the machine itself.
Further, <TT>
<FONT COLOR="#0000ff">172.16.0.0</FONT></TT> through <TT>
<FONT COLOR="#0000ff">172.31.255.255</FONT></TT> are additional private addresses
for very large internal networks, and <TT>
<FONT COLOR="#0000ff">10.0.0.0</FONT></TT> through <TT>
<FONT COLOR="#0000ff">10.255.255.255</FONT></TT> are
for even larger ones.
<P>
<H1><A NAME="SECTION002830000000000000000">
25.3 Network Masks and Addresses</A>
</H1>
<P>
Consider again the example of a university with a Class B
address. It might have an IP address range of
<TT>
<FONT COLOR="#0000ff">137.158.0.0</FONT></TT> through <TT>
<FONT COLOR="#0000ff">137.158.255.255</FONT></TT>. Assume it was decided that
the astronomy department should get 512 of its own IP
addresses, <TT>
<FONT COLOR="#0000ff">137.158.26.0</FONT></TT> through <TT>
<FONT COLOR="#0000ff">137.158.27.255</FONT></TT>. We say
that astronomy has a <I>network address</I> of <TT>
<FONT COLOR="#0000ff">137.158.26.0</FONT></TT>.
The machines there all have a <I>network mask</I> of
<TT>
<FONT COLOR="#0000ff">255.255.254.0</FONT></TT>. A particular machine in astronomy may
have an <I>IP address</I> of <TT>
<FONT COLOR="#0000ff">137.158.27.158</FONT></TT>. This
terminology is used later. Figure <A HREF="node28.html#fig:netmaskeg">25.2</A> illustrates
this example.
<P>
<P></P>
<DIV ALIGN="CENTER"><A NAME="fig:netmaskeg"></A><A NAME="40761"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 25.2:</STRONG>
Dividing an address into network and host portions</CAPTION>
<TR><TD><IMG
WIDTH="602" HEIGHT="165" ALIGN="BOTTOM" BORDER="0"
SRC="img28.png"
ALT="\begin{center}
{\small\begin{tabular}{\vert l \vert c @{.} c @{.} c @{.} c \vert...
...~0000~000\!\overbrace{1~1001~1110}$\ \\
\cline{1-6}
\end{tabular}}
\end{center}"></TD></TR>
</TABLE>
</DIV><P></P>
<P>
<H1><A NAME="SECTION002840000000000000000">
25.4 Computers on a LAN</A>
</H1>
<P>
In this section we will use the term LAN to indicate a network of computers that are all more or less
connected directly together by Ethernet cables (this is common for small businesses with up to
about 50 machines). Each machine has an Ethernet card which is referred to as
<TT>
<FONT COLOR="#0000ff">eth0</FONT></TT> throughout all command-line operations. If there is more than
one card on a single machine, then these are named <TT>
<FONT COLOR="#0000ff">eth0</FONT></TT>, <TT>
<FONT COLOR="#0000ff">eth1</FONT></TT>, <TT>
<FONT COLOR="#0000ff">eth2</FONT></TT>, etc., and
are each called a <I>network interface</I>
(or just <I>interface</I>, or sometimes <I>Ethernet port</I>) of the machine.
<P>
LANs work as follows.
Network cards transmit a frame to the LAN, and other network cards read that
frame from the LAN. If any one network card transmits a frame, then <I>all</I>
other network cards can see that frame.
If a card starts to transmit a frame
while another card is in the process of transmitting a frame, then a
<I>clash</I>
is said to have occurred, and the card waits a random amount of time and then
tries again. Each network card has a physical address of 48 bits called the
<I>hardware address</I> (which is inserted at the time of its manufacture
and has nothing to do with IP addresses). Each frame has a destination address in
its header that tells what network card it is destined for, so that network
cards ignore frames that are not addressed to them.
<P>
Since frame transmission is governed by the network cards, the destination
hardware address must be determined from the destination IP address before
a packet is sent to a particular machine. This is done is through the
<I>Address Resolution Protocol</I>
(ARP). A machine will transmit
a special packet that asks ``What hardware address is this IP address?'' The
guilty machine then responds, and the transmitting machine stores the result
for future reference. Of course, if you suddenly switch network cards, then other
machines on the LAN will have the wrong information, so ARP has time-outs and
re-requests built into the protocol. Try typing the command
<TT>
<FONT COLOR="#0000ff">arp</FONT></TT> to get
a list of hardware address to IP mappings.
<P>
<H1><A NAME="SECTION002850000000000000000">
25.5 Configuring Interfaces</A>
</H1>
<P>
Most distributions have a generic way
to configure your interfaces. Here, however, we first look at a
complete network configuration using only raw networking commands.
<P>
We first create a <TT>
<FONT COLOR="#0000ff">lo</FONT></TT> interface. This is called
the <I>loopback</I> device (and has nothing to do with loopback block devices:
<TT>
<FONT COLOR="#0000ff">/dev/loop</FONT></TT><I>?</I> files). The loopback device is an imaginary network card that is
used to communicate with the machine itself; for instance, if you are
<TT>
<FONT COLOR="#0000ff">telnet</FONT></TT>ing to the local machine, you are actually connecting
via the loopback device. The <TT>
<FONT COLOR="#0000ff">ifconfig</FONT></TT> (<TT>
<FONT COLOR="#0000ff">i</FONT></TT><I>nter</I><TT>
<FONT COLOR="#0000ff">f</FONT></TT><I>ace</I> <TT>
<FONT COLOR="#0000ff">config</FONT></TT><I>ure</I>)
command is used to do anything with interfaces. First, 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> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/ifconfig lo down</code><br>
<code>/sbin/ifconfig eth0 down</code><br>
</FONT></TD></TR></TABLE><P>
to delete any existing interfaces, then 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> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/ifconfig lo 127.0.0.1</code><br>
</FONT></TD></TR></TABLE><P>
which creates the loopback interface.
<P>
Create the Ethernet interface with:
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/ifconfig eth0 192.168.3.9 broadcast 192.168.3.255 netmask 255.255.255.0</code><br>
</FONT></TD></TR></TABLE><P>
The <TT>
<FONT COLOR="#0000ff">broadcast</FONT></TT> address is a special
address that all machines respond to. It is usually the first or last address
of the particular network.
<P>
Now 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> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/ifconfig</code><br>
</FONT></TD></TR></TABLE><P>
to view the interfaces. The output will be
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>5</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>10</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>eth0 Link encap:Ethernet HWaddr 00:00:E8:3B:2D:A2 </code><br>
<code> inet addr:192.168.3.9 Bcast:192.168.3.255 Mask:255.255.255.0</code><br>
<code> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1</code><br>
<code> RX packets:1359 errors:0 dropped:0 overruns:0 frame:0</code><br>
<code> TX packets:1356 errors:0 dropped:0 overruns:0 carrier:0</code><br>
<code> collisions:0 txqueuelen:100 </code><br>
<code> Interrupt:11 Base address:0xe400 </code><br>
<code> </code><br>
<code>lo Link encap:Local Loopback </code><br>
<code> inet addr:127.0.0.1 Mask:255.0.0.0</code><br>
<code> UP LOOPBACK RUNNING MTU:3924 Metric:1</code><br>
<code> RX packets:53175 errors:0 dropped:0 overruns:0 frame:0</code><br>
<code> TX packets:53175 errors:0 dropped:0 overruns:0 carrier:0</code><br>
<code> collisions:0 txqueuelen:0 </code><br>
</FONT></TD></TR></TABLE><P>
which shows various interesting bits, like the 48-bit
hardware address of the network card (hex bytes <TT>
<FONT COLOR="#0000ff">00:00:E8:3B:2D:A2</FONT></TT>).
<P>
<H1><A NAME="SECTION002860000000000000000">
25.6 Configuring Routing</A>
</H1>
<P>
The interfaces are now active. However, nothing tells
the kernel what packets should go to what interface, even
though we might expect such behavior to happen on its own.
With U<SMALL>NIX</SMALL>, you must explicitly tell the kernel to send particular
packets to particular interfaces.
<P>
Any packet arriving through any interface is pooled by the
kernel. The kernel then looks at each packet's destination
address and decides, based on the destination, where it should
be sent. It doesn't matter where the packet came from; once the
kernel <I>has</I> the packet, it's what its destination address says that
matters. It is up to the rest of the network to ensure that packets
do not arrive at the wrong interfaces in the first place.
<P>
We know that any packet having the network address
<TT>
<FONT COLOR="#0000ff">127.</FONT></TT><I>???</I><TT>
<FONT COLOR="#0000ff">.</FONT></TT><I>???</I><TT>
<FONT COLOR="#0000ff">.</FONT></TT><I>???</I> must go
to the loopback device (this is more or less a convention).
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> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo</code><br>
</FONT></TD></TR></TABLE><P>
adds a <I>route</I> to the
network <TT>
<FONT COLOR="#0000ff">127.0.0.0</FONT></TT>, albeit
an imaginary one.
<P>
The <TT>
<FONT COLOR="#0000ff">eth0</FONT></TT> device can be routed as follows:
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/route add -net 192.168.3.0 netmask 255.255.255.0 eth0</code><br>
</FONT></TD></TR></TABLE><P>
The command to display the current routes is
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/route -n</code><br>
</FONT></TD></TR></TABLE><P>
(<TT>
<FONT COLOR="#0000ff">-n</FONT></TT> causes <TT>
<FONT COLOR="#0000ff">route</FONT></TT> to not print
IP addresses as host names) with the following output:
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>Kernel IP routing table</code><br>
<code>Destination Gateway Genmask Flags Metric Ref Use Iface</code><br>
<code>127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo</code><br>
<code>192.168.3.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0</code><br>
</FONT></TD></TR></TABLE><P>
This output has the meaning, ``packets with destination address <TT>
<FONT COLOR="#0000ff">127.0.0.0/255.0.0.0</FONT></TT> <FONT COLOR="#ffa500">[The
notation <I>network/mask</I> is often used to denote ranges of IP address.]</FONT>must be sent to the <TT>
<FONT COLOR="#0000ff">lo</FONT></TT>opback device,'' and ``packets with destination address
<TT>
<FONT COLOR="#0000ff">192.168.3.0/255.255.255.0</FONT></TT> must be sent to <TT>
<FONT COLOR="#0000ff">eth0</FONT></TT>.'' <TT>
<FONT COLOR="#0000ff">Gateway</FONT></TT>
is zero, hence, is not set (see the following commands).
<P>
The routing table now routes <TT>
<FONT COLOR="#0000ff">127.</FONT></TT> and
<TT>
<FONT COLOR="#0000ff">192.168.3.</FONT></TT> packets. Now we need a route
for the remaining possible IP addresses. U<SMALL>NIX</SMALL> can have a route
that says to send packets with particular destination IP
addresses to another machine on the LAN, from whence they
might be forwarded elsewhere. This is sometimes called the
<I>gateway</I> machine. The command is:
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/route add -net <network-address> netmask <netmask> gw \</code><br>
<code> <gateway-ip-address> <interface></code><br>
</FONT></TD></TR></TABLE><P>
This is the most general form of the command, but it's often
easier to just 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> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/route add default gw <gateway-ip-address> <interface></code><br>
</FONT></TD></TR></TABLE><P>
when we want to add a route that applies to all remaining packets.
This route is called the <I>default gateway</I>.
<TT>
<FONT COLOR="#0000ff">default</FONT></TT> signifies all packets; it is the same as
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/route add -net 0.0.0.0 netmask 0.0.0.0 gw <gateway-ip-address> \</code><br>
<code> <interface></code><br>
</FONT></TD></TR></TABLE><P>
but since routes are ordered according to <TT>
<FONT COLOR="#0000ff">netmask</FONT></TT>,
<I>more specific routes are used in preference to less specific
ones</I>.
<P>
Finally, you can set your host name with:
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>hostname cericon.cranzgot.co.za</code><br>
</FONT></TD></TR></TABLE><P>
<P>
A summary of the example commands so far is
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>5</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/ifconfig lo down</code><br>
<code>/sbin/ifconfig eth0 down</code><br>
<code>/sbin/ifconfig lo 127.0.0.1</code><br>
<code>/sbin/ifconfig eth0 192.168.3.9 broadcast 192.168.3.255 netmask 255.255.255.0</code><br>
<code>/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo</code><br>
<code>/sbin/route add -net 192.168.3.0 netmask 255.255.255.0 eth0</code><br>
<code>/sbin/route add default gw 192.168.3.254 eth0</code><br>
<code>hostname cericon.cranzgot.co.za</code><br>
</FONT></TD></TR></TABLE><P>
<P>
<I>Although these 7 commands will get your network working,
you should not do such a manual configuration. The next section
explains how to configure your startup scripts.</I>
<P>
<H1><A NAME="SECTION002870000000000000000">
25.7 Configuring Startup Scripts</A>
</H1>
<P>
Most distributions will have a modular and extensible system of
startup scripts that initiate networking.
<P>
<H2><A NAME="SECTION002871000000000000000">
25.7.1 RedHat networking scripts</A>
</H2>
<P>
RedHat systems contain the directory <TT>
<FONT COLOR="#0000ff">/etc/sysconfig/</FONT></TT>,
which contains configuration files to automatically bring up networking.
<P>
The file <TT>
<FONT COLOR="#0000ff">/etc/sysconfig/network-scripts/ifcfg-eth0</FONT></TT>
contains:
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>5</code></font><code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>DEVICE=eth0</code><br>
<code>IPADDR=192.168.3.9</code><br>
<code>NETMASK=255.255.255.0</code><br>
<code>NETWORK=192.168.3.0</code><br>
<code>BROADCAST=192.168.3.255</code><br>
<code>ONBOOT=yes</code><br>
</FONT></TD></TR></TABLE><P>
<P>
The file <TT>
<FONT COLOR="#0000ff">/etc/sysconfig/network</FONT></TT>
contains:
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>NETWORKING=yes</code><br>
<code>HOSTNAME=cericon.cranzgot.co.za</code><br>
<code>GATEWAY=192.168.3.254</code><br>
</FONT></TD></TR></TABLE><P>
<P>
You can see that these two files are equivalent to the example
configuration done above. These two files can take an enormous
number of options for the various protocols besides IP,
but this is the most common configuration.
<P>
The file <TT>
<FONT COLOR="#0000ff">/etc/sysconfig/network-scripts/ifcfg-lo</FONT></TT> for the
loopback device will be configured automatically at installation;
you should never need to edit it.
<P>
To stop and start networking (i.e., to bring up and down the
interfaces and routing), type (alternative commands in parentheses):
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/etc/init.d/network stop</code><br>
<code>( /etc/rc.d/init.d/network stop )</code><br>
<code>/etc/init.d/network start</code><br>
<code>( /etc/rc.d/init.d/network start )</code><br>
</FONT></TD></TR></TABLE><P>
which will indirectly read your <TT>
<FONT COLOR="#0000ff">/etc/sysconfig/</FONT></TT>
files.
<P>
You can add further files, say, <TT>
<FONT COLOR="#0000ff">ifcfg-eth1</FONT></TT> (under <TT>
<FONT COLOR="#0000ff">/etc/sysconfig/network-scripts/</FONT></TT>)
for a secondary Ethernet device. For example,
<TT>
<FONT COLOR="#0000ff">ifcfg-eth1</FONT></TT> could contain
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>5</code></font><code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>DEVICE=eth1</code><br>
<code>IPADDR=192.168.4.1</code><br>
<code>NETMASK=255.255.255.0</code><br>
<code>NETWORK=192.168.4.0</code><br>
<code>BROADCAST=192.168.4.255</code><br>
<code>ONBOOT=yes</code><br>
</FONT></TD></TR></TABLE><P>
and then run <TT>
<FONT COLOR="#0000ff">echo "1" > /proc/sys/net/ipv4/ip_forward</FONT></TT>
to
enable packet forwarding between your two interfaces.
<P>
<H2><A NAME="SECTION002872000000000000000">
25.7.2 Debian networking scripts</A>
</H2>
<P>
Debian, on the other hand, has a directory <TT>
<FONT COLOR="#0000ff">/etc/network/</FONT></TT> containing a
file <TT>
<FONT COLOR="#0000ff">/etc/network/interfaces</FONT></TT>. <FONT COLOR="#ffa500">[As usual, Debian has a neat and
clean approach.]</FONT> (See also <TT>
<FONT COLOR="#0000ff">interfaces</FONT></TT>(5).) For the same configuration
as above, this file would contain:
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>5</code></font><code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>iface lo inet loopback</code><br>
<code>iface eth0 inet static</code><br>
<code> address 192.168.3.9</code><br>
<code> netmask 255.255.255.0</code><br>
<code> gateway 192.168.3.254</code><br>
</FONT></TD></TR></TABLE><P>
<P>
The file <TT>
<FONT COLOR="#0000ff">/etc/network/options</FONT></TT>
contains the same forwarding (and some other) options:
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>ip_forward=no</code><br>
<code>spoofprotect=yes</code><br>
<code>syncookies=no</code><br>
</FONT></TD></TR></TABLE><P>
<P>
To stop and start networking (i.e., bring up and down the
interfaces and routing), 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> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/etc/init.d/networking stop</code><br>
<code>/etc/init.d/networking start</code><br>
</FONT></TD></TR></TABLE><P>
which will indirectly read your
<TT>
<FONT COLOR="#0000ff">/etc/network/interfaces</FONT></TT> file.
<P>
Actually, the <TT>
<FONT COLOR="#0000ff">/etc/init.d/networking</FONT></TT> script merely runs
the <TT>
<FONT COLOR="#0000ff">ifup</FONT></TT> and <TT>
<FONT COLOR="#0000ff">ifdown</FONT></TT> commands.
See <TT>
<FONT COLOR="#0000ff">ifup</FONT></TT>(8). You can alternatively run these commands directly for finer control.
<P>
We add further interfaces similar to the RedHat example above by appending
to the <TT>
<FONT COLOR="#0000ff">/etc/network/interfaces</FONT></TT> file.
The Debian equivalent is,
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>5</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>iface lo inet loopback</code><br>
<code>iface eth0 inet static</code><br>
<code> address 192.168.3.9</code><br>
<code> netmask 255.255.255.0</code><br>
<code> gateway 192.168.3.254</code><br>
<code>iface eth1 inet static</code><br>
<code> address 192.168.4.1</code><br>
<code> netmask 255.255.255.0</code><br>
</FONT></TD></TR></TABLE><P>
and then set <TT>
<FONT COLOR="#0000ff">ip_forward=yes</FONT></TT> in your <TT>
<FONT COLOR="#0000ff">/etc/network/options</FONT></TT> file.
<P>
Finally, whereas RedHat sets its host name from the line <TT>
<FONT COLOR="#0000ff">HOSTNAME=</FONT></TT>...
in <TT>
<FONT COLOR="#0000ff">/etc/sysconfig/network</FONT></TT>, Debian sets it from the contents of the
file <TT>
<FONT COLOR="#0000ff">/etc/hostname</FONT></TT>, which, in the present case, would contain just
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>cericon.cranzgot.co.za</code><br>
</FONT></TD></TR></TABLE><P>
<P>
<H1><A NAME="SECTION002880000000000000000">
25.8 Complex Routing -- a Many-Hop Example</A>
</H1>
<P>
Consider two distant LANs that need to communicate. Two dedicated
machines, one on each LAN, are linked by some alternative method (in
this case, a permanent serial line), as shown in Figure <A HREF="node28.html#fig:tworemoteconn">25.3</A>.
<P>
<P></P>
<DIV ALIGN="CENTER"><A NAME="fig:tworemoteconn"></A><A NAME="40942"></A>
<TABLE>
<CAPTION ALIGN="BOTTOM"><STRONG>Figure 25.3:</STRONG>
Two remotely connected networks</CAPTION>
<TR><TD><IMG
BORDER="0"
SRC="rmtlynet.png"
ALT="\begin{figure}\begin{center}
{\setlength{\epsfxsize}{\textwidth}\epsfbox{route.eps}}
\end{center}\end{figure}"></TD></TR>
</TABLE>
</DIV><P></P>
<P>
This arrangement can be summarized by five machines
<B>X</B>, <B>A</B>, <B>B</B>, <B>C</B>, and <B>D</B>. Machines
<B>X</B>, <B>A</B>, and <B>B</B> form LAN <B>1</B> on subnet <TT>
<FONT COLOR="#0000ff">192.168.1.0/26</FONT></TT>.
Machines <B>C</B> and <B>D</B> form LAN <B>2</B> on subnet
<TT>
<FONT COLOR="#0000ff">192.168.1.128/26</FONT></TT>. Note how we use the ``<TT>
<FONT COLOR="#0000ff">/26</FONT></TT>'' to indicate
that only the first 26 bits are network address bits, while the remaining
6 bits are host address bits. This means that we can have at most
<FONT COLOR="#0000ff"><IMG
WIDTH="64" HEIGHT="17" ALIGN="BOTTOM" BORDER="0"
SRC="img30.png"
ALT="\bgroup\color{blue}$2^6~=~64$\egroup"></FONT> IP addresses on each of LAN <B>1</B> and <B>2</B>.
Our dedicated serial link comes between machines <B>B</B> and
<B>C</B>.
<P>
Machine <B>X</B> has IP address
<TT>
<FONT COLOR="#0000ff">192.168.1.1</FONT></TT>. This machine is the
gateway to the Internet. The Ethernet port of machine <B>B</B>
is simply configured with an IP address of
<TT>
<FONT COLOR="#0000ff">192.168.1.2</FONT></TT> with a default gateway of <TT>
<FONT COLOR="#0000ff">192.168.1.1</FONT></TT>. Note
that the broadcast address is <TT>
<FONT COLOR="#0000ff">192.168.1.63</FONT></TT> (the last 6 bits set
to 1).
<P>
The Ethernet port of machine <B>C</B> is configured with
an IP address of <TT>
<FONT COLOR="#0000ff">192.168.1.129</FONT></TT>. No default gateway should
be set until serial line is configured.
<P>
We will make the network between <B>B</B> and <B>C</B> subnet
<TT>
<FONT COLOR="#0000ff">192.168.1.192/26</FONT></TT>. It is effectively a LAN on its own, even
though only two machines can ever be connected. Machines
<B>B</B> and <B>C</B> will have IP addresses <TT>
<FONT COLOR="#0000ff">192.168.1.252</FONT></TT>
and <TT>
<FONT COLOR="#0000ff">192.168.1.253</FONT></TT>, respectively, on their facing interfaces.
<P>
This is a real-life example with an unreliable serial
link. To keep the link up requires <TT>
<FONT COLOR="#0000ff">pppd</FONT></TT> and a shell script
to restart the link if it dies. The <TT>
<FONT COLOR="#0000ff">pppd</FONT></TT> program is covered
in Chapter <A HREF="node44.html#chap:pppdialup">41</A>. The script for Machine <B>B</B>
is:
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>5</code></font><code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>#!/bin/sh</code><br>
<code>while true ; do</code><br>
<code> pppd lock local mru 296 mtu 296 nodetach nocrtscts nocdtrcts \</code><br>
<code> 192.168.1.252:192.168.1.253 /dev/ttyS0 115200 noauth \</code><br>
<code> lcp-echo-interval 1 lcp-echo-failure 2 lcp-max-terminate 1 lcp-restart 1</code><br>
<code>done</code><br>
</FONT></TD></TR></TABLE><P>
Note that if the link were an Ethernet link instead
(on a second Ethernet card), and/or a genuine LAN between machines
<B>B</B> and <B>C</B> (with subnet <TT>
<FONT COLOR="#0000ff">192.168.1.252/26</FONT></TT>),
then the same script would be just
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/ifconfig eth1 192.168.1.252 broadcast 192.168.1.255 netmask \</code><br>
<code> 255.255.255.192</code><br>
</FONT></TD></TR></TABLE><P>
in which case all ``<TT>
<FONT COLOR="#0000ff">ppp0</FONT></TT>'' would change to ``<TT>
<FONT COLOR="#0000ff">eth1</FONT></TT>''
in the scripts that follow.
<P>
Routing on machine <B>B</B> is achieved with the following
script, provided the link is up. This script must be executed
whenever <TT>
<FONT COLOR="#0000ff">pppd</FONT></TT> has negotiated
the connection and can therefore be placed in the file <TT>
<FONT COLOR="#0000ff">/etc/pppd/ip-up</FONT></TT>,
which <TT>
<FONT COLOR="#0000ff">pppd</FONT></TT> executes automatically as soon as the <TT>
<FONT COLOR="#0000ff">ppp0</FONT></TT>
interface is available:
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>5</code></font><code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/route del default</code><br>
<code>/sbin/route add -net 192.168.1.192 netmask 255.255.255.192 dev ppp0</code><br>
<code>/sbin/route add -net 192.168.1.128 netmask 255.255.255.192 gw 192.168.1.253</code><br>
<code>/sbin/route add default gw 192.168.1.1</code><br>
<code> </code><br>
<code>echo 1 > /proc/sys/net/ipv4/ip_forward</code><br>
</FONT></TD></TR></TABLE><P>
<P>
Our full routing table and interface list for machine <B>B</B> then looks
like this <FONT COLOR="#ffa500">[RedHat 6 likes to add (redundant) explicit routes to each device.
These may not be necessary on your system]</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> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>5</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>10</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>15</code></font><code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>Kernel IP routing table</code><br>
<code>Destination Gateway Genmask Flags Metric Ref Use Iface</code><br>
<code>192.168.1.2 0.0.0.0 255.255.255.255 UH 0 0 0 eth0</code><br>
<code>192.168.1.253 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0</code><br>
<code>192.168.1.0 0.0.0.0 255.255.255.192 U 0 0 0 eth0</code><br>
<code>192.168.1.192 0.0.0.0 255.255.255.192 U 0 0 0 ppp0</code><br>
<code>192.168.1.128 192.168.1.253 255.255.255.192 UG 0 0 0 ppp0</code><br>
<code>127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo</code><br>
<code>0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0</code><br>
<code> </code><br>
<code>eth0 Link encap:Ethernet HWaddr 00:A0:24:75:3B:69 </code><br>
<code> inet addr:192.168.1.2 Bcast:192.168.1.63 Mask:255.255.255.192</code><br>
<code>lo Link encap:Local Loopback </code><br>
<code> inet addr:127.0.0.1 Mask:255.0.0.0</code><br>
<code>ppp0 Link encap:Point-to-Point Protocol </code><br>
<code> inet addr:192.168.1.252 P-t-P:192.168.1.253 Mask:255.255.255.255</code><br>
</FONT></TD></TR></TABLE><P>
<P>
On machine <B>C</B> we can similarly run the script,
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>5</code></font><code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>#!/bin/sh</code><br>
<code>while true ; do</code><br>
<code> pppd lock local mru 296 mtu 296 nodetach nocrtscts nocdtrcts \</code><br>
<code> 192.168.1.253:192.168.1.252 /dev/ttyS0 115200 noauth \</code><br>
<code> lcp-echo-interval 1 lcp-echo-failure 2 lcp-max-terminate 1 lcp-restart 1</code><br>
<code>done</code><br>
</FONT></TD></TR></TABLE><P>
and then create routes with
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>5</code></font><code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/route del default</code><br>
<code>/sbin/route add -net 192.168.1.192 netmask 255.255.255.192 dev ppp0</code><br>
<code>/sbin/route add default gw 192.168.1.252</code><br>
<code> </code><br>
<code>echo 1 > /proc/sys/net/ipv4/ip_forward</code><br>
</FONT></TD></TR></TABLE><P>
<P>
Our full routing table for machine <B>C</B> then looks 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> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>5</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>10</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>15</code></font><code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>Kernel IP routing table</code><br>
<code>Destination Gateway Genmask Flags Metric Ref Use Iface</code><br>
<code>192.168.1.129 0.0.0.0 255.255.255.255 UH 0 0 0 eth0</code><br>
<code>192.168.1.252 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0</code><br>
<code>192.168.1.192 0.0.0.0 255.255.255.192 U 0 0 0 ppp0</code><br>
<code>192.168.1.128 0.0.0.0 255.255.255.192 U 0 0 0 eth0</code><br>
<code>127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo</code><br>
<code>0.0.0.0 192.168.1.252 0.0.0.0 UG 0 0 0 ppp0</code><br>
<code> </code><br>
<code>eth0 Link encap:Ethernet HWaddr 00:A0:CC:D5:D8:A7 </code><br>
<code> inet addr:192.168.1.129 Bcast:192.168.1.191 Mask:255.255.255.192</code><br>
<code>lo Link encap:Local Loopback </code><br>
<code> inet addr:127.0.0.1 Mask:255.0.0.0</code><br>
<code>ppp0 Link encap:Point-to-Point Protocol </code><br>
<code> inet addr:192.168.1.253 P-t-P:192.168.1.252 Mask:255.255.255.255</code><br>
</FONT></TD></TR></TABLE><P>
<P>
Machine <B>D</B> can be configured like any ordinary machine on a LAN.
It just sets its default gateway to <TT>
<FONT COLOR="#0000ff">192.168.1.129</FONT></TT>. Machine <B>A</B>,
however, has to know to send packets destined for subnet <TT>
<FONT COLOR="#0000ff">192.168.1.128/26</FONT></TT>
<I>through</I> machine <B>B</B>. Its routing table has an extra entry
for the <TT>
<FONT COLOR="#0000ff">192.168.1.128/26</FONT></TT> LAN. The full routing table for machine
<B>A</B> is:
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>5</code></font><code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>Kernel IP routing table</code><br>
<code>Destination Gateway Genmask Flags Metric Ref Use Iface</code><br>
<code>192.168.1.0 0.0.0.0 255.255.255.192 U 0 0 0 eth0</code><br>
<code>192.168.1.128 192.168.1.2 255.255.255.192 UG 0 0 0 eth0</code><br>
<code>127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo</code><br>
<code>0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0</code><br>
</FONT></TD></TR></TABLE><P>
<P>
To avoid having to add this extra route on machine <B>A</B>,
you can instead add the same route on machine <B>X</B>. This may
seem odd, but all that this means is that packets originating from <B>A</B> destined
for LAN 2 first <I>try</I> to go through <B>X</B> (since <B>A</B> has only one route),
and are then redirected <I>by</I> <B>X</B> to go through <B>B</B>.
<P>
The preceding configuration allowed machines to properly send
packets between machines <B>A</B> and <B>D</B> and out through the
Internet. One caveat: <TT>
<FONT COLOR="#0000ff">ping</FONT></TT> sometimes did not work even though
<TT>
<FONT COLOR="#0000ff">telnet</FONT></TT> did. This may be a peculiarity of the kernel version we were
using, **<I>shrug</I>**.
<P>
<H1><A NAME="SECTION002890000000000000000">
25.9 Interface Aliasing -- Many IPs on One Physical Card</A>
</H1>
<P>
<A NAME="ref:interfacealiasing"></A>
<P>
(The file <TT>
<FONT COLOR="#0000ff">/usr/src/linux/Documentation/networking/alias.txt</FONT></TT> contains
the kernel documentation on this.)
<P>
If you have one network card which you would like to double as several
different IP addresses, you can. Simply name
the interface <TT>
<FONT COLOR="#0000ff">eth0:</FONT></TT><I>n</I> where <I>n</I> is from <TT>
<FONT COLOR="#0000ff">0</FONT></TT>
to some large integer. You can use <TT>
<FONT COLOR="#0000ff">ifconfig</FONT></TT> as before as many
times as you like on the same network card--
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
<code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>/sbin/ifconfig eth0:0 192.168.4.1 broadcast 192.168.4.255 netmask 255.255.255.0</code><br>
<code>/sbin/ifconfig eth0:1 192.168.5.1 broadcast 192.168.5.255 netmask 255.255.255.0</code><br>
<code>/sbin/ifconfig eth0:2 192.168.6.1 broadcast 192.168.6.255 netmask 255.255.255.0</code><br>
</FONT></TD></TR></TABLE><P>
--in <I>addition</I> to your regular <TT>
<FONT COLOR="#0000ff">eth0</FONT></TT> device. Here, the
same interface can communicate to three LANs having networks
<TT>
<FONT COLOR="#0000ff">192.168.4.0</FONT></TT>, <TT>
<FONT COLOR="#0000ff">192.168.5.0</FONT></TT>, and <TT>
<FONT COLOR="#0000ff">192.168.6.0</FONT></TT>. Don't forget
to add routes to these networks as above.
<P>
<H1><A NAME="SECTION0028100000000000000000">
25.10 Diagnostic Utilities</A>
</H1>
<P>
It is essential to know how to inspect and test your network
to resolve problems. The standard U<SMALL>NIX</SMALL> utilities are explained
here.
<P>
<H2><A NAME="SECTION0028101000000000000000">
25.10.1 <TT>
<FONT COLOR="#0000ff">ping</FONT></TT></A>
</H2>
<P>
<A NAME="sec:ping"></A>
<P>
The <TT>
<FONT COLOR="#0000ff">ping</FONT></TT> command is the most common network utility.
IP packets come in three types on the Internet, represented
in the <B>Type</B> field of the IP header: <I>UDP</I>,
<I>TCP</I>, and <I>ICMP</I>. (The first two, discussed
later, represent the two basic methods of communication
between two programs running on different machines.)
<I>ICMP</I> stands for <I>Internet Control Message Protocol</I>
and is a diagnostic packet that is responded to in a special way.
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> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>ping metalab.unc.edu</code><br>
</FONT></TD></TR></TABLE><P>
or specify some other well-known host. You will get output
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> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-1"><code>5</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>PING metalab.unc.edu (152.19.254.81) from 192.168.3.9 : 56(84) bytes of data.</code><br>
<code>64 bytes from 152.19.254.81: icmp_seq=0 ttl=238 time=1059.1 ms</code><br>
<code>64 bytes from 152.19.254.81: icmp_seq=1 ttl=238 time=764.9 ms</code><br>
<code>64 bytes from 152.19.254.81: icmp_seq=2 ttl=238 time=858.8 ms</code><br>
<code>64 bytes from 152.19.254.81: icmp_seq=3 ttl=238 time=1179.9 ms</code><br>
<code>64 bytes from 152.19.254.81: icmp_seq=4 ttl=238 time=986.6 ms</code><br>
<code>64 bytes from 152.19.254.81: icmp_seq=5 ttl=238 time=1274.3 ms</code><br>
<code>64 bytes from 152.19.254.81: icmp_seq=6 ttl=238 time=930.7 ms</code><br>
</FONT></TD></TR></TABLE><P>
What is happening is that <TT>
<FONT COLOR="#0000ff">ping</FONT></TT> is sending ICMP packets
to <TT>
<FONT COLOR="#0000ff">metalab.unc.edu</FONT></TT>, which is automatically responding
with a return ICMP packet. Being able to <TT>
<FONT COLOR="#0000ff">ping</FONT></TT> a machine
is often the acid test of whether you have a correctly configured
and working network interface. Note that some sites explicitly filter
out ICMP packets, so, for example, <TT>
<FONT COLOR="#0000ff">ping cnn.com</FONT></TT> won't work.
<P>
<TT>
<FONT COLOR="#0000ff">ping</FONT></TT> sends a packet every second and measures
the time it takes to receive the return packet--like a
submarine sonar ``ping.'' Over the Internet, you can get times
in excess of 2 seconds if the place is remote enough. On a local
LAN this delay will drop to under a millisecond.
<P>
If <TT>
<FONT COLOR="#0000ff">ping</FONT></TT> does not even get to the line <TT>
<FONT COLOR="#0000ff">PING metalab.unc.edu</FONT></TT>...,
it means that <TT>
<FONT COLOR="#0000ff">ping</FONT></TT> cannot resolve the host name. You should then check that
your DNS is set up correctly--see Chapter <A HREF="node30.html#chap:dns">27</A>. If <TT>
<FONT COLOR="#0000ff">ping</FONT></TT>
gets to that line but no further, it means that the packets are not
getting there or are not getting back. In all other cases,
<TT>
<FONT COLOR="#0000ff">ping</FONT></TT> gives an error message reporting the absence of
either routes or interfaces.
<P>
<H2><A NAME="SECTION0028102000000000000000">
25.10.2 <TT>
<FONT COLOR="#0000ff">traceroute</FONT></TT></A>
</H2>
<P>
<TT>
<FONT COLOR="#0000ff">traceroute</FONT></TT> is a rather fascinating utility to identify
where a packet has been. It uses UDP packets or, with the <TT>
<FONT COLOR="#0000ff">-I</FONT></TT>
option, ICMP packets to detect the routing path. On my machine,
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>traceroute metalab.unc.edu</code><br>
</FONT></TD></TR></TABLE><P>
gives
<P><TABLE nowrap="1" width="100%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD valign="top" class="source" width="2%"><FONT color=red size="-2">
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-3"><code>5</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-3"><code>10</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-3"><code>15</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
<font size="-3"><code>20</code></font><code> </code><br>
<code> </code><br>
<code> </code><br>
<code> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue size="-2">
<code>traceroute to metalab.unc.edu (152.19.254.81), 30 hops max, 38 byte packets</code><br>
<code> 1 192.168.3.254 (192.168.3.254) 1.197 ms 1.085 ms 1.050 ms</code><br>
<code> 2 192.168.254.5 (192.168.254.5) 45.165 ms 45.314 ms 45.164 ms</code><br>
<code> 3 cranzgate (192.168.2.254) 48.205 ms 48.170 ms 48.074 ms</code><br>
<code> 4 cranzposix (160.124.182.254) 46.117 ms 46.064 ms 45.999 ms</code><br>
<code> 5 cismpjhb.posix.co.za (160.124.255.193) 451.886 ms 71.549 ms 173.321 ms</code><br>
<code> 6 cisap1.posix.co.za (160.124.112.1) 274.834 ms 147.251 ms 400.654 ms</code><br>
<code> 7 saix.posix.co.za (160.124.255.6) 187.402 ms 325.030 ms 628.576 ms</code><br>
<code> 8 ndf-core1.gt.saix.net (196.25.253.1) 252.558 ms 186.256 ms 255.805 ms</code><br>
<code> 9 ny-core.saix.net (196.25.0.238) 497.273 ms 454.531 ms 639.795 ms</code><br>
<code>10 bordercore6-serial5-0-0-26.WestOrange.cw.net (166.48.144.105) 595.755 ms 595.174 ms *</code><br>
<code>11 corerouter1.WestOrange.cw.net (204.70.9.138) 490.845 ms 698.483 ms 1029.369 ms</code><br>
<code>12 core6.Washington.cw.net (204.70.4.113) 580.971 ms 893.481 ms 730.608 ms</code><br>
<code>13 204.70.10.182 (204.70.10.182) 644.070 ms 726.363 ms 639.942 ms</code><br>
<code>14 mae-brdr-01.inet.qwest.net (205.171.4.201) 767.783 ms * *</code><br>
<code>15 * * *</code><br>
<code>16 * wdc-core-03.inet.qwest.net (205.171.24.69) 779.546 ms 898.371 ms</code><br>
<code>17 atl-core-02.inet.qwest.net (205.171.5.243) 894.553 ms 689.472 ms *</code><br>
<code>18 atl-edge-05.inet.qwest.net (205.171.21.54) 735.810 ms 784.461 ms 789.592 ms</code><br>
<code>19 * * *</code><br>
<code>20 * * unc-gw.ncren.net (128.109.190.2) 889.257 ms</code><br>
<code>21 unc-gw.ncren.net (128.109.190.2) 646.569 ms 780.000 ms *</code><br>
<code>22 * helios.oit.unc.edu (152.2.22.3) 600.558 ms 839.135 ms</code><br>
</FONT></TD></TR></TABLE><P>
You can see that there were twenty machines <FONT COLOR="#ffa500">[This is actually
a good argument for why ``enterprise''-level web servers have no use in
non-U.S. markets: there isn't even the network speed to load such servers,
thus making any kind of server speed comparisons superfluous.]</FONT> (or
<I>hops</I>) between mine and <TT>
<FONT COLOR="#0000ff">metalab.unc.edu</FONT></TT>.
<P>
<H2><A NAME="SECTION0028103000000000000000">
25.10.3 <TT>
<FONT COLOR="#0000ff">tcpdump</FONT></TT></A>
</H2>
<P>
<A NAME="sec:tcpdump"></A>
<P>
<TT>
<FONT COLOR="#0000ff">tcpdump</FONT></TT> watches a particular interface for <I>all</I>
the traffic that passes it--that is, all the traffic of all the
machines connected to the same hub (also called the <I>segment</I>
or <I>network segment</I>). A network card usually
grabs only the frames destined for it, but <TT>
<FONT COLOR="#0000ff">tcpdump</FONT></TT>
puts the card into <I>promiscuous</I> mode, meaning that the
card is to retrieve all frames regardless of their destination
hardware address. 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> </code><br>
</FONT></TD><TD valign="top" class="source" bgcolor="#FFE0C0"><FONT color=blue>
<code>tcpdump -n -N -f -i eth0</code><br>
</FONT></TD></TR></TABLE><P>
<TT>
<FONT COLOR="#0000ff">tcpdump</FONT></TT> is also discussed in
Section <A HREF="node44.html#sec:tcpdumpppp">41.5</A>. Deciphering the output of
<TT>
<FONT COLOR="#0000ff">tcpdump</FONT></TT> is left for now as an exercise for the reader. More
on the <I>tcp</I> part of <TT>
<FONT COLOR="#0000ff">tcpdump</FONT></TT> in Chapter <A HREF="node29.html#chap:tcpudp">26</A>.
<P>
<P>
<HR>
<!--Navigation Panel-->
<A NAME="tex2html2268"
HREF="node29.html">
<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A>
<A NAME="tex2html2264"
HREF="rute.html">
<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A>
<A NAME="tex2html2258"
HREF="node27.html">
<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A>
<A NAME="tex2html2266"
HREF="node1.html">
<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>
<BR>
<B> Next:</B> <A NAME="tex2html2269"
HREF="node29.html">26. TCP and UDP</A>
<B> Up:</B> <A NAME="tex2html2265"
HREF="rute.html">rute</A>
<B> Previous:</B> <A NAME="tex2html2259"
HREF="node27.html">24. Source and Binary</A>
  <B> <A NAME="tex2html2267"
HREF="node1.html">Contents</A></B>
<!--End of Navigation Panel-->
</BODY>
</HTML>
|