วันพฤหัสบดีที่ 12 กันยายน พ.ศ. 2556

Basic Command Cisco V1

*** Part 1 ***

- Mode ต่างๆ ในการจัดตั้งค่าให้กับเราเตอร์/สวิตซ์
1. User Execute Mode
2. Privilege Mode (Enable Mode)
3. Global Configuration Mode
4. Interface Configuration Mode 

router#sh clock - ดูเวลาของเราเตอร์
router#clock set 12:00:00 22 March 2010 - กำหนด เวลา และวันให้กับเราเตอร์
router(config)#hostname xxxxx - ตั้งชื่อให้กับเราเตอร์
R1#show run - ดูคำสั่งทั้งหมดที่ run อยู่บน RAM

R1#conf ter - เข้าไปที่ Configuration Mode
R1(config)#interface s0/0/0 - เข้าไปที่ขา interface serial 0/0/0 (WIC-1T)
R1(config-if)#ip address 192.168.0.1 255.255.255.0 - กำหนด ip, subnet mask ให้กับ interface serial 0/0/0 
R1(config-if)#no shut - enable ให้ interface นั้นๆ สามารถทำงานได้ 

วิธีตรวจสอบ ip ทำที่ Privilege Mode
R1#sh ip int br - ดู ip address ทุกอินเตอร์เฟสบนเราเตอร์ แบบสรุป

==========================================

*** Part 2 ***

R1#show flash - ดู file ทั้งหมดที่เก็บอยู่ใน flash โดยเฉพาะ ios ของเราเตอร์
R1#show history - ดูคำสั่งที่เราพิมพ์ไปก่อนหน้านี้ 
R1#show run - ดูคำสั่งทั้งหมดที่อยู่ใน RAM
R1#show start - ดูคำสั่งทั้งหมดที่อยู่ใน NVRAM

- วิธีการเปิด Telnet หรือ การ remote ระยะไกล

R1#conf ter
R1(config)#enable password cisco - กำหนดรหัสผ่านก่อนเข้า Privilege mode หรือ Enable mode 
R1(config)#line vty 0 4 
R1(config-line)#password cisco
R1(config-line)#login

R1(config)#service password-encryption - เข้ารหัส password แบบ password 7

Crack password 7 - http://www.kazmier.com/computer/cisco-cracker.html

R1(config)#enable secret cisco - ตั้ง password โดยเข้ารหัสแบบ md5 ก่อนเข้า Enable mode 

R1(config)#no ip domain-lookup - ไม่ให้มีคำสั่งที่พิมพ์ผิดพลาดนั้นส่งไปถาม domain server เพื่อจะทำให้เราทำงานได้เร็วขึ้น เพราะไม่เสียเวลารอ

- Basic Configuration for Lab#3
1. จัดตั้งค่า serial port ที่เราจะใช้งาน 
R1>enable
R1#config terminal
R1(config)#interface serial 0/0/0
R1(config-if)#ip address 192.168.x.x 255.255.255.0
R1(config-if)#no shut
2. ใส่สัญญาณนาฬิกาให้กับฝั่งที่เป็นขา DCE 
วิธีตรวจสอบว่าฝั่งไหนเป็น DCE หรือ DTE ทำได้โดยใช้คำสั่ง
R1#show controller s0/0/0 
จัดตั้งคำสั่งสัญญาณนาฬิกาทำได้โดย
R1(config-if)#clock rate 9600
ทำเฉพาะใน Lab และฝั่งเราเตอร์ที่เป็น DCE เท่านั้น (ฝั่งผู้ให้บริการ) 
3.ตรวจสอบสถานะของเราเตอร์
R1#sh ip int br 
R1#sh int s0/0/0
R1#ping 192.168.x.x

