Contributed by Coranth Gryphon <gryphon@FreeBSD.org>. 6 October 1995.
¬°¤FÅý¤@³¡¹q¸£¯à§ä¨ì¥t¤@³¡¹q¸£¡A¦]¦¹¥²»Ýn¦³¤@ºØ¾÷¨î¡A Åý³o³¡¹q¸£ª¾¹D¸Ó«ç»ò°µ¡A³oÓ¾÷¨î´N¬O¸ô®|¿ï¾Ü(routing)¡C ¤@Ó¸ô®|("route")¬O¥Ñ¤@¹ï¦ì§}©Ò©w¸qªº¡G¤@Ó "¥Ø¼Ð"¥H¤Î¤@Ó¹h¹D("gateway")¡C ³o¹ï¦ì§}ªí¥Ün°e¨ì¥Ø¼Ðªº«Ê¥]¡A ¥²¶·¸g¹L¹h¹D¡C ¥Ø¼Ð¤À¬°¤TºØÃþ«¬¡G¥D¾÷¡B¤lºô¸ô(subnet)©M¹w³]¸ô®| ("default route")¡C ¦pªG¨S¦³¨ä¥¦ªº¸ô®|¥i¥H¨Ï¥Î¡A³o®É´N·|¨Ï¥Î¹w³]¸ô®|¡A µy«á§ÚÌ·|¹ï¹w³]¸ô®|§@¶i¤@¨Bªº»¡©ú¡C¦¹¥~¡A¹h¹D¤]¦³¤TºØÃþ«¬¡G ¥D¾÷¡B¶Ç¿é¤¶±(interface¡A¤]ºÙ¬° "links") ©M¤A¤Óºô¸ôµwÅé¦ì§}¡C
¬°¤F»¡©ú¤£¦PÃþ«¬ªº¸ô®|¿ï¾Ü¡A §Ú̱N¨Ï¥Î¥Ñnetstat -r«ü¥O¨ú±oªº¸ê®Æ§@¬°½d¨Ò¡G
Destination Gateway Flags Refs Use Netif Expire default outside-gw UGSc 37 418 ppp0 localhost localhost UH 0 181 lo0 test0 0:e0:b5:36:cf:4f UHLW 5 63288 ed0 77 10.20.30.255 link#1 UHLW 1 2421 foobar.com link#1 UC 0 0 host1 0:e0:a8:37:8:1e UHLW 3 4601 lo0 host2 0:e0:a8:37:8:1e UHLW 0 5 lo0 => host2.foobar.com link#1 UC 0 0 224 link#1 UC 0 0
²Ä¤@¦æ¬O¹w³]¸ô¥Ñ(§ÚÌ·|¦b¤U¤@¬q»¡©ú)¡A ²Ä¤G¦æ«h¬Olocalhost¸ô®|¡C
¥ÑNetif¥i¥Hª¾¹Dlocalhost ©Ò¨Ï¥Îªº¤¶±¬Olo0¡A¤]´N¬Oloopback³]³Æ¡C ³oªí¥Ü©Ò¦³ªº«Ê¥]¤£·|³Q°e¤Wºô¸ô¡A¦Ó¬O¦b¤º³¡³B²z¡C
±µ¤U¨Ó¬O0:e0:...³o¨Ç¦ì§}¡C ³o¨Ç³£¬O¤A¤Óºô¸ôµwÅé¦ì§}¡AFreeBSD·|¦Û°ÊÃѧO¦b¦P¤@Ó¤A¤Óºô¸ô¤¤ªº¥D¾÷ (¦ptest0)¡A¨Ã¥B±N¥¦¥[¤J¸ô®|ªí¡AµM«á¸g¥Ñ ed0³oÓ¤¶±ª½±µ»P¥¦³q°T¡A ³oºØ¸ô®|³£·|¦³¤@Ó«O¯d®É¶¡(Expire)¡A ¦pªG»P¨º³¡¥D¾÷¶¡¤@ª½¨S¦³¥ô¦ó³q°T¡A¦b¶W¹L«O¯d®É¶¡¤§«á¡A ³oµ§¸ô®|·|¦Û°Ê³Q§R°£¡C³o¨Ç¥D¾÷´N¬O¥Î¤@ºØºÙ¬°RIP (Routing Information Protocol)ªº¾÷¨î¨ÓÃѧO¡A ¸g¥ÑRIP§ÚÌ¥i¥H±o¨ì»P¥»¦a¥D¾÷³q°Tªº³Ì¨Î¸ô®|¡C
FreeBSD¤]·|´À¥»¦aºô¸ô³]©w¸ô®| (10.20.30.255¬Oºô¸ô 10.20.30ªº¼s¼½¦ì§}¡A foobar.com«h¬Oºô°ì¦WºÙ)¡C link#1¥Nªí¥D¾÷ªº²Ä¤@¤ù¤A¤Óºô¸ô¥d¡A §A¤]³\¤]ª`·N¨ì¤F¡A³o¨Ç¸ô®|³£¨S¦³«ü©w¤¶±¡C
¥D¾÷©M¥»¦aºô¸ôªº¸ô®|¬O¥Ñrouted³oÓdaemon ¦Û°Ê³]©wªº¡A¦pªG¨S¦³°õ¦ærouted¡A ¨º´N¥u¦³ÀRºA¸ô®|¦s¦b¡C
¥Ñ¤A¤Óºô¸ô¦ì§}¥i¥Hª¾¹Dhost1³o¤@¦æ´N¬O§Ú̪º¥D¾÷¡ ¦]¬°§Ú̪º¥D¾÷¬Oµo°eºÝ¡AFreeBSDª¾¹D¸Ó¨Ï¥Îloopback¤¶± (lo0)¡A¦Ó«D°e¨ì¤A¤Óºô¸ô¤¶±¡C
host2³o¨â¦æ¬O¬°¤F¥Ü½d·í§Ų́ϥÎifconfig §O¦W®Éªºª¬ªp(³o»ò°µªºì¦]½Ð°Ñ¨£¤A¤Óºô¸ô³oÓ³¡¥÷)¡C lo0¤§«áªº =>²Å¸¹ªí¥Ü§Ú̩ҨϥΪºloopback¬OÓ§O¦W¡C ³oºØ¸ô®|¥u¦³¦b¤ä´©§O¦Wªº¥D¾÷¤W·|³QÅã¥Ü¥X¨Ó¡A ¨ä¥¦¥»¦a¥D¾÷¹ï³oºØ¸ô®|¥u·|²³æªºÅã¥Ü¤@¦ælink#1¡C
³Ì«á¤@¦æ(¥Ø¼Ð¤lºô¸ô224)¬O¥Î©óMultiCasting¡A §ÚÌ·|¦A»¡©ú¡C
¥t¥~´N¬OFlags©Ò¥Nªíªº·N«ä¡A ¨C¤@Ó¸ô®|ªºÄݩʳ£¦b³o¸ÌÅã¥Ü¡A¤U±ªºªí®æ¬O³o¨ÇÄݩʪºÂ²µu»¡©ú¡G
U | ±Ò°Ê(Up)¡G¥Nªí¥¿±`¹B§@¡C |
H | ¥D¾÷(Host)¡G³q¦V¤@³¡¥D¾÷ªº¸ô®|¡C |
G | ¹h¹D(Gateway)¡G¥ô¦ó°e¨ì¥Ø¼Ðªº«Ê¥]³£·|¥ý³Q³o³¡¥D¾÷±µ¦¬¡A µM«á¦A¥Ñ³o³¡¥D¾÷Âà°e¡C |
S | ÀRºA(Static)¡G³oºØ¸ô®|¬O¤H¤u³]©wªº¡A¨Ã«D¥Ñ¨t²Î¦Û°Ê²£¥Í¡C |
C | Clone¡G¥H¦¹¸ô®|¬°°ò¦²£¥Í·sªº¸ô®|¡A ³oºØ¸ô®|³q±`¥u¦b¥»¦aºô¸ô¨Ï¥Î¡C |
W | WasCloned¡Gªí¥Ü³oÓ¸ô®|¬O¥HÄݩʬ°C(Clone)ªº¸ô®|¬°°ò¦¦Û°Ê²£¥Íªº¡C |
L | Link¡G¸ô®|°Ñ¦Ò¨ì¤A¤Óºô¸ôµwÅé¡C |
·í¥»¦a¥D¾÷»Ýn»P»·ºÝ¥D¾÷³q³s®É¡A ¥»¦a¥D¾÷·|¥ý¨ì¸ô®|ªí¸ÌÀY¥h´M§ä¬O§_¤w¸g¦³¥i¥H¨Ï¥Îªº¸ô®|¡A ¦pªG»·ºÝ¥D¾÷¦ì©ó§Ṳ́w¸gª¾¹Dªº¤lºô¸ô(Cloned routes)¡A ¨t²Î´N·|Àˬd¬O§_¯à¸g¥Ñ³o±ø¸ô®|¶i¦æ³q³s¡C
¦pªG©Ò¦³¤wª¾¸ô®|³£µLªk¨Ï¥Î¡A¨t²Î¥u¦³¤@ӳ̫᪺¿ï¾Ü¡G¹w³]¸ô®|¡C ¹w³]¸ô®|¬O¤@ºØ¯S§Oªº¹h¹D¸ô®|(³q±`¤]¬O¨t²Î¤¤°ß¤@ªº¤@Ó)¡A ¦Ó¥B¤@©w·|¦ñÀHµÛ¤@ÓÄÝ©Êc¡A ¦ì©ó°Ï°ìºô¸ô¤¤ªº¥D¾÷¥i¥H±N¹h¹D³]©w¦¨¥ô¦ó»P¥~¬Éª½±µ³q³sªº¾÷¾¹ (µL½×¬O¥ÎPPP©Î¬O¤@³¡»P±M½u³s±µªºµwÅé)¡C
¦pªG¤@³¡¾÷¾¹¬O³q©¹¥~¤¶ªº¹h¹D¡A¦Ó§A¤S±N³o³¡¾÷¾¹ªº¹w³]¸ô®|³]¬°¾÷¾¹¦Û¤ ³oÓ®ÉÔISP(Internet Service Provider)ªº¹h¹D¾¹´N·|Åܦ¨¹w³]¸ô®|¡C
Åý§Ú̬ݬݤ@Ó¹w³]¸ô®|ªº¨Ò¤l¡A³o¬O¤@Ó±`¨£ªºª¬ªp¡G
[Local2] <--ether--> [Local1] <--PPP--> [ISP-Serv] <--ether--> [T1-GW]
Local1»PLocal2 ³o¨â³¡¥D¾÷³£©M§A¦b¦P¤@Ó¦a¤è¡A¨Ã¥B¨Ï¥ÎÂI¹ïÂI³q°T¨ó©w(PPP)»PISP¬Û³s¡A ³o®aISP¦³¥L̦ۤvªº°Ï°ìºô¸ô¡A ¥]¬A»P§A³s±µªº¦øªA¾¹¥H¤Î»Pºô»Úºô¸ô¬Û³sªºµwÅé¸Ë¸m(T1-GW)¡C
³o¨â³¡¥D¾÷ªº¹w³]¸ô®|¦p¤U¡G
¤@Ó±`¨£ªº°ÝÃD¡F"¬°¤°»ò±N¹w³]¸ô®|³]¦¨T1-GW¡A ¦Ó¤£¬O§ÚÌ©Ò³s±µªº¦øªA¾¹©O¡H"
§O§Ñ¤F¡A¬JµMPPP¤¶±¨Ï¥Îªº¦ì§}¬OÄÝ©óISPªº°Ï°ìºô¸ô¡A ¦b³oÓ°Ï°ìºô¸ô¤¤©Ò¦³¥D¾÷ªº¸ô®|´N·|¦Û°Ê²£¥Í¡A ¦]¦¹¦ÛµM¤]´N±o¨ìT1-GW³o³¡¾÷¾¹ªº¸ô®|¡A©Ò¥H¦h¾lªº³]©w¬O¤£»Ýnªº¡C
¤@¯ë³£¬O§â...1 ³oÓ¦ì§}°µ¬°¥»¦aºô¸ôªº¹h¹D¦ì§}¡A¦]¦¹¡A ¦pªG§Aªºclass-C¦ì§}¬O10.20.30¡A ¦ÓISP¬O¥Î10.9.9¡A³o®É¹w³]¸ô®|´N¬O¡G
Local2 (10.20.30.2) --> Local1 (10.20.30.1)
Local1 (10.20.30.1, 10.9.9.30) --> T1-GW (10.9.9.1)
ÁÙ¦³¤@ºØ°t¸m¤è¦¡¬O§ÚÌÀ³¸Óª¾¹Dªº¡A ¨º´N¬O¤@³¡³s±µ¨âÓ¤£¦Pºô¸ôªº¥D¾÷¡A §Þ³N¤W¨Ó¨Ó¡A¥ô¦ó°µ¬°¹h¹Dªº¾÷¾¹³£¥i¥Hµø¬°daul-homed¥D¾÷¡A ¦ý¬O³oÓ¦Wµü¶È¥Î¨Óªí¥Ü¦P®É³s±µ¨âÓ°Ï°ìºô¸ôªº¾÷¾¹¡C
Á|¨Ò¨Ó»¡¡A¤@³¡¾÷¾¹´¡¤F¨â¤ùºô¸ô¥d¡A ¨â¤ùºô¸ô¥dªº¦ì§}³£¦b¤£¦Pªº¤lºô¸ô¤W¡F ¥t¥~¤@Ó¨Ò¤l´N¬O¡A¤@³¡¾÷¾¹¥u´¡¤F¤@¤ùºô¸ô¥d¡A¦ý¬O¥Î¤Fifconfig¥[¤W§O¦W¡C ²Ä¤@Ó¨Ò¤l¬O¦b¦P®É¨Ï¥Î¨âÓ¹êÅé¤A¤Óºô¸ô®É¡A ²Ä¤GÓ¨Ò¤l¬O¥u¦³¤@Ó¹êÅéºô¸ô¡A ¦ý¬O¦bÅÞ¿è¤W¦³¨âÓ¤lºô¸ô¡C
¦¹¥~¡A ¥i¥H³]©w¸ô®|ªíÅý¨CÓ¤lºô¸ôª¾¹D³o»O¾÷¾¹¬O³q©¹¥t¤@Ó¤lºô¸ôªº¹h¹D¡A ±N¾÷¾¹°µ¬°¨âÓ¤lºô¸ôªº¾ô±µ¾¹®É¡A³q±`·|¥Î³oºØ¤èªk¨Ó³]¸m«Ê¥]¹LÂo (packet filtering)©Î¨¾¤õÀð(firewall)¡C
§Ú̪¾¹D¦p¦ó³]©w³q¦V¥~ÀYªº¸ô®|¡A ¦ý¬OÁÙ¤£ª¾¹D§O¤H¬O«ç»ò§ä¨ì§Ú̪º¡C
§Ú̪¾¹D¸g¥Ñ³]©w¸ô®|ªí¡A©Ò¦³°e¨ì¬Y¬q¦ì§}ªº«Ê¥] (¦b½d¨Ò¤¤¬O¤@Óclass-Cªººô¸ô)³£·|³Q°e¨ì¤@³¡¦ì©ó¥Ø¼Ðºô¸ôªº¯S©w¥D¾÷¡A ±µµÛ³o³¡¥D¾÷·|±N«Ê¥]Âà°eµ¹¯u¥¿ªº±µ¦¬ªÌ¡C
·í§A¬°¤lºô¸ô¨ú±o¤@¬q¦ì§}®É¡AISP·|³]©w¥L̪º¸ô®|ªí¡A ©Ò¥H©Ò¦³°eµ¹§Aªº«Ê¥]³£·|¸g¥ÑPPP°e¨ì§Aªººô¸ô¡C ¦ý¬O¦ì©ó¨ä¥L°ê®aªº¹q¸£¬O¦p¦óª¾¹Dn±N«Ê¥]°eµ¹§AªºISP©O¡H
¦³¤@Ó¨t²Î(»PDNSªº¬[ºc«Ü¹³)¤£Â_ªº°O¿ý©Ò¦³¤À°tªº¦ì§}¡A ¨Ã¥B¬°¥¦Ì³]©wºô»Úºô¸ô°©·F(Internet Backbone)ªº³s±µÂI¡A ``Backbone''¬Ot³d¥þ²yºô»Úºô¸ô³q°Tªº°©·F½u¸ô¡A ¨C¤@³¡¦ì©ó°©·F½u¸ô¤Wªº¾÷¾¹(backbone machine)³£«O¦s¤@¥÷¹ïÀ³ªí¡A ¦³¤F³o¥÷¹ïÀ³ªí¡A«Ê¥]´N¥i¥H°e¨ì§AªºISP¡A³Ì«á¨ì¹F§Aªººô¸ô¡C
¦¹¥~¡AISP¤]¥²¶·Åý°©·F½u¸ô¤Wªº¾÷¾¹ª¾¹D§A¬O¸g¥Ñ³o®aISP³s¤Wºô¸ôªº¡C ³oÓµ{§Ç´N¬O¸ô®|¶Ç¼½¡C
¦³®ÉÔ¸ô®|¶Ç¼½(routing propagation)¥X¤F°ÝÃD¡A ¾ÉP¬Y¨Ç¦a¤èªº¹q¸£µLªk»P§A³q³s¡A ¤]³\traceroute(8)³oӳ̦³¥Îªº«ü¥O¥i¥HÀ°§A§ä¥X¸ô®|¬O¦bþ¸Ì¤¤Â_¡A ³oÓ«ü¥O¦b§AµLªk»P»·ºÝ¥D¾÷³q³s®É¤@¼Ë¦³¥Î(¨Ò¦p·íping(8)¥¢±Ñ®É)¡C
traceroute(8)³oÓ«ü¥O¬O¥H§An³s±µªº»·ºÝ¥D¾÷°µ¬°°Ñ¼Æ¡A traceroute(8)·|±N«Ê¥]©Ò¸g¹Lªº¹h¹DÅã¥Ü¥X¨Ó¡A µL½×³Ì«á¬O§_¯à¦¨¥\¨ì¹F»·ºÝ¥D¾÷¡C
½Ð°Ñ¦Ò½u¤W¤â¥U(manual page)¨ú±o§ó¦hÃö©ótraceroute(8)ªº¸ê°T¡C