Gateway of last resort ใน routing table ของ Cisco router คืออะไร
"Gateway of Last Resort" ใน routing table ของ Cisco router คืออะไร และสัมพันธ์กับ default route "ip route 0.0.0.0 0.0.0.0" อย่างไร
Resort = แหล่งพึ่งพิง ดังนั้น Last Resort ก็หมายถึง แหล่งพึ่งพิงสุดท้าย
เวลาเรา show routing table ด้วย command "show ip route" ใน Cisco router เราจะพบคำว่า "Gateway of Last Resort" เคยสงสัยมั๊ยว่ามันคืออะไร ซึ่งมันจะเกี่ยวกับหลักการ forwarding IP packet ดังนี้
Router เมื่อได้รับ IP packet เข้ามา มันจะพิจารณา destination IP address ใน IP header แล้วนำไปเทียบกับรายการ (entries) ใน routing table ด้วยหลักการ longest match คือ entries ไหน หรือ รายการไหนใน routing table มี bit ที่ match กับ destination IP address มากที่สุด entries นั้นจะถูกเลือกใช้ แล้ว packet จะถูก forward ไปตาม next-hop หรือ outgoing interface ของ entries นั้นๆ (พิจารณาจาก Major Network เป็นหลัก แล้วย่อยลงมาหา subnet ที่ match ที่สุด)
แต่หากไม่พบ entries ไหนเลยที่ match แล้ว packet จะถูก drop ทิ้ง (ไม่ flood เหมือน switch นะครับ เพราะ router เกิดมาเพื่อกั้น broadcast domain)
ในกรณีที่ router ตัวนี้ต่ออยู่กับ Internet แล้ว ใน routing table จะมี routing (subnet) ของบริษัทอยู่ครบ แต่จะไม่มี routing (subnet) ของ Internet (ในกรณี router รุ่นไม่ได้ใหญ่มาก) ดังนั้นหาก router ตัวนี้ได้รับ IP packet ที่มี destination เป็น IP address ที่อยู่ใน Internet แล้ว router ตัวนี้ก็จะ drop IP packet นั้นทิ้งไป
เหตุผลว่าทำไม router ตัวนี้จึงไม่มี routing (subnet) ของ Internet คำตอบคือ เพราะ router ตัวนี้เป็นรุ่นเล็ก มี resource เช่น CPU ต่ำ และ Memory ที่น้อย หาก router ตัวนี้ต้องบรรจุ Internet route ที่มีขนาด 500,000 routes แล้ว router ถึงตายได้ ผมจะเรียกเหตุการณ์นี้ว่า "ลูกหมาลากซุง" คือเอาลูกหมามาทำงานช้าง
ดังนั้นวิธีที่จะทำให้ router ตัวนี้สามารถ forward IP packet ที่มี destination IP address เป็น Internet address ได้นั้น เราจะต้องใส่ default route ให้กับมัน ด้วย command "ip route 0.0.0.0 0.0.0.0 x.x.x.x" เมื่อ x.x.x.x คือ IP address ขา WAN ของ ISP
หลังจากที่ configure command นี้ให้กับ router แล้ว address 0.0.0.0/0 นี้จะไปปรากฎอยู่ใน routing table (จากการใช้ command "show ip route") ดังนี้
S* 0.0.0.0/0 [1/0] via x.x.x.x ( * คือ candidate default หรือ แสดงให้เราทราบว่า route นี้เป็น default route นะ)
และที่ตำแหน่ง "Gateway of last resort" จะขึ้นประมาณนี้
Gateway of last resort is x.x.x.x to network 0.0.0.0
เมื่อ x.x.x.x คือ IP address ของ ISP
นั่นก็คือ จากนี้ไป หาก IP packet ที่มี destination IP address ที่ไม่ match ใน routing table มันจะไม่ถูก drop อีกแล้ว เพราะมันมี "แหล่งพึ่งพิงสุดท้าย" แล้ว นั่นก็คือ packet นี้จะถูก forward ไปยัง ISP ที่ IP address x.x.x.x นี้แทน
ยังมีอีกหลายเรื่องที่อยากจะแบ่งปัน และเชื่อว่าหลายๆ คนคงอยากรู้:
- Command "ip default-gateway" คืออะไร? - Command "ip default-network" คืออะไร? - Command "ip route 0.0.0.0 0.0.0.0" ต่างจาก "default-gateway" กับ "default-network" อย่างไร?
โดยเฉพาะ Command "ip default-network" ซึ่ง command นี้เป็น command ที่เข้าใจได้ยาก กว่าที่ผมจะเข้าใจก็ศึกษาอยู่ 3 ปี ปีละ 1 นาที ล้อเล่งอ่ะ ^^"
อย่างไรก็ตาม จะพยายามหาเวลามาแชร์ให้นะครับ และหวังว่าข้อมูลนี้จะมีประโยชน์กับทุกๆ ท่าน
KoChaiwat (โก้-ชัยวัฒน์)
Create Date : 26 มีนาคม 2558 |
Last Update : 30 มีนาคม 2558 12:23:35 น. |
|
3 comments
|
Counter : 9372 Pageviews. |
|
 |
|