- สรุปคำสั่ง show ต่างๆ บนเราเตอร์ ทำที่ Privilege mode
#show startup-config -> ดูค่า configure ใน nvram
#show running-config -> ดูค่า configure ปัจจุบันซึ่งถูกเก็บอยู่ใน RAM แต่เมื่อเรา wr มันจะเก็บไปไว้ที่ nvram 
#show clock -> ดูวัน เวลาของเราเตอร์ 
#show user -> ดูว่าใครเข้ามาใช้เราเตอร์อยู่บ้าง 
#show history -> ดูคำสั่งที่เคยพิมพ์มา
#show flash -> ดูไฟล์ต่างๆ ใน flash 
#show memory free -> ดู memory
#show tech-support -> จะแสดงทุกสิ่ง ทุกอย่างบนเราเตอร์ 
#show cdp neighbor -> จะดูอุปกรณ์ติดอยู่กับอุปกรณ์ข้างเคียงอะไรบ้าง

------------------------------------------------------------------------
วิธี configure คำสั่ง static route ทำที่ Global Configuration Mode
R1#config ter
R1(config)#ip route (network ปลายทาง) (subnet mask ปลายทาง) (next hop ip)

วิธีตรวจ routing table 
R1#sh ip route 

PC>ping x.x.x.x เป็นคำสั่งที่ใช้สำหรับตรวจสอบ keep alive หรือ เจออุปกรณ์ปลายทางได้
PC>tracert x.x.x.x เป็นคำสั่งที่ใช้สำหรับตรวจสอบเส้นทางของข้อมูลที่ไปถึงปลายทาง ซึ่งจะบอกเป็นค่า ip ของขาเข้า

- วิธีการติดตั้ง routing protocol แบบ RIP 
R1>enable
R1#config terminal
R1(config)#router rip
R1(config-router)#network (เครือข่ายที่อยู่ติดกับเราเตอร์ที่กำลังติดตั้ง)

วิธีตรวจสอบ
R1#show ip route
R1#show ip protocol 

- วิธีการเว้นบรรทัดเมื่อมีการส่ง log หรือข้อผิดพลาดมาจากเราเตอร์ เพื่อไม่ให้สับสนเมื่อทำการ configure เราเตอร์ ณ เวลานั้นๆ 
R1>
R1#config terminal
R1(config)#line console 0
R1(config-line)#logging synchronous

==========================================

*** Part3 ***

- OSPF (Open Shortest Path First) เป็น dinamic routing protocol ชนิดหนึ่ง
วิธีการติดตั้ง OSPF บนเราเตอร์

R1>enable
R1#config terminal
R1(config)#router ospf (process id - เป็นตัวเลข)
R1(config-router)#network (เครือข่ายที่อยู่ติดกับเราเตอร์) (wildcard mask) area (area id - เป็นตัวเลข)

วิธีตรวจสอบ ospf routing table
R1#show ip route
R1#show ip protocol

- Wildcard Mask คือค่ากลับ bit ของ subnet mask 
- วิธีหา wildcard mask ให้เอา 255.255.255.255 เป็นตัวตั้ง แล้วเอาไปลบกับ subnet mask

- OSPF จะใช้ค่า interface cost ในการเลือกเส้นทางที่จะไปถึงปลายทาง 

Interface Cost = (10^8)/Bandwidth ของ interface

*** OSPF จะให้ข้อมูลผ่านไปทางเส้นทาง ที่มีค่า interface cost ที่น้อยที่สุด 

-----------------------------------------------------------------------------

- EIGRP (Enhanced Intrior Gateway Routing Protocol) เป็น dynamic routing protocol ที่ Cisco พัฒนาขึ้นมา และเป็น protocol ที่เลือกเส้นทางได้ดีที่สุด 

- วิธีการติดตั้งคำสั่ง EIGRP ทำได้โดย 
R1>enable 
R1#config terminal
R1(config)#router eigrp (AS Number)
R1(config-router)#network (เครือข่ายที่อยู่ติดกับเราเตอร์)

