คู่มือการกำหนดค่า Cisco Router แบบอินเทอร์แอคทีฟ
ยินดีต้อนรับ! แอปพลิเคชันนี้ถูกออกแบบมาเพื่อช่วยให้คุณเรียนรู้และค้นหาคำสั่งการตั้งค่าเราเตอร์ Cisco ได้อย่างง่ายดายและรวดเร็ว
แอปพลิเคชันนี้เปลี่ยนคู่มือทางเทคนิคแบบดั้งเดิมให้เป็นเครื่องมือที่โต้ตอบได้ คุณสามารถเลือกหัวข้อที่สนใจจากเมนูด้านซ้ายเพื่อดูรายละเอียดการกำหนดค่า คำอธิบายหลักการทำงาน และคำสั่งสำหรับตรวจสอบผลลัพธ์ นอกจากนี้ยังมีส่วนเปรียบเทียบโปรโตคอลต่างๆ ในรูปแบบกราฟที่เข้าใจง่าย เพื่อช่วยให้เห็นภาพรวมและความแตกต่างได้อย่างชัดเจน
เริ่มต้นใช้งาน
เลือกหัวข้อจากเมนูด้านซ้ายเพื่อเริ่มสำรวจเนื้อหา เช่น การกำหนดค่าพื้นฐาน สำหรับผู้เริ่มต้น หรือ การกำหนดเส้นทาง สำหรับการตั้งค่า Routing Protocols
ค้นหาอย่างรวดเร็ว
ใช้ช่องค้นหาที่ด้านบนเพื่อค้นหาคำสั่งหรือหัวข้อที่ต้องการ ระบบจะไฮไลท์คำที่ตรงกันในเนื้อหาทั้งหมดทันที
เปรียบเทียบข้อมูล
ไปที่หน้า เปรียบเทียบข้อมูล เพื่อดูการเปรียบเทียบคุณสมบัติที่สำคัญของ Routing Protocols ในรูปแบบกราฟ เช่น Administrative Distance และ Metric ที่ใช้
การกำหนดค่าพื้นฐาน
ส่วนนี้ครอบคลุมการตั้งค่าเบื้องต้นที่จำเป็นสำหรับเราเตอร์ Cisco ทุกตัว ตั้งแต่การเข้าถึงอุปกรณ์ การตั้งค่าความปลอดภัยพื้นฐาน ไปจนถึงการบันทึกการกำหนดค่าเพื่อให้การตั้งค่าคงอยู่ถาวร
การตั้งชื่อ Hostname
ช่วยในการระบุตัวตนของเราเตอร์แต่ละตัวในเครือข่าย
Router(config)# hostname R1
การตั้งรหัสผ่าน
การตั้งรหัสผ่าน `enable secret` เป็นวิธีที่แนะนำเพื่อความปลอดภัยสูงสุด
R1(config)# enable secret YourStrongPassword R1(config)# line console 0 R1(config-line)# password ConsolePassword R1(config-line)# login R1(config)# line vty 0 4 R1(config-line)# password VtyPassword R1(config-line)# login R1(config-line)# transport input ssh
การกำหนดค่า IP Address และเปิดใช้งาน Interface
ทุก Interface ที่ใช้งานต้องมี IP Address และต้องใช้คำสั่ง `no shutdown` เพื่อเปิดการทำงาน
R1(config)# interface GigabitEthernet0/0 R1(config-if)# description Link to LAN R1(config-if)# ip address 192.168.1.1 255.255.255.0 R1(config-if)# no shutdown
การบันทึกการกำหนดค่า
บันทึกการตั้งค่าปัจจุบัน (running-config) ไปยังหน่วยความจำถาวร (startup-config)
R1# copy running-config startup-config
การกำหนดเส้นทาง (Routing)
Routing protocols เป็นหัวใจของการสื่อสารข้ามเครือข่าย ช่วยให้เราเตอร์สามารถเรียนรู้เส้นทางและส่งข้อมูลไปยังปลายทางได้อย่างถูกต้อง ส่วนนี้จะอธิบายวิธีการตั้งค่าโปรโตคอลต่างๆ ตั้งแต่ Static Route ที่ง่ายที่สุด ไปจนถึง BGP ที่ใช้สำหรับเครือข่ายขนาดใหญ่และอินเทอร์เน็ต คุณสามารถคลิกเพื่อดูรายละเอียดของแต่ละโปรโตคอลได้
Static Routing
เป็นการกำหนดเส้นทางด้วยตนเอง เหมาะสำหรับเครือข่ายขนาดเล็ก หรือใช้กำหนด Default Route เพื่อออกสู่ Internet
ตัวอย่างการกำหนดค่า
Router(config)# ip route 10.10.20.0 255.255.255.0 192.168.12.2
Router(config)# ip route 0.0.0.0 0.0.0.0 GigabitEthernet0/1
คำสั่งตรวจสอบ
show ip route static
show ip route
RIP (Routing Information Protocol)
เป็นโปรโตคอลแบบ Distance Vector ที่เรียบง่าย ใช้ Hop Count เป็น Metric แนะนำให้ใช้ RIPv2 เนื่องจากเป็น Classless
ตัวอย่างการกำหนดค่า RIPv2
Router(config)# router rip
Router(config-router)# version 2
Router(config-router)# no auto-summary
Router(config-router)# network 192.168.1.0
Router(config-router)# network 10.0.0.0
Router(config-router)# passive-interface GigabitEthernet0/0
คำสั่งตรวจสอบ
show ip route rip
show ip protocols
debug ip rip
EIGRP
โปรโตคอล Advanced Distance Vector ของ Cisco มีจุดเด่นที่ Converge ได้รวดเร็วมากโดยใช้อัลกอริทึม DUAL
ตัวอย่างการกำหนดค่า
Router(config)# router eigrp 100
Router(config-router)# no auto-summary
Router(config-router)# network 192.168.1.0 0.0.0.255
Router(config-router)# network 10.1.1.0 0.0.0.3
คำสั่งตรวจสอบ
show ip eigrp neighbors
show ip eigrp topology
show ip route eigrp
OSPF
โปรโตคอล Link-State ที่เป็นมาตรฐานเปิด มีความสามารถในการขยายสูง เหมาะสำหรับเครือข่ายขนาดกลางถึงใหญ่
ตัวอย่างการกำหนดค่า Single-Area OSPF
Router(config)# router ospf 1
Router(config-router)# router-id 1.1.1.1
Router(config-router)# network 192.168.1.0 0.0.0.255 area 0
Router(config-router)# network 10.1.1.0 0.0.0.3 area 0
คำสั่งตรวจสอบ
show ip ospf neighbor
show ip ospf interface brief
show ip route ospf
BGP (Border Gateway Protocol)
โปรโตคอลแบบ Path Vector ที่ใช้สำหรับแลกเปลี่ยนข้อมูลเส้นทางระหว่าง Autonomous Systems (AS) บนอินเทอร์เน็ต
eBGP (External BGP)
ใช้เชื่อมต่อระหว่าง AS ที่แตกต่างกัน
ตัวอย่างการกำหนดค่า
Router(config)# router bgp 65001
Router(config-router)# bgp router-id 1.1.1.1
Router(config-router)# neighbor 203.0.113.2 remote-as 65002
Router(config-router)# network 198.51.100.0 mask 255.255.255.0
iBGP (Internal BGP)
ใช้แลกเปลี่ยนเส้นทางภายใน AS เดียวกัน มักใช้คู่กับ `next-hop-self`
ตัวอย่างการกำหนดค่า
Router(config)# router bgp 65001
Router(config-router)# bgp router-id 2.2.2.2
Router(config-router)# neighbor 1.1.1.1 remote-as 65001
Router(config-router)# neighbor 1.1.1.1 next-hop-self
คำสั่งตรวจสอบ BGP
show ip bgp summary
show ip bgp
show ip route bgp
ความปลอดภัย (Security)
การรักษาความปลอดภัยเป็นสิ่งสำคัญที่สุดในเครือข่าย ส่วนนี้จะครอบคลุมเครื่องมือหลักสองอย่างคือ Access Control Lists (ACLs) สำหรับการกรองทราฟฟิก และ Virtual Private Networks (VPNs) สำหรับการสร้างช่องทางการสื่อสารที่ปลอดภัยผ่านเครือข่ายสาธารณะ
Access Control Lists (ACLs)
ACLs ใช้สำหรับกรอง Packet ตามเงื่อนไขต่างๆ เพื่อควบคุมการเข้าถึงทรัพยากรในเครือข่าย
Standard ACL
กรองทราฟฟิกโดยใช้ Source IP Address เท่านั้น
ตัวอย่าง (Named)
Router(config)# ip access-list standard VTY_ACCESS
Router(config-std-nacl)# permit host 10.0.0.5
Router(config-std-nacl)# permit host 10.0.0.6
Router(config)# line vty 0 4
Router(config-line)# access-class VTY_ACCESS in
Extended ACL
กรองได้ละเอียดกว่า โดยใช้ Source/Destination IP, Protocol, และ Port
ตัวอย่าง (Named)
Router(config)# ip access-list extended ALLOW_WEB_ACCESS
Router(config-ext-nacl)# permit tcp any host 192.168.1.100 eq www
Router(config-ext-nacl)# permit tcp any host 192.168.1.100 eq 443
Router(config-ext-nacl)# deny ip any any
Router(config)# interface GigabitEthernet0/1
Router(config-if)# ip access-group ALLOW_WEB_ACCESS in
คำสั่งตรวจสอบ ACLs
show access-lists
show ip interface
Virtual Private Networks (VPNs)
สร้างช่องทางที่ปลอดภัยผ่านเครือข่ายสาธารณะ มีหลายประเภทตามการใช้งาน
Site-to-Site IPsec VPN (IKEv1)
การกำหนดค่าแบบดั้งเดิมสำหรับเชื่อมต่อระหว่างสำนักงาน
ขั้นตอนการกำหนดค่า
- กำหนด ISAKMP Policy (Phase 1)
- กำหนด Pre-shared Key
- สร้าง Crypto ACL (ระบุทราฟฟิกที่น่าสนใจ)
- กำหนด Transform Set (Phase 2)
- สร้างและนำ Crypto Map ไปใช้งานกับ Interface
ตัวอย่าง
! --- Phase 1 ---
crypto isakmp policy 10
encr aes
hash sha
authentication pre-share
group 14
! --- Pre-shared key ---
crypto isakmp key Cisco123 address 203.0.113.2
! --- Phase 2 ---
crypto ipsec transform-set MY_TS esp-aes esp-sha-hmac
! --- Crypto ACL ---
ip access-list extended VPN_TRAFFIC
permit ip 192.168.1.0 0.0.0.255 10.10.0.0 0.0.0.255
! --- Crypto Map ---
crypto map MY_MAP 10 ipsec-isakmp
set peer 203.0.113.2
set transform-set MY_TS
match address VPN_TRAFFIC
! --- Apply to interface ---
interface GigabitEthernet0/0
crypto map MY_MAP
Site-to-Site IPsec VPN (IKEv2)
เวอร์ชันใหม่ที่มีประสิทธิภาพและยืดหยุ่นกว่า
ขั้นตอนการกำหนดค่า
- กำหนด IKEv2 Keyring, Proposal, Policy และ Profile
- กำหนด IPsec Transform Set
- สร้างและนำ Crypto Map (ที่อ้างถึง IKEv2 Profile) ไปใช้งาน
ตัวอย่าง
! --- IKEv2 Proposal ---
crypto ikev2 proposal IKEV2_PROPOSAL
encryption aes-cbc-256
integrity sha256
group 19
! --- IKEv2 Policy ---
crypto ikev2 policy IKEV2_POLICY
proposal IKEV2_PROPOSAL
! --- IKEv2 Keyring ---
crypto ikev2 keyring IKEV2_KEYRING
peer OTHER_SITE
address 203.0.113.2
pre-shared-key local MyLocalKey
pre-shared-key remote PeerRemoteKey
! --- IKEv2 Profile ---
crypto ikev2 profile IKEV2_PROFILE
match address local interface GigabitEthernet0/0
match identity remote address 203.0.113.2
authentication remote pre-share
authentication local pre-share
keyring local IKEV2_KEYRING
! --- Crypto Map (referencing IKEv2) ---
crypto map MY_MAP 10 ipsec-isakmp
set peer 203.0.113.2
set transform-set MY_TS
set ikev2-profile IKEV2_PROFILE
match address VPN_TRAFFIC
Remote Access VPN (Client-to-Server)
สำหรับให้ผู้ใช้รายบุคคลเชื่อมต่อเข้ามาในเครือข่ายองค์กร
ขั้นตอนการกำหนดค่า (Easy VPN)
- สร้าง User และ Password สำหรับ VPN
- สร้าง IP Pool สำหรับแจกให้ Client
- กำหนด ISAKMP Policy และ Pre-shared Key สำหรับกลุ่ม
- กำหนด Transform Set
- สร้าง Dynamic Crypto Map และ Crypto Map
- สร้าง Group Policy (Crypto ISAKMP Profile)
- นำ Crypto Map ไปใช้งาน
ตัวอย่าง
! --- User and IP Pool ---
username vpnuser password vpnpassword
ip local pool VPN_POOL 10.100.100.1 10.100.100.10
! --- ISAKMP Profile (Group Policy) ---
crypto isakmp client configuration group VPN_GROUP
key mygroupkey
pool VPN_POOL
! --- Dynamic Crypto Map ---
crypto dynamic-map DYN_MAP 10
set transform-set MY_TS
! --- Static Crypto Map ---
crypto map MY_MAP 20 ipsec-isakmp dynamic DYN_MAP
! --- Apply to interface ---
interface GigabitEthernet0/0
crypto map MY_MAP
SSL VPN (AnyConnect)
ใช้ SSL/TLS เพื่อความยืดหยุ่นสูง สามารถทำงานผ่าน NAT และ Firewall ได้ง่าย
ขั้นตอนการกำหนดค่า
- ติดตั้ง AnyConnect package และเปิดใช้งาน
- สร้าง IP Pool สำหรับแจกให้ Client
- กำหนด Group Policy และกำหนด IP Pool
- เปิดใช้งาน WebVPN Gateway และผูกกับ Interface
ตัวอย่าง
! --- Enable AnyConnect ---
webvpn install svc flash:/anyconnect-package.pkg
! --- User and IP Pool ---
username anyuser password anypassword
ip local pool ANYCONNECT_POOL 10.200.200.1 10.200.200.10
! --- Group Policy and Connection Profile ---
group-policy ANYCONNECT_POLICY internal
group-policy ANYCONNECT_POLICY attributes
vpn-tunnel-protocol ssl-client
address-pool value ANYCONNECT_POOL
! --- WebVPN Gateway ---
webvpn gateway MY_GATEWAY
ip interface GigabitEthernet0/0 port 443
ssl trustpoint-name MY_TRUSTPOINT
inservice
! --- WebVPN Context ---
webvpn context MY_CONTEXT
policy group ANYCONNECT_POLICY
gateway MY_GATEWAY
inservice
คำสั่งตรวจสอบ VPN
! For IPsec
show crypto isakmp sa
show crypto ipsec sa
show crypto map
! For AnyConnect
show webvpn session
show webvpn context
บริการเครือข่าย (Network Services)
เราเตอร์ Cisco ไม่ได้ทำหน้าที่แค่ส่งต่อข้อมูล แต่ยังสามารถให้บริการที่สำคัญอื่นๆ ในเครือข่ายได้ด้วย ส่วนนี้จะอธิบายการตั้งค่า NAT สำหรับการแปลง IP address เพื่อออกสู่อินเทอร์เน็ต และ DHCP สำหรับการแจกจ่าย IP address อัตโนมัติให้กับเครื่องลูกข่าย
Network Address Translation (NAT)
ใช้สำหรับแปลง Private IP Address ภายในเครือข่ายเป็น Public IP Address เพื่อสื่อสารกับภายนอก
ตัวอย่างการกำหนดค่า PAT (NAT Overload)
เป็นรูปแบบที่นิยมที่สุด ช่วยให้หลายเครื่องใช้ Public IP เดียวกันได้
! 1. Define inside and outside interfaces
interface GigabitEthernet0/0
description OUTSIDE_INTERFACE_TO_INTERNET
ip address dhcp
ip nat outside
!
interface GigabitEthernet0/1
description INSIDE_INTERFACE_TO_LAN
ip address 192.168.1.1 255.255.255.0
ip nat inside
!
! 2. Create an ACL for internal hosts
ip access-list standard NAT_ACL
permit 192.168.1.0 0.0.0.255
!
! 3. Configure NAT Overload
ip nat inside source list NAT_ACL interface GigabitEthernet0/0 overload
คำสั่งตรวจสอบ
show ip nat translations
show ip nat statistics
DHCP Services
เราเตอร์สามารถทำหน้าที่เป็น DHCP Server เพื่อแจกจ่าย IP ให้กับ Client ได้โดยอัตโนมัติ
ตัวอย่างการกำหนดค่า DHCP Server
! 1. Exclude addresses for static devices
ip dhcp excluded-address 192.168.1.1 192.168.1.10
!
! 2. Create DHCP pool
ip dhcp pool LAN_POOL
network 192.168.1.0 255.255.255.0
default-router 192.168.1.1
dns-server 8.8.8.8 8.8.4.4
domain-name mycompany.local
lease 7
คำสั่งตรวจสอบ
show ip dhcp binding
show ip dhcp pool
เปรียบเทียบข้อมูลโปรโตคอล
การเลือกใช้ Routing Protocol ที่เหมาะสมขึ้นอยู่กับหลายปัจจัย กราฟด้านล่างจะช่วยให้คุณเห็นภาพเปรียบเทียบคุณสมบัติที่สำคัญของโปรโตคอลต่างๆ ได้อย่างชัดเจน เพื่อประกอบการตัดสินใจในการออกแบบเครือข่าย
เปรียบเทียบ Administrative Distance (AD)
ค่า AD ใช้ในการตัดสินใจเลือกเส้นทางเมื่อเราเตอร์เรียนรู้เส้นทางไปยังปลายทางเดียวกันจากหลายโปรโตคอล (ค่ายิ่งน้อย ยิ่งน่าเชื่อถือ)
เปรียบเทียบ Metric ที่ใช้
Metric คือค่าที่แต่ละโปรโตคอลใช้ในการคำนวณเส้นทางที่ดีที่สุด ซึ่งสะท้อนถึงหลักการทำงานที่แตกต่างกัน