17.2. ¹h¹D»P¸ô®|

Contributed by Coranth Gryphon . 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

17.2.1. ½d¨Ò

¬°¤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
CClone¡G¥H¦¹¸ô®|¬°°ò¦²£¥Í·sªº¸ô®|¡A ³oºØ¸ô®|³q±`¥u¦b¥»¦aºô¸ô¨Ï¥Î¡C
WWasCloned¡Gªí¥Ü³o­Ó¸ô®|¬O¥HÄݩʬ°C(Clone)ªº¸ô®|¬°°ò¦¦Û°Ê²£¥Íªº¡C
LLink¡G¸ô®|°Ñ¦Ò¨ì¤A¤Óºô¸ôµwÅé¡C

17.2.2. ¹w³]¸ô®|

·í¥»¦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¾÷¹w³]¹h¹D¤¶­±
Local2Local1ethernet
Local1T1-GWPPP

¤@­Ó±`¨£ªº°ÝÃ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)
      

17.2.3. Dual homed¥D¾÷

ÁÙ¦³¤@ºØ°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

17.2.4. ¸ô®|¶Ç¼½(Routing propagation)

§Ú­Ìª¾¹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¦óª¾¹D­n±N«Ê¥]°eµ¹§AªºISP©O¡H

¦³¤@­Ó¨t²Î(»PDNSªº¬[ºc«Ü¹³)¤£Â_ªº°O¿ý©Ò¦³¤À°tªº¦ì§}¡A ¨Ã¥B¬°¥¦­Ì³]©wºô»Úºô¸ô°©·F(Internet Backbone)ªº³s±µÂI¡A ``Backbone''¬O­t³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

17.2.5. ¸Ñ¨M°ÝÃD

¦³®É­Ô¸ô®|¶Ç¼½(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§A­n³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