- Metrix ของ EIGRP ได้มาจากการคำนวณค่าต่าง ๆ เหล่านี้ 

Bad - B - Bandwidth คือ Link 
Dog - D - Delay คือ First bit in Last bit out
Really - R - Realiability คือ ความน่าเชื่อถือของเส้นทางนั้นๆ 
Like  - L - Load คือ ความคับคั่งของข้อมูล
Meat  - M - MTU คือ การขนถ่ายข้อมูลจำนวนมากที่สุดต่อหนึ่งหน่อย 

-------------------------------------------------
- สรุป routing protocol 
1. Static Route - ระบุเส้นทาง ปลายทาง และทางออกให้กับเราเตอร์โดยตรง
2. RIP - จะพิจารณาจาก hop เส้นทางไหนน้อย ก็จะไปเส้นทางนั้น
3. OSPF - จะพิจารณาจาก Interface Cost = 10^8/Bandwidth ฝั่งไหนมี Interface Cost น้อยกว่า packet จะไปฝั่งนั้น
4. EIGRP - จะพิจารณาจากการคำนวณ Bad Dod Really Like Meat 

-----------------------------------------------------------
รูปแบบการส่งข้อมูลของอุปกรณ์ใดๆ ไปถึงปลายทาง 

Unicast - ส่งแบบระบุปลายทาง
Multicast - ส่งแบบระบุกลุ่มปลายทาง 
Broadcast - ไม่ระบุปลายทาง 

----------------------------------------------------------------------
- VLAN (Virtual Local Area Network) 
VLAN คือ การแบ่งกลุ่มของ client ออกจากกัน ไม่ให้ติดต่อกันได้ ถึงแม้ว่า
1. จะอยู่บน switch ตัวเดียวกัน
2. IP Address เครือข่ายเดียวกัน  

- ประโยชน์ของการทำ VLAN
1.Security - เพราะว่าบางกลุ่มไม่จำเป็นต้องติดต่อกัน 
2.Network Design/Performance - ประสิทธิภาพของเครือข่าย เป็นการแยก broadcast ให้เป็นกลุ่มเล็ก 

- การติดตั้ง VLAN บนสวิตซ์ สามารถทำได้ดังนี้ 
1. ทำที่ Privilege mode 
SW1>enable
SW1(vlan)#vlan database -> สร้างฐานข้อมูล vlan
SW1(vlan)#vlan 2 name science สร้าง vlan id และ vlan name 

2.ทำที่ Global Configuration Mode
SW1>enable
SW1#conf ter
SW1(config)#vlan 3
SW1(config-vlan)#name guest

- วิธีตรวจสอบ vlan ที่สร้างขึ้นมา 
SW#show vlan brief

-------------------------------------------------------------------------
- Port/Interface บน switch แบ่งได้เป็น 2 แบบ คือ
1. Access Port คือ พอร์ตที่สามารถขนถ่าย vlan ได้เพียง 1 vlan เท่านั้น มักจะนำไปใช้ต่อเข้ากับอุปกรณ์ที่เป็น Client เช่น Computer, IP Phone, Printer, IP Camera เป็นต้น

- วิธีการ configure Access port ทำได้โดย
SW>enable
SW#config ter
SW(config)#int fa0/1
SW(config-if)#switchport mode access
SW(config-if)#switchport access vlan x (x = vlan id)

2. Trunk Port คือ พอร์ตที่สามารถขนถ่าย vlan ได้ทุก vlan มักจะนำไปใช้ต่อระหว่าง switch กับ switch เป็นต้น 

- วิธีการ configure Trunk port ทำได้โดย
SW>enable
SW#config ter
SW(config)#int fa0/1
SW(config-if)#switchport mode trunk

วิธีตรวจสอบ Trunk port 
SW#show int trunk

============================================

*** Part 4 ***

- Mode กระบวนการทำงานของสวิตซ์ ซึ่งทำงานใน Layer 2 (Data Link Layer)
1. Learning - สวิตซ์จะทำการเรียนรู้ค่า MAC Address ของอุปกรณ์ network ที่มาเชื่อมต่อ 
2. Forwarding - สวิตซ์จะทำการส่งต่อ Frame ไปยังพอร์ตปลายทางได้อย่างถูกต้อง 
3. Filtering - กรอง Frame ไม่ให้นำส่งไปยังพอร์ตที่ไม่เกี่ยวข้องกับการสื่อสาร
4. Flooding จะเกิดขึ้นได้ใน 2 กรณี
4.1 สวิตซ์ตรวจไม่พบ MAC Address ใน MAC Address Table 
4.2 สวิตซ์ถูกโจมตี เช่น DOS (Denial of Service) 

SW#show mac-address-table - ใช้สำหรับดูค่า mac address ที่เก็บอยู่ใน mac address table ทั้งหมด

Switch(config-if)#spanning-tree portfast - ไม่ต้องเช็ค spanning tree เพื่อให้ port สามารถ enable และทำงานได้ทันที 

------------------------------------------------------------------------------------

VTP (VLAN Trunking Protocol) เป็น protocol ที่ใช้สำหรับ update ฐานข้อมูล vlan ทั้งหมดออกไปสู่สวิตซ์ได้ จะแบ่งได้เป็น 3 mode
1.Server Mode
- สร้าง/ลบ ฐานข้อมูล vlan (เลข ,ชื่อของ vlan) บนสวิตซ์
- Update ฐานข้อมูล vlan ไปให้กับสวิตซ์ที่ทำงานใน VTP Domain เดียวกัน 
- โดย default สวิตซ์ของ Cisco จะทำงานเป็น Server mode ในกรณีที่เรา Enable VTP ใช้งาน
- ใน 1 ระบบ ไม่ควรมีสวิตซ์ ที่เป็น Server mode เกิน 1 ตัว
2.Client Mode
- จะรับฐานข้อมูล vlan จาก Server เท่านั้น
- เราไม่สามารถ Create/delete/modify vlan จาก mode นี้ได้ 
3.Transparent Mode 
- ส่งต่อฐานข้อมูล vlan ไปให้กับสวิตซ์อื่นๆ ที่ทำงานใน VTP Domain เดียวกันได้
- จะส่งฐานข้อมูล vlan ผ่านออกไป โดยจะไม่เก็บใช้งาน 
- Create/delete/modify ฐานข้อมูล vlan ได้ด้วยตัวเอง 

วิธีการ configure VTP 
SW>enable 
SW#config terminal
SW(config)#VTP domain xxxx - กำหนดชื่อ VTP domain ให้กับสวิตซ์ ตัวเล็ก ตัวใหญ่สำคัญหมด 
SW(config)#VTP mode (server/client/transparent)
SW(config)#VTP password xxx - กำหนด password ให้กับ VTP domain นี้ 

วิธีตรวจสอบ VTP
SW#show vtp status
SW#show vtp counters
SW#show vtp password

-----------------------------------------------------------------------------------------
VLAN to VLAN 

- Inter VLAN Routing จะต้องใช้ Layer 3 switch เข้ามาช่วยเป็น Core Switch 

วิธีการ configure Inter VLAN Routing ทำได้โดย
1. สร้างฐานข้อมูล vlan ที่ Core Switch และทำการสร้าง ip ให้กับ interface ของ vlan ที่เราสร้างขึ้นมาด้วย 
SW>enable
SW#config ter
SW(config)#int vlan 1
SW(config-vlan)#ip address 192.168.1.1 255.255.255.0
SW(config-vlan)#no shut
SW(config)#int vlan 2
SW(config-vlan)#ip address 192.168.2.1 255.255.255.0
SW(config-vlan)#no shut

2. ที่ PC ให้ Gateway ของ client ชี้ไปยัง ip ของ interface vlan ที่สร้างขึ้นมาบน L3 Switch (Core switch)

=== LAB 14 ====

at Core Switch

Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname CORE
CORE(config)#vlan 2
CORE(config-vlan)#name sale
CORE(config-vlan)#vlan 3
CORE(config-vlan)#name support
CORE(config-vlan)#exit
CORE(config)#int range gi0/1 - 2
CORE(config-if-range)#switchport mode trunk
CORE(config-if-range)#exit
CORE(config)#int vlan 2
CORE(config-if)#ip address 192.168.2.1 255.255.255.0
CORE(config-if)#no shut
CORE(config-if)#int vlan 3
CORE(config-if)#ip address 192.168.3.1 255.255.255.0
CORE(config-if)#no shut

at SW1

Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname SW1
SW1(config)#vlan 2
SW1(config-vlan)#name sale
SW1(config-vlan)#vlan 3
SW1(config-vlan)#name support
SW1(config)#int fa0/1
SW1(config-if)#description Link to PC0-VLAN2
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 2
SW1(config-if)#int fa0/2
SW1(config-if)#description Link to PC1-VLAN3
SW1(config-if)#switchport mode access
SW1(config-if)#switchport access vlan 3
SW1(config-if)#int gi1/1
SW1(config-if)#switchport mode trunk

at SW2
Switch>en
Switch#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname SW2
SW2(config)#vlan 2
SW2(config-vlan)#name sale
SW2(config-vlan)#vlan 3
SW2(config-vlan)#name support
SW2(config-vlan)#int fa0/1
SW2(config-if)#description Link to PC2-VLAN2
SW2(config-if)#switchport mode access
SW2(config-if)#switchport access vlan 2
SW2(config-if)#int fa0/2
SW2(config-if)#description Link to PC3-VLAN3
SW2(config-if)#switchport mode access
SW2(config-if)#switchport access vlan 3
SW2(config-if)#int gi1/1
SW2(config-if)#switchport mode trunk

---------------------------------------------------------------------------------------

=== LAB 15 ===

Switch(config)#int fa0/1
Switch(config-if)#switchport mode access
Switch(config-if)#spanning-tree portfast
Switch(config-if)#switchport port-security
Switch(config-if)#switchport port-security mac-address sticky

------------------------------------------------------------------------

วิธีการ configure DHCP Server บน เราเตอร์

R1(config)#ip dhcp excluded-address 192.168.0.1 192.168.0.10
R1(config)#ip dhcp pool yru
R1(config-dhcp)#network 192.168.0.0 255.255.255.0
R1(config-dhcp)#default-router 192.168.0.1
R1(config-dhcp)#dns-server 4.2.2.2

Router#show ip dhcp binding  - ตรวจสอบดูว่าแจก IP ให้กับเครื่องไหน 

==============================================

NAT - Network Address Translation แบ่งออก 3 แบบ คือ

1.Static NAT จะทำการแปลง ip ปลอม ไปเป็น ip จริง แบบ 1:1

R1(config)#ip nat inside source static (ip ปลอม) (ip จริง)
R1(config)#int s0/0/0
R1(config-if)#ip nat out
R1(config)#int fa0/0
R1(config-if)#ip nat in

2.Dynamic NAT จะทำการแปลง ip ปลอม ไปเป็น ip จริง แบบ Many:1

2.Overloading NAT (PAT) จะทำการแปลง ip ปลอมทั้งหมด ไปเป็น ip จริง แบบ All:1

วิธีตรวจสอบ NAT
R1#sh ip nat translations

=== LAB 18 ===

Router(config)#ip nat inside source list 1 interface fa0/1 overload
Router(config)#int fa0/1
Router(config-if)#ip nat out
Router(config-if)#int fa0/0
Router(config-if)#ip nat in






ไม่มีความคิดเห็น:

แสดงความคิดเห็น