104
Leturer: Ta Duy Cong Chien Page 1 Bài tập thực hành Routing and Switching ------------------------------------------------------------- PHẤN I: CÁC THAO TÁC CƠ BẢN Lab 1-1: Đăng nhập vào router – giao diện dòng lệnh Yêu cầu Bài thực hành này giúp người đọc làm quen với chế độ lệnh (CLI-Command Line Interface) và một số lệnh cơ bản của hệ điều hành CiscoIOS. Hướng dẫn Router>enble Router#show verion Router#exit Router>_ Router>enable Router# – Để quay lại user mode bằng lệnh disable hoặc lệnh exit Router#disable Router> – Dùng lệnh logout để thoát chế độ dòng lệnh Router>logout Router con0 is now available Press RETURN to get started. – Bạn đang ở chế độ user mode, nhập ký tự ? (chấm hỏi) để xem các lệnh được dùng trong chế độ này: Router>? Exec commands: access-enable Create a temporary Access-List entry access-profile Apply user-profile to interface clear Reset functions connect Open a terminal connection disable Turn off privileged commands disconnect Disconnect an existing network connection enable Turn on privileged commands

Switching LAb V3

Embed Size (px)

Citation preview

Page 1: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 1

Bài tập thực hành

Routing and Switching

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

PHẤN I: CÁC THAO TÁC CƠ BẢN

Lab 1-1: Đăng nhập vào router – giao diện dòng lệnh

Yêu cầu Bài thực hành này giúp người đọc làm quen với chế độ lệnh (CLI-Command Line Interface) và một số lệnh cơ bản của hệ điều hành CiscoIOS. Hướng dẫn Router>enble

Router#show verion

Router#exit Router>_ Router>enable Router# – Để quay lại user mode bằng lệnh disable hoặc lệnh exit Router#disable Router> – Dùng lệnh logout để thoát chế độ dòng lệnh Router>logout Router con0 is now available Press RETURN to get started.

– Bạn đang ở chế độ user mode, nhập ký tự ? (chấm hỏi) để xem các lệnh được dùng trong chế độ này: Router>? Exec commands: access-enable Create a temporary Access-List entry access-profile Apply user-profile to interface clear Reset functions connect Open a terminal connection disable Turn off privileged commands disconnect Disconnect an existing network connection enable Turn on privileged commands

Page 2: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 2

exit Exit from the EXEC help Description of the interactive help system lock Lock the terminal login Log in as a particular user logout Exit from the EXEC mrinfo Request neighbor and version information from a multicast router mstat Show statistics after multiple multicast traceroutes mtrace Trace reverse multicast path from destination to source name-connection Name an existing network connection pad Open a X.29 PAD connection ping Send echo messages ppp Start IETF Point-to-Point Protocol (PPP) resume Resume an active network connection --More-- Nếu số hàng thông tin cần hiển thị nhiều hơn một trang màn hình (25 hàng), cuối màn hình hiện chữ --More-- bạn nhấn phím ENTER để xem hàng kế tiếp, hoặc phím SPACE để xem trang kế tiếp. Nếu bạn nhấn phím ENTER, thông tin sẽ hiển thị thêm từng hàng. Nếu bạn dùng SPACE BAR, thông tin sẽ hiển thị theo trang màn hình. – Lệnh giúp đỡ (?) rất hữu dụng, bạn có thể dùng trong bất kỳ chế độ nào, Router sẽ đưa ra các mục chọn được phép sử dụng và ý nghĩa của lệnh đó. Ví dụ bạn muốn xem tiếp các phần của lệnh show, bạn gõ: Router>show ? Hoặc bạn không nhớ tất cả những lệnh bắt đầu bằng các k tự te, bạn có thể gõ: Router>te? Telnet Terminal Khi đó, router sẽ liệt kê tất cả các lệnh bắt đầu bằng te. – Hệ điều hành trong Router Cisco cho phép gõ tắt. Bạn chỉ cần gõ số ký tự đủ để phân biệt các câu lệnh với nhau là câu lệnh được chấp nhận, hoặc bạn nhấn phím TAB để hiện đầy đủ câu lệnh. Router>tel[TAB] Router>telnet – Vào chế độ global-configuration-mode, dùng lệnh configuration terminal Router#configuration terminal Enter configuration commands, one per line. End with CNTL/Z.

Page 3: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 3

– Một số tổ hợp phím tắt: Kỳ thi CCNA đòi hỏi người học phải sử dụng thành thạo tổ hợp các phím tắt này. Ngòai ra, một số chương trình dùng làm terminal có thể không hỗ trợ các tổ hợp phím này. Ctrl-A Trở về đầu dòng Ctrl-B Mũi tên trái Trở về một ký tự Esc-B Trở về một từ Ctrl-E Đến cuối dòng Ctrl-F Mũi tên phải Tới một ký tự Ctrl-P Mũi tên lên Đến câu lệnh đã thực hiện trước đó Ctrl-N Mũi tên xuống Đến câu lệnh đã thực hiện sau câu lệnh đó 3. Xem thông tin về cấu hình của router Tại chế độ privileged mode, bạn hãy thực hiện các lệnh sau, và kiểm tra kết quả của từng lệnh: show version Xem tên files IOS, version của IOS đang sử dụng, cấu hình phần cứng của Router, chế độ BOOT (thanh ghi) show flash: dir flash Xem file IOS đang lưu trong flash dir nvram Xem các file đang lưu trong NVRAM show interface [interface] Xem cấu hình của tất cả các cổng hay của cổng được chỉ định show running-config Xem cấu hình chung đang sử dụng show startup-config show configuration Xem cấu hình chung dùng cho khởi động (lưu trong NVRAM)

Page 4: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 4

show clock Xem đồng hồ show user Xem các kết nối đang truy cập vào Router show line Xem tất cả các kết nối (line) của Router show ip route Xem bảng chọn đường của Router show arp Xem bảng tương ứng (map) từ địa chỉ MAC và địa chỉ IP show host Xem tên và địa chỉ của các host đã biết (đã được đặt tên) – Xoá cấu hình được router dùng lúc khởi động: dùng lệnh erase startup-config. Khi đã thực hiện lệnh này, nếu xem lại cấu hình khởi động, bạn sẽ nhận thông báo lỗi Router#erase startup-config Erasing the nvram filesystem will remove all files! Continue? [confirm] [OK] Erase of nvram: complete Router#sh start %% Non-volatile configuration memory is not present Router# 4. Sử dụng HYPER TERMINAL Sử dụng trình tiệc ích truyền file của HYPER TERMINAL – Để có thể cấu hình nhanh một Router, bạn có thể soạn thảo trước các câu lệnh bằng NotePad theo đúng trình tự, lưu dưới dạng file text, sau đó dùng Send Text File... (Transfer -> Send Text File...) để truyền File: Ví dụ: bạn soạn thảo file SHOW.TXT như sau: show version show flash: show running-config show startup-config configuration terminal exit – Cách truyền file chỉ hữu dụng với các lệnh cấu hình không có các thông số xác nhận (một dòng là câu lệnh hoàn chỉnh), không thực hiện được cho các câu lệnh có thông số lựa chọn. Chẳng hạn: không nên dùng cho lệnh enable (vì có thể phải xác nhận mật khẩu), không thể dùng cho lệnh lưu cấu hình vào NVRAM vì có xác nhận tên file:

Page 5: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 5

Router#copy running-config startup-config

Destination filename [startup-config]?

Building configuration...

[OK]

Page 6: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 6

Lab 1-2: Đặt mật khẩu cho router

Lab 1-2: Đặt mật khẩu cho router Mô tả Thông thường có các loại mật khẩu để bảo mật cho một router Cisco như sau: – Loại mật khẩu đầu tiên là enable. Lọai này được sử dụng để vào chế độ enabled mode. Router sẽ yêu cầu bạn nhập mật khẩu này vào khi bạn đánh lệnh enable từ user mode để chuyển sang chế độ enable mode. – Ba loại còn lại là mật khẩu khi người dùng truy cập qua cổng console, cổng Aux, hay Telnet. ¤ Mật khẩu có phân biệt chữ hoa hay chữ thường (case sensitive), và không quá 25 ký tự. Các ký tự này có thể là chữ hoa, chữ thường, con số, các dấu chấm câu và khoảng cách; tuy nhiên ký tự đầu tiên không được là dấu trắng. Thực hiện Mật khẩu truy cập vào enable mode – Hai loại enable mật khẩu trên router, đặt bằng các lệnh sau: Router(config)#enable secret vip ¬ mật khẩu là vip Router(config)#enable password cisco ¬ mật khẩu là cisco – Ở chế độ mặc định, mật khẩu ở dạng không mã hóa (clear-text) trong file cấu hình; Lệnh enable secret password sẽ mã hóa các mật khẩu hiện có của router. Nếu có đặt enable secret, nó sẽ có hiệu lực mạnh hơn các mật khẩu còn lại. Mật khẩu truy cập vào User Mode 1. Đặt mật khẩu cho user mode bằng lệnh line, xem xét các thông số theo sau bằng cách đánh dấu ? sau lệnh line. Router(config)#line ? <0-4> First Line number aux Auxiliary line console Primary terminal line vty Virtual terminal – console đặt mật khẩu trước khi vào user mode – vty đặt mật khẩu để telnet vào router. Nếu không đặt mật khẩu, không thể thực hiện telnet vào router. Để đặt mật khẩu cho user mode, cần xác định line muốn cấu hình và dùng lệnh login để router đưa ra thông báo chứng thực đòi hỏi nhập mật khẩu. Router#config t Enter configuration commands, one per line. End with CNTL/Z.

Page 7: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 7

3. Đặt mật khẩu truy cập cho cổng console trên router: dùng lệnh line console 0 Router(config)#line console 0 Router(config-line)#login Router(config-line)#password test 4. Đặt mật khẩu telnet: dùng lệnh line vty Router(config-line)#line vty 0 4 Router(config-line)#login Router(config-line)#password test Sau khi router cấu hình địa chỉ IP, bạn có thể dùng chương trình Telnet để cấu hình và kiểm tra router thay vì sử dụng cáp console. Kiểm tra Kiểm tra lại các loại mật khẩu đã đặt bằng cách xem cấu hình hiện tại đang chạy, thực hiện lệnh show running-config: Router#show running-config Building configuration... Current configuration: ! version 12.0 service timestamps debug uptime service timestamps log uptime no service password-encryption ! hostname Router ! enable secret 5 $1$Y3Hx$iF7j2hPkFe6/hwJG.NZOg. enable password cisco ! ! interface Ethernet0 no ip address shutdown ! interface Serial0 no ip address shutdown ! ! line con 0 password rrr

Page 8: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 8

login line aux 0 password vip login line vty 0 4 password RRR login ! end Trong cấu hình ta thấy enable secret password ở dạng mã hóa. Các mật khẩu khác ở dạng không mã hóa. Hệ điều hành Cisco IOS cho phép mã hóa tất cả các mật khẩu trong file cấu hình bằng lệnh service password-encryption tại global configuration mode: Router# Router#conf ter Router(config)#service password-encryption Router(config)# [Ctrl–Z] Router#show running-config Building configuration... Current configuration: ! version 12.0 service password-encryption ! hostname Router ! enable secret 5 $1$Y3Hx$iF7j2hPkFe6/hwJG.NZOg. enable password 7 01100F175804 ! ! interface Ethernet0 no ip address shutdown ! interface Serial0 no ip address shutdown ! ! line con 0 password 7 111B0B17 login line aux 0

Page 9: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 9

password 7 0312521B login line vty 0 4 password 7 1520393E login ! end Tất cả các mật khẩu đã được mã hóa. Mật khẩu Enable secret vẫn ở dạng cũ; Mức độ mã hóa được hiển thị bằng chỉ số đứng ngay trước mỗi mật khẩu. Các giá trị có thể có của chỉ số này là: – 7 : mật khẩu được mã hóa theo thuật toán hai chiều MD7; mật khẩu dạng này có thể giải mã được. – 5 : mật khẩu được mã hóa theo thuật toán một chiều MD5; không thể giải mã được dạng này. – 0 : (hoặc không có giá trị) mật khẩu được hiển thị ở dạng không mã hóa. Nếu tắt chế độ mã hóa với câu lệnh no service password-encryption, thì mật khẩu vẫn ở dạng mã hóa trừ khi đặt lại mật khẩu.

Page 10: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 10

1. Lab 1-3: Các lệnh cơ ba n của hệ điều hành Cisco IOS

Lab 1-3: Các lệnh cơ bản của hệ điều hành Cisco IOS 1. Đặt router banner Đặt lời chào khi người dùng đăng nhập qua cổng console hay telnet vào router. Trong thực tế, lệnh banner được dùng để ra các cảnh báo đối với các truy cập trái phép vào router. Lệnh này chỉ có tính chất cung cấp thông tin về hệ thống mà người dùng đang truy cập vào. – Câu lệnh thực hiện tại global configuration mode như sau Router(config)#banner ? LINE c banner-text c, where 'c' is a delimiting character exec Set EXEC process creation banner incoming Set incoming terminal line banner login Set login banner motd Set Message of the Day banner – Tham số motd thường hay được sử dụng nhất. Thông số này đưa ra thông báo cho mọi người khi quay số hay kết nối với router thông qua Telnet, cổng aux hay cổng console. Router(config)#banner motd ? LINE c banner-text c, where 'c' is a delimiting character Router(config)#banner motd # Enter TEXT message. End with the character '#'. Chao cac hoc vien lop CCNA # Router(config)#^Z Router# %SYS-5-CONFIG_I: Configured from console by console Router#exit Router con0 is now available Press RETURN to get started. Chao cac hoc vien lop CCNA Router> – Để loại bỏ banner dùng lệnh no banner login Router#

Page 11: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 11

Router#conf t Router(conf)#no banner login 2. Cấu hình các cổng giao tiếp trên router: Cấu hình các cổng giao tiếp của router là một trong những tác vụ cấu hình quan trọng nhất trong qui trình cấu hình một thiết bị định tuyến router. Tác vụ này phải chính xác để router có thể trao đổi các thông tin với các thiết bị khác cũng như là có thể trao đổi được dữ liệu. Các bước cấu hình như sau: – Tại chế độ cấu hình tòan cục, ta dùng lệnh interface [loại interface] [số thứ tự] – Để cho phép interface hoạt động, hãy dùng lệnh no shutdown. – Để tắt một interface dùng lệnh shutdown. – Nếu một interface bị shutdown, trạng thái hiển thị sẽ là administratively down khi dùng lệnh show interface để xem trạng thái của một cổng giao tiếp. Khi đó, nếu dùng lệnh show running-config, ta sẽ thấy kết quả lệnh sẽ hiển thị trạng thái của các giao tiếp là shutdown. – Mặc định các interface ở trạng thái shutdown. Router#sh inte Ethernet0 is administratively down, line protocol is down Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#inte fa0/0 Router(config-if)#no shutdown Router(config-if)#^Z %LINK-3-UPDOWN: Interface Ethernet0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0, changed state to up Router#sh inte fa0/0 Ethernet0 is up, line protocol is up – Đặt địa chỉ IP cho một interface Router(config)#int e0 Router(config-if)#ip address 172.16.10.2 255.255.255.0 Router(config-if)#no shut Router#sh run Building configuration Current configuration: ... ! interface Ethernet0 ip address 172.16.20.2 255.255.255.0 secondary ip address 172.16.10.2 255.255.255.0

Page 12: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 12

! – Một số lệnh cho cổng serial của router: Lệnh clock rate: đặt xung clock cho DCE. Nếu đặt lệnh clock rate trên một cổng giao tiếp không phải là DCE thì câu lệnh không có tác dụng. Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int s0 Router(config-if)#clock rate ? Speed (bits per second) 1200 2400 4800 9600 19200 38400 56000 64000 72000 125000 148000 250000 500000 800000 1000000 1300000 2000000 4000000 <300-4000000> Choose clockrate from list above Router(config-if)#clock rate 64000 %Error: This command applies only to DCE interfaces Router(config-if)#int s1 Router(config-if)#clock rate 64000 Lệnh bandwith: Ở chế độ mặc định, các cổng giao tiếp của thiết bị định tuyến Cisco sẽ họat động ở băng thông của T1 (1,544 Mbps). Tuy nhiên, lệnh bandwidth không ảnh hưởng gì đến tốc độ truyền dữ liệu thật sự của cổng giao tiếp. Lệnh bandwidth chỉ có tác động đến quá trình tính tóan metric của các giao thức định tuyến như IGRP, EIGRP hay OSPF để tính toán chi phí tốt nhất tới một mạng ở xa. Router(config-if)#bandwidth ? <1-10000000> Bandwidth in kilobits ← Bandwidth được tính bằng Kbit

Page 13: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 13

Router(config-if)#bandwidth 64 – Mô tả cho cổng giao tiếp: mô tả rất hữu ích cho người quản trị và nó chỉ có tác dụng cục bộ, dùng lệnh description tại interface mode; để xem lại dùng lệnh show run hay show interface Router(config)#int e0 Router(config-if)#description Sales Lan Router(config-if)#int s0 Router(config-if)#description Ket noi Wan toi DHCN Router#sh run [...] ! interface Ethernet0 description Sales Lan ip address 172.16.10.30 255.255.255.0 ! interface Serial0 description Ket noi Wan toi PTIT no ip address no ip directed-broadcast no ip mroute-cache Router#sh int e0 Ethernet0 is up, line protocol is up Hardware is Lance, address is 0010.7be8.25db (bia 0010.7be8.25db) Description: Sales Lan ... Router#sh int s0 Serial0 is up, line protocol is up Hardware is HD64570 Description: Ket noi Wan toi PTIT ... Router# 3. Đặt hostname Đặt tên cho router bằng lệnh hostname, tên chỉ có tác dụng cục bộ. Việc đặt hostname là cần thiết trong qui trình cấu hình router. Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname RRR RRR(config)#

Page 14: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 14

4. Lưu cấu hình Dùng lệnh copy running-config startup-config hay write memory để lưu file cấu hình từ DRAM vào NVRAM (có thể dùng lệnh tắt copy run start hay wr) RRR#copy run start Destination filename [startup-config]?[Enter] Building configuration... Xem lại file đã lưu trong NVRAM RRR#show startup-config 5. Các lệnh kiểm tra cấu hình – Lệnh ping có thể dùng với các giao thức khác nhau, thực hiện ở user-mode hay priviledge-mode RRR#ping ? WORD Ping destination address or hostname appletalk Appletalk echo decnet DECnet echo ip IP echo ipx Novell/IPX echo srb srb echo <cr> – Telnet để kiểm tra kết nối IP RRR#telnet ? WORD IP address or hostname of a remote system <cr> Một cách để kiểm tra hoạt động của cổng giao tiếp của router là dùng lệnh show interface. Lệnh này sẽ hiển thị trạng thái của tất cả các cổng giao tiếp của router. Router#sh int ? Ethernet IEEE 802.3 Null Null interface Serial Serial accounting Show interface accounting crb Show interface routing/bridging info irb Show interface routing/bridging info <cr> Có thể chỉ ra cổng giao tiếp để xem thông tin cụ thể về cổng giao tiếp đó. RRR#sh int e0

Page 15: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 15

Ethernet0 is up, line protocol is up Hardware is Lance, address is 0010.7b7f.c26c (bia 0010.7b7f.c26c) Internet address is 172.16.10.1/24 MTU 1500 bytes, BW 10000 Kbit, DLY 1000 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation ARPA, loopback not set, keepalive set (10 sec) ARP type: ARPA, ARP Timeout 04:00:00 Last input 00:08:23, output 00:08:20, output hang never Last clearing of "show interface" counters never Queueing strategy: fifo ... Một số thông báo sự cố thường gặp đối với cổng giao tiếp serial và cách giải quyết sự cố (trạng thái liên kết xem bằng lệnh show interface serial x trong đó x là số thứ tự của cổng). Thực hiện no shutdown trong cấu hình cổng serial ở cả hai phía. Serial x is up, line protocol is down. – Cấu hình sai giữa hai router ở hai đầu. – Remote router không gửi keepalive packet. – Clock rate chưa được đặt trên Router DCE – Kiểm tra lại cấu hình IP ở hai đầu và phải đảm bảo encapsulation giống nhau. – Bò lệnh no keepalive ờ hai đầu trong cấu hình cổng serial – Đặt clock rate cho Router DCE bằng lệnh clock rate xxxxx trong cầu hình cổng serial. – Dùng lệnh show running–config để xem xét có cổng nào bị cấu hình dưới dạng loop hay không. Nếu có, bỏ trạng thái này đi. – Reset lại cổng bằng lệnh shutdown, rồi sau đó no shutdown.

Page 16: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 16

Lab 1.4 Cisco Discovery Protocol

Mô tả –Cisco Discovery Protocol (CDP) là giao thức riêng của Cisco dùng để thu thập thông tin về các thiết bị lân cận. Khi sử dụng giao thức CDP, bạn có thể biết được thông tin phần cứng, phần mềm của các thiết bị gần kề. Thông tin này rất hữu ích trong quá trình xử lý sự cố hay kiểm soát các thiết bị trong một hệ thống mạng. –Bài thực hành này giúp bạn biết được các chức năng và thông số của các lệnh liên quan tới CDP. + CDP chỉ cung cấp thông tin về thiết bị nối kết nối trực tiếp, trái với giao thức định tuyến. Giao thức định tuyến cung cấp thông tin cho phép router xác định chặng kế cho các mạng muốn tới. Thực hiện Trước tiên, cấu hình các router như sau. Mặc định, các thiết bị Cisco đã có cho phép giao thức CDP. Do đó, khi dùng lệnh show run, thông tin về CDP sẽ không được hiển thị. RouterA ! hostname RouterA ! interface serial0 ip address 172.16.10.1 255.255.255.0 clock rate 64000 ← hoạt động như là DCE cung cấp xung clock no shut ! interface ethernet0 ip address 192.168.0.1 255.255.255.0 no shut ! no ip classless ! line console 0 line aux 0 line vty 0 4 login ! end RouterB

Page 17: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 17

! hostname RouterB ! interface serial0 ip address 172.16.10.2 255.255.255.0 no shut ! no ip classless ! line console 0 line aux 0 line vty 0 4 login ! End 1.Để xem thông tin về các thông số thời gian của CDP, dùng lệnh show cdp (hay sh cdp) Router#sh cdp Global CDP information: Sending CDP packets every 60 seconds Sending a holdtime value of 180 seconds Router# Dùng lệnh cdp holdtime và cdp timer để đặt lại thời gian gởi và thời gian giữ gói cho router. – CDP timer là chu kỳ gởi gói CDP tới tới tất cả cổng đang hoạt động. – CDP holdtime là khoảng thời gian thiết bị giữ gói nhận được từ láng giềng. RouterA#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#cdp ? holdtime Specify the holdtime (in sec) to be sent in packets timer Specify the rate at which CDP packets aresent(in sec) run RouterA(config)#cdp timer 90 RouterA(config)#cdp holdtime 240 RouterA(config)#^Z Bạn có thể tắt hòan tòan giao thức CDP trong thiết bị Cisco với lệnh no cdp run. Để tắt CDP trên một cổng sử dụng câu lệnh no cdp enable trên cổng đó. 2.Lệnh show cdp neighbor (viết tắt sh cdp nei) hiện thông tin về thiết bị nối trực tiếp. RouterA#sh cdp nei Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge, S - Switch, H - Host, I - IGMP, r - Repeater Device ID Local Interfce Holdtme Capability Platform Port ID Switch Eth 0 238 T S 1900 2 RouterB Ser 0 138 R 2500 Ser 0 RouterA# Một lệnh khác cho biết thông tin về các thiết bị láng giềng là show cdp neighbor detail (show cdp nei de),

Page 18: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 18

cũng có thể chạy trên router và switch RouterA#sh cdp neighbor detail ------------------------- Device ID: 1900Switch Entry address(es): IP address: 0.0.0.0 Platform: cisco 1900, Capabilities: Trans-Bridge Switch Interface: Ethernet0, Port ID (outgoing port): 2 Holdtime : 166 sec Version : V9.00 ------------------------- Device ID: 2501B Entry address(es): IP address: 172.16.10.2 Platform: cisco 2500, Capabilities: Router Interface: Serial0, Port ID (outgoing port): Serial0 Holdtime : 154 sec <...> RouterA# Ngoài ra, lệnh show cdp entry * cũng hiển thị thông tin tương tư. Lệnh show cdp traffic hiển thị lưu lượng tại cổng gồm cả số gói CDP gởi nhận và bị lỗi : RouterA#sh cdp traffic CDP counters: Packets output: 13, Input: 8 Hdr syntax: 0, Chksum error: 0, Encaps failed: 0 No memory: 0, Invalid packet: 0, Fragmented: 0 RouterA# 3.Thông tin trạng thái CDP trên port hay cổng hiển thị bằng lệnh show cdp interface (sh cdp int) Như đã đề cập trước, có thể tắt CDP hoàn toàn trên router dùng lệnh no cdp run. Tuy nhiên, muốn tắt CDP trên từng cổng dùng lệnh no cdp enable. Có thể cho phép CDP trên một port bằng lệnh cdp enable. Trên router, show cdp interface cho thông tin về từng cổng dùng CDP, gồm cả dạng đóng gói trên đường truyền, timer và holdtime trên mỗi cổng RouterA#sh cdp interface Ethernet0 is up, line protocol is up Encapsulation ARPA Sending CDP packets every 60 seconds Holdtime is 180 seconds Serial0 is administratively down, line protocol is down Encapsulation HDLC Sending CDP packets every 60 seconds Holdtime is 180 seconds Serial1 is administratively down, line protocol is down Encapsulation HDLC Sending CDP packets every 60 seconds Holdtime is 180 seconds Tắt CDP trên một cổng

Page 19: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 19

RouterA#config t Enter configuration commands, one per line. End withCNTL/Z. RouterA(config)#int s0 RouterA(config-if)#no cdp enable RouterA(config-if)#^Z Kiểm tra lại sự thay đổi đó. RouterA#sh cdp int Ethernet0 is up, line protocol is up Encapsulation ARPA Sending CDP packets every 60 seconds Holdtime is 180 seconds Serial1 is administratively down, line protocol is down Encapsulation HDLC Sending CDP packets every 60 seconds Holdtime is 180 seconds Router# Lưu ý rằng serial 0 không được liệt kê khi thực hiện lệnh trên, nếu dùng lệnh cdp enable trên serial 0, cổng này sẽ hiển thị.

Page 20: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 20

Lab 1-5: Sử dụng Telnet

Mô tả –Telnet là một giao thức đầu cuối ảo (virtual terminal) là một phần của chồng giao thức TCP/IP. Telnet cho phép tạo kết nối với thiết bị từ xa, thu thập thông tin và chạy chương trình. –Lab này hướng dẫn dùng lệnh telnet và các lệnh liên quan trên router. + Virtual terminal (VTY) lines cho phép việc truy cập vào router thông qua các phiên nối kết Telnet. VTY lines không nối trực tiếp vào các cổngs như cách TTY nối vào asynchronous interface mà là các kết nối “ảo” vào router thông qua địa chỉ của ethernet port (cổng ethernet). Router tạo những VTY lines một cách linh động, trong khi đó TTY lines là chỉ nối kết vào những cổng vật lý. Khi người dùng kết nối vào router bằng VTY line, người dùng đó đang kết nối vào một cổng ảo trên cổng. Thực hiện Ban đầu cấu hình router như sau RouterA ! hostname RouterA ! interface serial0 ip address 172.16.10.1 255.255.255.0 clock rate 64000 ← hoạt động như là thiết bị DCE cung cấp xung clock no shut ! interface ethernet0 ip address 192.168.0.1 255.255.255.0 no shut ← cho phép cổng ! line console 0 line aux 0 line vty 0 4 login !

Page 21: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 21

end RouterB ! hostname RouterB ! interface serial0 ip address 172.16.10.2 255.255.255.0 no shut ! line console 0 line aux 0 line vty 0 4 login ! end Đặt địa chỉ IP, mật khẩu dùng để telnet cho Switch – Với Catalyst 2900 ! hostname Switch ! enable password cisco ! interface vlan1 ip address 192.168.0.148 255.255.255.0 ! line vty 0 15 login password cisco ! End Tiến hành các bước sau đây để kiểm tra kết quả: 1.Thử dùng lệnh telnet trên router: RouterA#telnet 172.16.10.2 Trying 172.16.10.2 ... Open Password required, but none set [Connection to 172.16.10.2 closed by foreign host] RouterA# + Đối với Cisco router, bạn không cần phải dùng lệnh telnet mà chỉ cần đánh địa

Page 22: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 22

chỉ IP tại dấu nhắc, router sẽ ngầm định rằng bạn muốn telnet vào thiết bị, ví dụ: RouterA#172.16.10.2 Trying 172.16.10.2 ... Open Password required, but none set [Connection to 172.16.10.2 closed by foreign host] RouterA# Trong trường hợp trên, mật khẩu chưa được đặt cho đường VTY nên ta không thể telnet vào RouterB được. Đặt mật khẩu cho đường VTY như sau RouterB#config t Enter configuration commands, one per line. End with CNTL/Z. RouterB(config)#line vty 0 4 RouterB(config-line)#login RouterB(config-line)#mật khẩu Router RouterB(config-line)#^Z RouterB# Thử truy cập bằng cách telnet vào router lần nữa: RouterA#172.16.10.2 Trying 172.16.10.2 ... Open User Access Verification Mật khẩu: RouterB> Chú ý rằng mật khẩu VTY là mật khẩu ở user-mode, không phải là enable–mode nên không thể vào enable mode nếu chưa đặt enable password. RouterB>en % No password set RouterB> 2.Telnet vào nhiều thiết bị đồng thời Bạn có thể giữ kết nối mà trở về router console ban đầu bằng cách nhấn Ctrl+Shift+6 đồng thời, sau đó thả ra và nhấn X. RouterA#telnet 172.16.10.2 Trying 172.16.10.2 ... Open User Access Verification

Page 23: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 23

Mật khẩu: RouterB>[Ctrl+Shift+6, x] RouterA# Telnet tiếp tục vào switch RouterA#telnet 192.168.0.148 Trying 192.168.0.148 ... Open ... Switch>[Ctrl+Shift+6, x] RouterA# 3.Kiểm tra các kết nối telnet bằng lệnh show sessions. RouterA#sh sessions Conn Host Address Byte Idle Conn Name 1 172.16.10.2 172.16.10.2 0 0 172.16.10.2 * 2 192.168.0.148 192.168.0.148 0 0 192.168.0.148 RouterA# Dấu (*) nghĩa là session cuối cùng bạn dùng; có thể trở lại session cuối bằng cách nhấn Enter hai lần. Hay muốn tới session bất kỳ bằng cách gõ số của kết nối và nhấn Enter hai lần. –Kiểm tra Telnet Users RouterA#sh users Line User Host(s) Idle Location * 0 con 0 172.16.10.2 00:07:52 192.168.0.148 Ký hiệu con tượng trưng cho local console. RouterB>sh users Line User Host(s) Idle Location 0 con 0 idle 9 * 2 vty 0 Thông tin hiển thị console đang hoạt động và VTY port 2 đang được dùng. Dấu * phiên người dùng hiện tại. 4.Đóng phiên làm việc Telnet –Có thể đóng phiên làm việc bằng các nhấn exit hay disconnect RouterA#[Enter] [Enter] [Resuming connection 2 to 192.168.0.148 ... ] Switch>exit [Connection to 192.168.0.148 closed by foreign host]

Page 24: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 24

RouterA#disconnect ? ← tham số theo sau là số thứ tự Conn hiển thị trong lệnh show sessions <1-2> The number of an active network connection WORD The name of an active network connection <cr> RouterA#disconnect 1 Closing connection to 172.16.10.2 [confirm] RouterA# –Để ngắt một kết nối của một user dùng lệnh clear line RouterB#clear line 2 ← tham số theo sau là số thứ tự line hiển thị trong lệnh show users [confirm] [OK]

Page 25: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 25

PHẦN II: SWITCHING

Lab 2-1 Cấu hình căn bản Catalyst 2900

Mô tả : –Phần thực hành này mô tả cách cấu hình các thông số cơ bản cho thiết bị switch Catalyst 2900. Các thông số cơ bản bao gồm đặt tên, địa chỉ IP, và mật khẩu. Thực hiện : 1.Nối cổng COM của máy tính với cổng console của Catalyst 2900 (ở mặt sau của switch) dùng cáp Rolled-over. Các thông số truy cập: 8 data bit , no parity, 1 stop bit, no flow control. 2.Bật switch và xem quá trình khởi động (cần khoảng 1 phút để 2900 khởi động xong) C2900XL Boot Loader (C2900-HBOOT-M) Version 12.0(5)XU, RELEASE SOFTWARE (fc1) Compiled Mon 03-Apr-00 17:20 by swati starting... Base ethernet MAC Address: 00:02:b9:9a:85:80 Xmodem file system is available. Initializing Flash... flashfs[0]: 108 files, 3 directories flashfs[0]: 0 orphaned files, 0 orphaned directories flashfs[0]: Total bytes: 3612672 flashfs[0]: Bytes used: 2775040 flashfs[0]: Bytes available: 837632 flashfs[0]: flashfs fsck took 6 seconds. ...done Initializing Flash. Boot Sector Filesystem (bs:) installed, fsid: 3 Parameter Block Filesystem (pb:) installed, fsid: 4 Loading "flash:c2900XL-c3h2s-mz-120.5- XU.bin"...######################################## ################## ################################################## ##################

Page 26: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 26

… 3.Khi khởi động xong, bạn sẽ được thông báo bằng System Configuration Dialog (do chưa có cấu hình lưu trong switch). IOS (tm) C2900XL Software (C2900XL-C3H2S-M), Version 12.0(5)XU,RELEASE SOFTWARE Copyright (c) 1986-2000 by cisco Systems, Inc. Compiled Mon 03-Apr-00 16:37 by swati --- System Configuration Dialog --- At any point you may enter a question mark '?' for help. Use ctrl-c to abort configuration dialog at any prompt. Default settings are in square brackets '[]'. Continue with configuration dialog? [yes/no]: Cũng giống như router nhấn no để không vào Setup mode chuyển trực tiếp sang user exec mode: Switch> 4.Nhấn enable vào privileged mode: Switch>enable Switch#show running-config Building configuration... Current configuration: ! version 12.0 no service pad service timestamps debug uptime service timestamps log uptime no service mật khẩu-encryption ! hostname Switch ! ip subnet-zero ! interface FastEthernet0/1 ! interface FastEthernet0/2 ! interface FastEthernet0/3 ! interface FastEthernet0/4 !

Page 27: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 27

interface FastEthernet0/5 ! interface FastEthernet0/6 ! interface FastEthernet0/7 ! interface FastEthernet0/8 ! interface FastEthernet0/9 ! interface FastEthernet0/10 ! interface FastEthernet0/11 ! interface FastEthernet0/12 ! interface VLAN1 no ip directed-broadcast no ip route-cache ! line con 0 transport input none stopbits 1 line vty 5 15 ! end Như đã hiển thị ở trên, cấu hình của switch rất giống với IOS trên router. Các interface trên switch là các port của switch. Lưu ý sẽ không có bất kỳ cấu định tuyến nào trên switch, bạn sẽ không thấy bất cứ lệnh nào liên quan tới định tuyến gói tin. 5.Bước tiếp theo, ta đặt tên cho switch, đặt các mật khẩu truy cập Đặt tên: Switch#config terminal Switch(config)#host ALSwitch ALSwitch(config)# Đặt mật khẩu ALSwitch(config)#enable password class ALSwitch(config)#line con 0 ALSwitch(config-line)#password cisco ALSwitch(config-line)#login ALSwitch(config-line)#line vty 0 15

Page 28: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 28

ALSwitch(config-line)#password cisco ALSwitch(config-line)#login Dùng câu lệnh copy để lưu cấu hình từ RAM vào NVRAM: ALSwitch#copy running-config startup-config 6.Đặt địa chỉ IP cho switch để nó có thể liên lạc với các thiết bị khác qua trên mạng. Switch là một thiết bị lớp 2. Việc đặt IP address cho switch chỉ nhằm mục đích quản trị. Tất cả các port mặt định của VLAN 1, do đó phải cấu hình cho quản lý switch dùng VLAN 1. Bạn cấu hình VLAN 1 như cấu hình một cổng giao tiếp của router khi gán địa chỉ IP. ALSwitch#config terminal ALSwitch(config)#interface vlan 1 ALSwitch(config-if)#ip address 10.1.1.251 255.255.255.0 Vì switch không thể cấu hình giao thức định tuyến, nên để tới tất cả các mạng, ta phải cấu hình một địa chỉ gateway mặc định để gởi tất cả lưu lượng khi ta cần liên lạc giữa các VLAN. ALSwitch(config)#ip default-gateway 10.1.1.1 7.Cấu hình PC của bạn cho nó là một thành phần trong mạng 10.1.1.0/24 (giả sử đặt địa chỉ IP cho PC là 10.1.1.10/24). Cắm PC vào một port bất kỳ của switch. Từ PC Telnet vào switch dùng địa chỉ đã cấu hình 10.1.1.251 (Từ Window: Start/Run/Telnet 10.1.1.251) Sau khi đã telnet thành công, thử một số lệnh trên switch: ALSwitch#show interfaces FastEthernet0/1 is down, line protocol is down Hardware is Fast Ethernet, address is 0002.fd49.7b81 (bia 0002.fd49.7b81) MTU 1500 bytes, BW 0 Kbit, DLY 100 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation ARPA, loopback not set Keepalive not set Auto-duplex , Auto Speed , 100BaseTX/FX ARP type: ARPA, ARP Timeout 04:00:00 Last input never, output never, output hang never Last clearing of "show interface" counters never

Page 29: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 29

--More— Lệnh show version để xem thông tin phần cứng và phần mềm ALSwitch#show version Cisco Internetwork Operating System Software IOS (tm) C2900XL Software (C2900XL-C3H2S-M), Version 12.0(5)XU, RELEASE SOFTWARE Compiled Mon 03-Apr-00 16:37 by swati Image text-base: 0x00003000, data-base: 0x00301398 ROM: Bootstrap program is C2900XL boot loader ALSwitch uptime is 16 minutes System returned to ROM by power-on System image file is "flash:c2900XL-c3h2s-mz-120.5-XU.bin" cisco WS-C2924-XL (PowerPC403GA) processor (revision 0x11) with 8192K/1024K bytes of memory. . . . . 24 FastEthernet/IEEE 802.3 interface(s) 32K bytes of flash-simulated non-volatile configuration memory. Base ethernet MAC Address: 00:02:FD:49:7B:80 Motherboard assembly number: 73-3382-08 Power supply part number: 34-0834-01 Motherboard serial number: FAB04301ANJ Power supply serial number: PHI04150042 Model revision number: A0 Motherboard revision number: B0 Model number: WS-C2924-XL-EN System serial number: FAB0432S2GJ Configuration register is 0xF ALSwitch#

Page 30: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 30

Lab 2-2: VLAN

Mô tả –Cấu hình trên switch Catalyst 2900 XL hỗ trợ 4 VLAN: Marketing, Accounting, Enginerring và Network Management theo bảng sau: VLANs VLAN 1: Network Management VLAN 10: Accounting VLAN 20: Marketing VLAN 30: Engineering Port Numbers Fa0/1 – Fa0/3 Fa0/4 – Fa0/6 Fa0/7 – Fa0/9 Fa0/10 – Fa0/12

+ Trong khi triển khai VLAN trong một hệ thống mạng cục bộ, người quản trị có thể thiết kế VLAN theo hai cách thức: * Thiết kế VLAN theo dạng end-to-end: còn gọi là campus-wide. Trong kiểu chia VLAN này, VLAN sẽ trải rộng trên toàn campus. Một thành viên của VLAN đó di chuyển trong mạng, thuộc tính là thành viên của VLAN đó không thay đổi. Điều này có nghĩa là, mỗi VLAN phải sẵn có ở từng switch, đặc biệt là những switch nằm ở layer access trong mô hình 3-layer: core-distribution-access. Như vậy, trong end-to-end VLAN, các người dùng sẽ được nhóm vào thành những nhóm dựa theo chức năng, theo nhóm dự án hoặc theo cách mà những người dùng đó sử dụng tài nguyên mạng. *Chia VLAN dạng cục bộ: VLAN được giới hạn trong một switch hoặc một khu vực địa lý hẹp (trong một wiring closet). L y do để dùng dạng VLAN này là các VLAN dạng end-to-end trở nên khó duy trì. Các người dùng thường xuyên yêu cầu nhiều tài nguyên khác nhau. Các tài nguyên này thường nằm trong nhìều VLAN khác nhau.

Page 31: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 31

Thực hiện 1.Trước tiên phải tạo cơ sở dữ liệu VLAN. Mỗi VLAN có một số phân biệt là vlan-id, có thể từ 1 đến 1001. Để tạo cơ sở dữ liệu VLAN (VLAN database) thực hiện các bước như sau: –Vào mode cấu hình cho VLAN database: Switch#vlan database

–Tạo mới VLAN bằng câu lệnh vlan vlan-id [name name]. Nếu không đặt tên cho VLAN thì tên sẽ được lấy mặc định Switch(vlan)# vlan 20 name marketing

–Cập nhật dữ liệu VLAN vào cơ sở dữ liệu VLAN, và thoát về priviledge mode. Switch(vlan)# exit

–Kiểm tra cấu hình VLAN bằng lệnh show vlan Switch# vlan database Switch(vlan)# vlan 20 name marketing VLAN 20 added: Name: marketing Switch(vlan)# exit APPLY completed. Exiting.... Switch# show vlan name marketing VLAN Name Status Ports ---- -------------------------------- --------- --------------------- 20 marketing active VLAN Type SAID MTU Parent RingNo BridgeNo Stp Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- ------ ------ 20 enet 100003 1500 - - - - 0 0

Việc tạo ra các VLAN khác sẽ được thực hiện tương tự. 2.Gán các port cho VLAN tương ứng. Trước tiên cần cấu hình tất cả các port là “access” ports. Các port trên switch 2900 có thể ở 1 trong 3 chế độ: trunk port, multi-VLAN port và access port. Trunk port và multi-VLAN port được dùng để nối với switch khác (hoặc thiết bị khác có tạo VLAN trunking). Do kết nối các workstation với các port này nên cần phải cấu hình tất cả các port này ở chế độ access port. Switch(config)#interface fa0/1 Switch(config-if)#switchport mode access

Gán các port vào VLAN theo yêu cầu bằng cách sử dụng lệnh switchport access vlan n (n là số hiệu VLAN) Switch(config)#interface fa0/4 Switch(config-if)#switchport access vlan 10 Switch(config)#interface fa0/5

Page 32: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 32

Switch(config-if)#switchport access vlan 10 Switch(config)#interface fa0/6 Switch(config-if)#switchport access vlan 10 Switch(config)#interface fa0/7 Switch(config-if)#switchport access vlan 20 Switch(config)#interface fa0/8 Switch(config-if)#switchport access vlan 20 Switch(config)#interface fa0/9 Switch(config-if)#switchport access vlan 20 Switch(config)#interface fa0/10 Switch(config-if)#switchport access vlan 30 Switch(config)#interface fa0/11 Switch(config-if)#switchport access vlan 30 Switch(config)#interface fa0/12 Switch(config-if)#switchport access vlan 30

Bạn không cần phải cấu hình port fa0/1-fa0/3 là VLAN 1 vì mặc định các port được gán vào VLAN 1. Ví dụ cấu hình gán port 07 cho VLAN 20 và kiểm tra lại cấu hình Switch# configure terminal Enter configuration commands, one per line. End with CNTL/Z. Switch(config)# interface fa0/7 Switch(config-if)# switchport mode access Switch(config-if)# switchport access vlan 20 Switch(config-if)# end Switch# show interface fa0/7 switchport Name: Fa0/7 Switchport: Enabled Administrative mode: static access Operational Mode: static access Administrative Trunking Encapsulation: isl Operational Trunking Encapsulation: isl Negotiation of Trunking: Disabled Access Mode VLAN: 20 (marketing) Trunking Native Mode VLAN: 1 (default) Trunking VLANs Enabled: NONE Pruning VLANs Enabled: NONE

3.Thực hiện kiểm tra các VLAN trên switch bằng lệnh show vlan Switch# show vlan brief VLAN Name Status Ports ---- -------------------------------- --------- --------------------- 1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/13, Fa0/14, Fa0/15, Fa0/16 10 Accounting active Fa0/4 – Fa0/6 20 maketing active Fa0/7 – Fa0/9 30 Engineering active Fa0/10 – Fa0/12 40 VLAN0040 active 1002 fddi-default active 1003 token-ring-default active

Page 33: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 33

1004 fddinet-default active 1005 trnet-default active

Page 34: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 34

Lab 2-3: VLAN Trunking

Mô tả

–VLAN cho phép kết hợp các port trên switch thành các nhóm để giảm lưu lượng broadcast trên mạng. Các lưu lượng này được giới hạn trong phạm vi được xác định bởi VLAN. –Kết nối trunk là liên kết point-to-point giữa các port trên switch với router hoặc với switch khác. Kết nối trunk sẽ vận chuyển thông tin của nhiều VLAN thông qua 1 liên kết đơn và cho phép mở rộng VLAN trên hệ thống mạng. –VTP (VLAN Trunking Protocol) là giao thức hoạt động ở Layer 2 trong mô hình OSI. VTP giúp cho việc cấu hình VLAN luôn đồng nhất khi thêm, xoá, sửa thông tin về VLAN trong hệ thống mạng. –Bài thực hành này mô tả cách thức tạo trunk giữa 2 switch. Trunking được cấu hình trên port FA0/1 của hai switch. Ta nên dùng cáp chéo để nối hai port này. Cấu hình Switch 1 ! hostname DL1 ! enable password cisco ! interface FastEthernet0/1 switchport trunk encapsulation isl switchport mode trunk ! interface FastEthernet0/4 switchport access vlan 10 switchport mode access ! interface FastEthernet0/5 switchport access vlan 10 switchport mode access

Page 35: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 35

! interface FastEthernet0/6 switchport access vlan 10 switchport mode access ! interface FastEthernet0/7 switchport access vlan 20 switchport mode access ! interface FastEthernet0/8 switchport access vlan 20 switchport mode access ! interface FastEthernet0/9 switchport access vlan 20 switchport mode access ! interface FastEthernet0/10 switchport access vlan 30 switchport mode access ! interface FastEthernet0/11 switchport access vlan 30 switchport mode access ! interface FastEthernet0/12 switchport access vlan 30 switchport mode access ! interface Vlan1 ip address 192.168.1.2 255.255.255.0 ! interface Vlan10 ip address 192.168.10.2 255.255.255.0 ! interface Vlan20 ip address 192.168.20.2 255.255.255.0 ! interface Vlan30 ip address 192.168.30.2 255.255.255.0 ! line vty 0 4 password cisco login line vty 5 15 password cisco login ! end Switch 2 ! hostname AL1 ! enable password cisco ! interface FastEthernet0/1 switchport trunk encapsulation isl switchport mode trunk ! interface FastEthernet0/4 switchport access vlan 10

Page 36: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 36

switchport mode access ! interface FastEthernet0/5 switchport access vlan 10 switchport mode access ! interface FastEthernet0/6 switchport access vlan 10 switchport mode access ! interface FastEthernet0/7 switchport access vlan 20 switchport mode access ! interface FastEthernet0/8 switchport access vlan 20 switchport mode access ! interface FastEthernet0/9 switchport access vlan 20 switchport mode access ! interface FastEthernet0/10 switchport access vlan 30 switchport mode access ! interface FastEthernet0/11 switchport access vlan 30 switchport mode access ! interface FastEthernet0/12 switchport access vlan 30 switchport mode access ! interface VLAN1 ip address 192.168.1.3 255.255.255.0 no ip directed-broadcast no ip route-cache ! line vty 0 4 mật khẩu cisco login line vty 5 15 mật khẩu cisco login ! end

Thực hiện Cấu hình trên Switch DL1 làm VTP Server 1. Đặt hostname, mật khẩu và cấu hình cổng vlan trên DL1: Switch#conf t Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#hostname DL1 DL1(config)#enable password cisco DL1(config)#line vty 0 15 DL1(config-line)#password cisco DL1(config-line)#login DL1(config-line)#exit DL1(config)#int vlan 1 DL1(config-if)#ip address 192.168.1.3 255.255.255.0 DL1(config-if)#end

Page 37: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 37

DL1# 2. Thiết lập VTP domain là DHCN, VTP mode là SERVER, tạo ra các VLAN 10 (SALES), 20 (ACCOUNTING), 30 (ENGINEERING) DL1#vlan database

Thiết lập chếDL1(vlan)#vtp server độ VTP server mode

đặt switch DL1 vào domainDL1(vlan)#vtp domain DHCN DHCN

Tạo VLAN 10 và đặt tên làDL1(vlan)#vlan 10 name SALES SALES VLAN 10 added: Name: SALES DL1(vlan)#vlan 20 name ACCOUNTING VLAN 20 added: Name: ACCOUNTING DL1(vlan)#vlan 30 name ENGINEERING VLAN 30 added: Name: ENGINEERING

Lưu cấpDL1(vlan)#apply hình vào file vlan.dat APPLY completed. DL1(vlan)#exit APPLY completed. Exiting.... DL1# + Một switch chỉ thuộc 1 VTP domain Mặc định switch ở chế độ VTP server mode 3. Kích hoạt trunking trên cổng Fa0/1 và cho phép tất cả các VLAN qua trunk: DL1#conf t Enter configuration commands, one per line. End with CNTL/Z. DL1(config)#int f0/1 DL1(config-if)#switchport mode trunk DL1(config-if)#switchport trunk đóng gói kiểu isl (hoặc dot1q) để đi qua

đườngencapsulation isl trunk

Cho phép tất cảDL1(config-if)#switchport trunk allowed vlan all các VLAN qua trunk DL1(config-if)#exit DL1(config)# + Giả sử ta chỉ muốn cho phép các VLAN 10, 20, 30 ta dùng lệnh: DL1(config-if)#switchport trunk allowed vlan 10 DL1(config-if)#switchport trunk allowed vlan 20 DL1(config-if)#switchport trunk allowed vlan 30 4. Gán các port vào VLAN tương ứng DL1(config)#int f0/4

DL1(config-if)#switchport mode access Cấu hình cổng ở access mode

DL1(config-if)#switchport access vlan 10 cấu hình cổng vào vlan 10 !–– Mỗi access port chỉ phục vụ cho một VLAN DL1(config-if)#int f0/5 DL1(config-if)#switchport mode access DL1(config-if)#switchport access vlan 10 DL1(config-if)#int f0/6 DL1(config-if)#switchport mode access DL1(config-if)#switchport access vlan 10 DL1(config)#int f0/7 DL1(config-if)#switchport mode access DL1(config-if)#switchport access vlan 20 DL1(config-if)#int f0/8 DL1(config-if)#switchport mode access

Page 38: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 38

DL1(config-if)#switchport access vlan 20 DL1(config-if)#int f0/9 DL1(config-if)#switchport mode access DL1(config-if)#switchport access vlan 20 DL1(config)#int f0/10 DL1(config-if)#switchport mode access DL1(config-if)#switchport access vlan 30 DL1(config-if)#int f0/11 DL1(config-if)#switchport mode access DL1(config-if)#switchport access vlan 30 DL1(config-if)#int f0/12 DL1(config-if)#switchport mode access DL1(config-if)#switchport access vlan 30

5. Xem cấu hình vừa thực hiện DL1#sh vlan brief VLAN Name Status Ports ---- -------------------------------- --------- ------------------------------ 1 default active Fa0/2, Fa0/3, Fa0/13, Fa0/14 Fa0/15, Fa0/16, Fa0/17, Fa0/18 Fa0/19, Fa0/20, Fa0/21, Fa0/22 Fa0/23, Fa0/24, Gi0/1, Gi0/2 10 SALES active Fa0/4, Fa0/5, Fa0/6 20 ACCOUNTING active Fa0/7, Fa0/8, Fa0/9 30 ENGINEERING active Fa0/10, Fa0/11, Fa0/12 1002 fddi-default act/unsup 1003 token-ring-default act/unsup 1004 fddinet-default act/unsup 1005 trnet-default act/unsup DL1# Cấu hình trên Switch AL1 làm VTP Client 1. Đặt hostname, mật khẩu và cấu hình management vlan trên DL1: Switch#conf t Enter configuration commands, one per line. End with CNTL/Z. Switch(config)#hostname AL1 AL1(config)#enable mật khẩu cisco AL1(config)#line vty 0 15 AL1(config-line)#mật khẩu cisco AL1(config-line)#login AL1(config-line)#exit AL1(config)#int vlan 1 AL1(config-if)#ip address 192.168.1.2 255.255.255.0 AL1(config-if)#end AL1#

2. Thiết lập VTP domain là DHCN, VTP mode là CLIENT AL1#vlan database AL1(vlan)#vtp client AL1(vlan)#vtp domain TEST AL1(vlan)#exit In CLIENT state, no apply attempted. Exiting.... AL1# 3. Kích hoạt trunking trên cổng Fa0/1 và cho phép tất cả các VLAN qua trunk:

Page 39: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 39

AL1#conf t Enter configuration commands, one per line. End with CNTL/Z. AL1(config)#int f0/1 AL1(config-if)#switchport mode trunk

Cho phép tất cảAL1(config-if)#switchport trunk allowed vlan all các VLAN qua trunk AL1(config-if)#exit AL1(config)# 4. Áp đặt các port chỉ định vào VLAN tương ứng AL1(config)#int f0/4 AL1(config-if)#switchport mode access AL1(config-if)#switchport access vlan 10 AL1(config-if)#int f0/5 AL1(config-if)#switchport mode access AL1(config-if)#switchport access vlan 10 AL1(config-if)#int f0/6 AL1(config-if)#switchport mode access AL1(config-if)#switchport access vlan 10 AL1(config)#int f0/7 AL1(config-if)#switchport mode access AL1(config-if)#switchport access vlan 20 AL1(config-if)#int f0/8 AL1(config-if)#switchport mode access AL1(config-if)#switchport access vlan 20 AL1(config-if)#int f0/9 AL1(config-if)#switchport mode access AL1(config-if)#switchport access vlan 20 AL1(config)#int f0/10 AL1(config-if)#switchport mode access AL1(config-if)#switchport access vlan 30 AL1(config-if)#int f0/11 AL1(config-if)#switchport mode access AL1(config-if)#switchport access vlan 30 AL1(config-if)#int f0/12 AL1(config-if)#switchport mode access AL1(config-if)#switchport access vlan 30 5. Xem cấu hình vừa thực hiện AL1#sh vlan VLAN Name Status Ports ---- -------------------------------- --------- --------------------------- 1 default active Fa0/2, Fa0/3 10 SALES active Fa0/4, Fa0/5, Fa0/6 20 ACCOUNTING active Fa0/7, Fa0/8, Fa0/9 30 ENGINEERING active Fa0/10, Fa0/11, Fa0/12 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default active 1005 trnet-default active VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2 ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------ 1 enet 100001 1500 - - - - - 0 0 10 enet 100010 1500 - - - - - 0 0 20 enet 100020 1500 - - - - - 0 0 30 enet 100030 1500 - - - - - 0 0 1002 fddi 101002 1500 - 0 - - - 0 0 1003 tr 101003 1500 - 0 - - srb 0 0

Page 40: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 40

1004 fdnet 101004 1500 - - - ieee - 0 0 1005 trnet 101005 1500 - - - ibm - 0 0 AL1# Kiểm tra 1. Kiểm tra cổng Fa0/1 đã hoạt động chưa AL1#show int fa0/1

Cổng đã hoạt độngFastEthernet0/1 is up, line protocol is up Hardware is Fast Ethernet, address is 00b0.64c9.cd41 (bia 00b0.64c9.cd41) MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation ARPA, loopback not set Keepalive not set Auto-duplex (Full), Auto Speed (100), 100BaseTX/FX ARP type: ARPA, ARP Timeout 04:00:00 ... 2. Kiểm tra cổng Fa0/1 đã kích hoạt trunking và đúng kiểu encapsulation chưa AL1#sh int fa0/1 switchport Name: Fa0/1 Switchport: Enabled Administrative mode: trunk

Cổng F0/1Operational Mode: trunk hoạt động ở chế độ trunk mode Administrative Trunking Encapsulation: isl

Kiểu đóng gói làOperational Trunking Encapsulation: isl isl Negotiation of Trunking: Disabled Access Mode VLAN: 0 ((Inactive)) Trunking Native Mode VLAN: 1 (default)

Trunking VLANs Cho phép tất cả các VLAN qua kết nối trunkEnabled: ALL

Trunking Các VLAN hiện hành đang hoạt độngVLANs Active: 1,10,20,30 Pruning VLANs Enabled: 2-1001 Priority for untagged frames: 0 Override vlan tag priority: FALSE Voice VLAN: none Appliance trust: none AL1# 3. Kiểm tra revision number trên client có đồng bộ với server chưa AL1#sh vtp status VTP Version : 2

Configuration Revision số revision number: 2 Maximum VLANs supported locally : 68 Number of existing VLANs : 8

Switch hoạt động ở chếVTP Operating Mode : Client độ client

Switch thuộc domain DHCNVTP Domain Name : DHCN VTP Pruning Mode : Disabled VTP V2 Mode : Disabled VTP Traps Generation : Disabled MD5 digest : 0xDC 0x45 0xB2 0xD9 0x5B 0x7A 0x50 0x19 Configuration last modified by 192.168.1.2 at 3-1-93 01:54:06 AL1# DL1#sh vtp status VTP Version : 2 Configuration Revision : 2 Maximum VLANs supported locally : 1005 Number of existing VLANs : 8

Page 41: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 41

VTP Operating Mode : Server VTP Domain Name : DHCN VTP Pruning Mode : Disabled VTP V2 Mode : Disabled VTP Traps Generation : Disabled MD5 digest : 0xDC 0x45 0xB2 0xD9 0x5B 0x7A 0x50 0x19 Configuration last modified by 192.168.1.2 at 3-1-93 01:54:06 Local updater ID is 192.168.1.2 on interface Vl1 (lowest numbered VLAN interface found) DL1#

+ Revision number là một trong những thông số quan trọng của VTP. Mỗi khi VTP server thay đổi VLAN database thì sẽ tăng giá trị revision lên 1 và thực hiện quảng cáo VLAN database này. Các thiết bị có số revision nhỏ hơn phải chấp nhận VLAN database có số revision lớn hơn. Nếu VTP server xoá bỏ tất cả các VLAN & có số revision cao nhất thì các thiết bị khác cũng sẽ bị xoá VLAN. 4. Kiểm tra số lần gửi và nhận thông tin trunking DL1#sh vtp counters VTP statistics: Summary advertisements received : 18 Subset advertisements received : 5 Request advertisements received : 1 Summary advertisements transmitted : 12 Subset advertisements transmitted : 2 Request advertisements transmitted : 0 Number of config revision errors : 0 Number of config digest errors : 0 Number of V1 summary errors : 0 VTP pruning statistics: Trunk Join Transmitted Join Received Summary advts received from non-pruning-capable device ---------------- ---------------- ---------------- --------------------------- Fa0/1 0 0 0 DL1# AL1#sh vtp counters VTP statistics: Summary advertisements received : 13 Subset advertisements received : 2 Request advertisements received : 0 Summary advertisements transmitted : 20 Subset advertisements transmitted : 6 Request advertisements transmitted : 1 Number of config revision errors : 0 Number of config digest errors : 0 Number of V1 summary errors : 0 VTP pruning statistics: Trunk Join Transmitted Join Received Summary advts received from non-pruning-capable device

Page 42: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 42

Lab 2-4: Định tuyến giữa các VLAN

Mục đích

Các Vlan có thể nhìn thấy nhau với mỗi VLAN có một lớp địa chỉ IP khác nhau

Dùng lệnh Ping để kiểm tra trên các máy

Cách làm

- Cấu hình VLAN - Cấu hình Access Port - Cấu hình trunking - Cấu hình Routing - Cấu hình IP, subnet mask, default gate way tren may tính

Cấu hình đầy đủ (tham khảo) dùng lệnh show running config trên các thiết bị 2900XL switch ! hostname 2900xl ! interface FastEthernet0/1 switchport mode trunk

Page 43: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 43

! !-- Nếu bạn cấu hình trunking theo chuẩn 802.1q thì phải cấu hình trên cổng giao tiếp Fa0/1 là: !-- interface FastEthernet0/1 !-- switchport trunk encapsulation dot1q !-- switchport mode trunk ! interface FastEthernet0/2 switchport access vlan 1 ! interface FastEthernet0/3 switchport access vlan 10 !

interface FastEthernet0/4 switchport access vlan 20 ! interface FastEthernet0/5 switchport access vlan 30 ! interface VLAN1 ip address 10.10.10.2 255.255.255.0

interface VLAN10 ip address 10.10.11.2 255.255.255.0

interface VLAN20 ip address 10.10.12.2 255.255.255.0

! interface VLAN30 ip address 10.10.13.2 255.255.255.0 no ip directed-broadcast no ip route-cache ! ip default-gateway 10.10.10.1 ! end Router 1800 Series:

Page 44: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 44

! hostname c2600 ! no logging console enable password mysecret ! ip subnet-zero ! interface FastEthernet0/0 no ip address duplex auto speed auto ! interface FastEthernet0/0.1 encapsulation dot1Q 1 native ip address 10.10.10.1 255.255.255.0 ! interface FastEthernet0/0.10 encapsulation dot1Q 10 ip address 10.10.11.1 255.255.255.0 !

interface FastEthernet0/0.20 encapsulation dot1Q 20 ip address 10.10.12.1 255.255.255.0 ! interface FastEthernet0/0.30 encapsulation dot1Q 30 ip address 10.10.13.1 255.255.255.0 ! end

Page 45: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 45

Lab 2.5: VLAN & ROUTING

Mục đích: Sao cho các máy thuộc các VLAN khác nhau với các lớp địa chỉ mạng

khác nhau có thể nhìn thấy nhau

Hướng dẫn:

1. Cấu hình VLAN

2. Cấu Hình Access port tương ứng với các máy tinh nối vào Switch như hình

vẽ

3. Cấu hình trunking giữa các switch với nhau, giữa switch với router

4. Cấu hình VTP trên các switch

5. Cấu hình sub interface trên router để routing giữa các Vlan

6. Cấu hình địa chỉ IP, SubNet Mask, default gate way trên các máy tính tương

ứng với các VLAN

7. Dùng lệnh Ping để kiểm tra sự kết nối giữa các máy tính

8. Cấu hình Consol port trên router với máy tính để quản trị các thiết bị

Page 46: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 46

PHẦN III: ROUTING

Lab 3-1: Định tuyến trên router Cisco

Định tuyến IP được cho phép mặc định trên Cisco router. Lệnh để cho phép hay vô hiệu hoá định tuyến: [no] ip routing Vì lệnh này mặc định nên khi xem cấu hình đang chạy bằng lệnh show running–config sẽ không thấy hiển thị lệnh này. Để kiểm tra tác động của câu lệnh cho router nối với PC1 và PC2 qua hai cổng Ethernet 0 và Ethernet 1 như hình vẽ. –Router A với 2 cổng Ethernet sẽ được cấu hình như sau: RouterA(config)#interface Ethernet0/0 RouterA(config–if)#ip address 172.108.1.1 255.255.255.0 RouterA(config–if)#no shutdown RouterA(config–if)#exit RouterA(config)#interface Ethernet0/1 RouterA(config–if)#ip address 172.108.2.1 255.255.255.0 RouterA(config–if)#no shutdown RouterA(config–if)#exit RouterA(config)#ip routing ← lệnh này mặc định trên Cisco router RouterA(config)# Ctrl+z RouterA# – Đặt địa chỉ IP cho PC1 và PC2 cùng mạng với cổng Ethernet0 và Ethernet1, như trên hình. Lưu ý. Win 2000, XP: Start – Settings – Connection – Local Area Connection – Properties – Internet Protocol (TCP/IP) Win98: Start – Settings – Control Panel – Networks – TCP/IP – TCP/IP Properties

Page 47: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 47

–Thực hiện lệnh ping trên PC1 và PC2, lệnh ping phải thành công: Gói IP từ PC1 tới PC2 sẽ được định tuyến bởi R1 mà không cần giao thức định tuyến vì các mạng được kết nối trực tiếp với RouterA. Win 2000, XP: Start – Run: cmd.exe Win98: Start – Run: command.exe Tại PC1 Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\> ping 172.108.2.2 Pinging 172.108.2.2 with 32 bytes of data: Reply from 172.108.2.2: bytes=32 time<1ms TTL=127 Reply from 172.108.2.2: bytes=32 time<1ms TTL=127 Reply from 172.108.2.2: bytes=32 time<1ms TTL=127 Reply from 172.108.2.2: bytes=32 time<1ms TTL=127 Ping statistics for 172.108.2.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms C:\>_ Tại PC2 Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\> ping 172.108.1.2 Pinging 172.108.2.2 with 32 bytes of data: Reply from 172.108.1.2: bytes=32 time<1ms TTL=127 Reply from 172.108.1.2: bytes=32 time<1ms TTL=127 Reply from 172.108.1.2: bytes=32 time<1ms TTL=127 Reply from 172.108.1.2: bytes=32 time<1ms TTL=127 Ping statistics for 172.108.1.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 0ms, Average = 0ms

Page 48: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 48

–Xem bảng định tuyến RouterA bằng lệnh show ip route. Chữ C ở phía trái bảng định tuyến tượng trưng cho các mạng nối trực tiếp. RouterA#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, * - candidate default U - per-user static route, o - ODR Gateway of last resort is not set 172.100.0.0 is subnetted, 2 subnets C 172.108.1.0 is directly connected, Ethernet0 C 172.108.2.0 is directly connected, Ethernet1

Page 49: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 49

Lab 3-2: Cấu hình định tuyến tĩnh

Mô tả & yêu cầu –Cấu hình static route trên các router A, router B và router C. –RouterC hoạt động như DCE router, RouterA là DTE router. –Từ các router, ta phải có thể ping được tất cả các địa chỉ trong mạng Cấu hình RouterA ! hostname RouterA no ip domain-lookup ! interface s0 ip address 10.0.3.2 255.255.255.0 no shutdown ! interface E0 ip address 10.0.2.2 255.255.255.0 no shutdown ! end RouterA ! hostname RouterB no ip domain-lookup ! interface E0 ip address 10.0.2.1 255.255.255.0 no shutdown !

Page 50: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 50

ip route 10.0.3.0 255.255.255.0 e0 ! end RouterC ! hostname RouterC no ip domain-lookup ! interface s0 ip address 10.0.3.100 255.255.255.0 no shutdown ! ip route 10.0.2.0 255.255.255.0 10.0.3.2 ! end Các bước thực hiện Bước 1: Cấu hình RouterA RouterA(config)#hostname RouterA RouterA(config)#no ip domain-lookup RouterA(config)#interface s0 RouterA(config-if)#ip address 10.0.3.2 255.255.255.0 RouterA(config-if)#no shutdown - Khi thực hiện lệnh no shutdown, sẽ hiện dòng thông báo 01:31:19: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up RouterA(config-if)#interface E0 RouterA(config-if)#ip address 10.0.2.2 255.255.255.0 RouterA(config-if)#no shutdown 01:34:38: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up RouterA(config-if)#end 01:35:39: %SYS-5-CONFIG_I: Configured from console by console RouterA# Bước 2: Cấu hình RouterB RouterB(config)#hostname RouterB RouterB(config)#no ip domain-lookup RouterB(config-if)#interface e0 RouterB(config-if)#ip address 10.0.2.1 255.255.255.0

Page 51: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 51

RouterB(config-if)#no shut 01:44:38: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up RouterB(config-if)#end 01:45:39: %SYS-5-CONFIG_I: Configured from console by console RouterB# Bước 3: Cấu hình cơ bản router RouterC RouterC(config)#hostname RouterC RouterC(config)#no ip domain-lookup RouterC(config)#interface s0 RouterC(config-if)#ip address 10.0.3.100 255.255.255.0 RouterC(config-if)#no shutdown 01:51:19: %LINK-3-UPDOWN: Interface Serial0/0, changed state to up RouterC(config-if)#end 01:51:39: %SYS-5-CONFIG_I: Configured from console by console RouterC# Bước 4: Kiểm tra kết nối giữa các router RouterA, RouterC và RouterB RouterC#ping 10.0.3.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.0.3.2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms - Nếu không ping được, kiểm tra lại cấu hình bằng lệnh show running-config, show interface để đảm bảo cấu hình đúng, giải quyết sự cố nếu cần. RouterB#ping 10.0.2.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.0.2.2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms RouterB#ping 10.0.2.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.0.2.1, timeout is 2 seconds: !!!!!

Page 52: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 52

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms RouterA#ping 10.0.3.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.0.3.100, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms RouterC#ping 10.0.2.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.0.2.1, timeout is 2 seconds: ..... Success rate is 0 percent (0/5) RouterB#ping 10.0.3.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.0.3.100, timeout is 2 seconds: ..... Success rate is 0 percent (0/5) –Trên router RouterC, xem bảng định tuyến bằng lệnh show ip route RouterC#show ip route Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set 10.0.0.0/24 is subnetted, 1 subnets C 10.0.3.0 is directly connected, Serial0/0

Page 53: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 53

Bước 5: Cấu hình Static Routes –Tại router RouterC, cấu hình static route đến router RouterB: RouterC(config)#ip route 10.0.2.0 255.255.255.0 10.0.3.2 RouterC(config)#exit 02:06:37: %SYS-5-CONFIG_I: Configured from console by console + Khi cấu hình next hop router là địa chỉ IP thì AD = 0; ta cấu hình next hop router sử dụng outgoing interface thì AD = 1. –Tại router RouterB, định tuyến static route đến router RouterC: RouterB(config)#ip route 10.0.3.0 255.255.255.0 e0 RouterB(config)#exit 02:06:37: %SYS-5-CONFIG_I: Configured from console by console –Tại router RouterC, ping router RouterB bằng lệnh ping 10.0.2.1 RouterC#ping 10.0.2.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.0.2.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms –Tại router RouterB, ping router RouterC bằng lệnh ping 10.0.3.100 RouterB#ping 10.0.3.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.0.3.100, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/4/8 ms –Xem bảng định tuyến trên router RouterC bằng lệnh show ip route: RouterC#show ip route ... Gateway of last resort is not set 10.0.0.0/24 is subnetted, 2 subnets S 10.0.2.0 [1/0] via 10.0.3.2

Page 54: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 54

C 10.0.3.0 is directly connected, Serial0/0 Chú ý: S biểu thị cho kết nối static với AD = 1 và hop count là 0 [1/0] –Xem bảng định tuyến trên router RouterB: RouterB#show ip route ... Gateway of last resort is not set 10.0.0.0/24 is subnetted, 2 subnets C 10.0.2.0 is directly connected, FastEthernet0/1 S 10.0.3.0 is directly connected, FastEthernet0/1 Chú ý AD = 0 khi ta chọn outgoing interface để cấu hình static route. Ở đây ta không thấy entry [1/0] trong cấu hình.

Lab 3.3: Định tuyến tĩnh

Cấu hình hệ thống theo sơ đồ trên dùng định tuyến tĩnh sao cho các máy có thể Ping thấy nhau

Page 55: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 55

Lab 3-4: Giao thức định tuyến RIP

Mô tả & yêu cầu –Router A, B, C sử dụng RIP để quảng cáo thông tin định tuyến –Router B hoạt động như DCE cung cấp xung clock cho router A và C –Các router cấu hình RIP và quảng cáo tất cả các mạng nối trực tiếp. –Từ router A, B và C, ta ping được hết các địa chỉ trong mạng. Cấu hình Router A ! hostname Router A no ip domain-lookup ! interface Loopback0 ← Định nghĩa interface ảo để làm điểm kiểm tra ip address 10.1.1.1 255.255.255.0 ! interface Ethernet0 ip address 148.1.1.1 255.255.255.0 no shutdown no keepalive ← cho phép cổng Ethernet vẫn up khi không kết nối với bên ngoài ! interface Serial0 ip address 192.1.1.1 255.255.255.0 no shutdown ! router rip ← kích hoạt quá trình định tuyến RIP trên router network 10.0.0.0 ← chỉ ra mạng sẽ quảng cáo và xác

Page 56: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 56

định interface nào sẽ gởi và nhận thông tin định tuyến RIP network 148.1.0.0 network 192.1.1.0 ! no ip classless ! end Router B ! hostname RouterB no ip domain-lookup ! interface Serial0 ip address 192.1.1.2 255.255.255.0 clock rate 64000 ← hoạt động như DCE cung cấp xung clock no shutdown ! interface Serial1 ip address 193.1.1.1 255.255.255.0 clock rate 64000 ← hoạt động như DCE cung cấp xung clock no shutdown ! router rip network 192.1.1.0 network 193.1.1.0 ! end + Để xác định router nào cung cấp xung clock tức là thiết bị DCE dùng câu lệnh: show controller [type number] Router C ! hostname RouterC no ip domain-lookup ! interface Ethernet0 ip address 152.1.1.1 255.255.255.0 no shutdown no keepalive ← vô hiệu hóa keepalive trên router cho phép interface ethernet0 vẫn up khi không kết nối ra bên ngoài !

Page 57: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 57

interface Serial0 ip address 193.1.1.2 255.255.255.0 no shutdown ! router rip network 152.1.0.0 network 193.1.1.0 ! no ip classless ! end Các bước thực hiện Đặt hostname, đặt địa chỉ IP cho các cổng Loopback, Serial, Ethernet Đối với RouterA Router>en Router#config terminal Router(config)#hostname RouterA RouterA(config)#interface Loopback RouterA(config–if)# ip address 10.1.1.1 255.255.255.0 RouterA(config–if)#exit RouterA(config)#interface Ethernet0 RouterA(config–if)#ip address 148.1.1.1 255.255.255.0 RouterA(config–if)#no shutdown RouterA(config–if)#no keepalive RouterA(config–if)#exit RouterA(config)#interface Serial0 RouterA(config–if)#ip address 192.1.1.1 255.255.255.0 RouterA(config–if)#no shutdown RouterA(config–if)#end RouterA# Cấu hình tương tự đối với RouterB và RouterC. Lưu ý tại RouterB có lệnh clock rate khi cấu hình cổng Serial. RouterB(config)#interface Serial0 RouterB(config–if)#ip address 192.1.1.2 255.255.255.0 RouterB(config–if)#clock rate 64000 RouterB(config–if)#no shutdown RouterB(config–if)#interface Serial1 RouterB(config–if)#ip address 193.1.1.1 255.255.255.0 RouterB(config–if)#clock rate 64000

Page 58: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 58

RouterB(config–if)#no shutdown RouterB(config–if)#end RouterB# Kiểm tra hoạt động cổng Serial tại các router bằng lệnh show interface [Type Number] RouterA#show interface Serial0 Serial0 is up, line protocol is up Hardware is HD64570 Internet address is 192.1.1.1/24 MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation HDLC, loopback not set Keepalive set (10 sec) Last input 00:00:06, output 00:00:08, output hang never Last clearing of "show interface" counters never Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0 Queueing strategy: weighted fair Output queue: 0/1000/64/0 (size/max total/threshold/drops) Conversations 0/3/256 (active/max active/max total) Reserved Conversations 0/0 (allocated/max allocated) 5 minute input rate 0 bits/sec, 0 packets/sec 5 minute output rate 0 bits/sec, 0 packets/sec 489 packets input, 30563 bytes, 0 no buffer Received 473 broadcasts, 0 runts, 0 giants, 0 throttles 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort 524 packets output, 33973 bytes, 0 underruns 0 output errors, 0 collisions, 26 interface resets 0 output buffer failures, 0 output buffers swapped out 15 carrier transitions --More—- RouterB#sh int s0 Serial0 is up, line protocol is up Hardware is HD64570 Internet address is 192.1.1.2/24 MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation HDLC, loopback not set ... RouterB#show interface serial1

Page 59: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 59

Serial1 is up, line protocol is up Hardware is HD64570 Internet address is 193.1.1.1/24 MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation HDLC, loopback not set ... RouterC#show interface Serial0 Serial0 is up, line protocol is up Hardware is HD64570 Internet address is 193.1.1.2/24 MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation HDLC, loopback not set ... Chạy giao thức định tuyến RIP trên mỗi router RouterA(config)#router rip RouterA(config–router)#network 10.0.0.0 RouterA(config–router)#network 148.1.0.0 RouterA(config–router)#network 192.1.1.0 RouterB(config)#router rip RouterB(config–router)#network 192.1.1.0 RouterB(config–router)#network 193.1.1.0 RouterC(config)#router rip RouterC(config–router)#network 152.1.0.0 RouterC(config–router)#network 193.1.1.0 Kiểm tra Xem bảng định tuyến bằng lệnh show ip route RouterA# show ip route ... Gateway of last resort is not set 10.0.0.0 is subnetted, 1 subnets C 10.1.1.0 is directly connected, Loopback0 148.1.0.0/24 is subnetted, 1 subnets C 148.1.1.0 is directly connected, Ethernet0 R 152.1.0.0/16 [120/2] via 192.1.1.2, 00:00:20, Serial0 C 192.1.1.0/24 is directly connected, Serial0 R 193.1.1.0/24 [120/1] via 192.1.1.2, 00:00:20, Serial0

Page 60: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 60

+ Dùng lệnh show ip route rip nếu chỉ muốn xem các route học từ RIP. RouterA# show ip route rip R 152.1.0.0/16 [120/2] via 192.1.1.2, 00:00:20, Serial0 R 193.1.1.0/24 [120/1] via 192.1.1.2, 00:00:20, Serial0 Từ router ping các địa chỉ trên mạng RouterC#ping 192.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.1.1.1 timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/4 ms RouterC#ping 192.1.1.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.1.1.2 timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/4 ms RouterA#ping 148.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 148.1.1.1 timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/4 ms RouterC#ping 10.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 10.1.1.1 timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/4 ms Ta có thể xem quá trình cập nhật định tuyến của RIP bằng cách dùng lệnh debug ip rip. Chú ý tại cổng serial0, RouterA không quảng cáo network học từ RouterB (152.1.0.0 và 193.1.1.0) nhưng ở các router còn lại các network này được quảng cáo. Đây là hoạt động của cơ chế split horizon: khi split horizone hoạt động, router sẽ không quảng cáo route ngược trở lại nơi nó đến.

Page 61: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 61

RouterA#debug ip rip RIP: sending v1 update to 255.255.255.255 via Ethernet0 (148.1.1.1) network 10.0.0.0, metric 1 network 152.1.0.0, metric 3 network 192.1.1.0, metric 1 network 193.1.1.0, metric 2 RIP: sending v1 update to 255.255.255.255 via Loopback0 (10.1.1.1) network 148.1.0.0, metric 1 network 152.1.0.0, metric 3 network 192.1.1.0, metric 1 network 193.1.1.0, metric 2 RIP: sending v1 update to 255.255.255.255 via Serial0 (192.1.1.1) network 10.0.0.0, metric 1 network 148.1.0.0, metric 1 Khi debug chạy, router sẽ đưa ra thông tin định tuyến RIP, để ngừng debug dùng lệnh: RouterA#undebug all Vô hiệu hoá split horizon tại RouterA dùng lệnh tại interface mode RouterA(config)#int s0 RouterA(config–if)#no ip split–horizon Lúc này, để kiểm tra thông tin định tuyến tại RouterA dùng lệnh debug ip rip. Thông tin xuất hiện dưới đây (chú ý tất cả các route được quảng cáo ra cổng serial , bao gồm cả các route học từ RouterB và RouterC): RouterA#debug ip rip RIP: sending v1 update to 255.255.255.255 via Ethernet0 (148.1.1.1) network 10.0.0.0, metric 1 network 152.1.0.0, metric 3 network 192.1.1.0, metric 1 network 193.1.1.0, metric 2 RIP: sending v1 update to 255.255.255.255 via Loopback0 (10.1.1.1) network 148.1.0.0, metric 1 network 152.1.0.0, metric 3 network 192.1.1.0, metric 1 network 193.1.1.0, metric 2 RIP: sending v1 update to 255.255.255.255 via Serial0

Page 62: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 62

(192.1.1.1) network 10.0.0.0, metric 1 network 148.1.0.0, metric 1 network 152.1.0.0, metric 3 network 192.1.1.0, metric 1 network 193.1.1.0, metric 2

Page 63: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 63

Lab 3-5: Giao thức định tuyến RIP

Mô tả & yêu cầu –Lab này cấu hình định tuyến IP dùng địa chỉ mạng lớp B (131.108.0.0/16), với subnet mask lớp C (255.255.255.0 hay /24). –Cấu hình giao thức định tuyến RIP trên R1 và R2 để từ router ping được tất cả địa chỉ trên mạng. Cấu hình R1 ! hostname R1 ! interface loopback0 ip address 192.168.4.1 255.255.255.0 exit ! interface loopback1 ip address 192.168.5.1 255.255.255.0 exit ! interface loopback2 ip address 192.168.6.1 255.255.255.0 exit ! interface Ethernet0 ip address 192.168.1.1 255.255.255.0 no shutdown no keepalive exit ! interface Serial0

Page 64: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 64

ip address 192.168.3.1 255.255.255.0 clock rate 64000 no shut exit ! router rip network 192.168.0.0 ! end R2 ! hostname R2 ! interface loopback0 ip address 192.168.7.1 255.255.255.0 exit ! interface loopback1 ip address 192.168.8.1 255.255.255.0 exit ! interface loopback2 ip address 192.168.9.1 255.255.255.0 exit ! interface Ethernet0 ip address 192.168.2.1 255.255.255.0 no shutdown no keepalive exit ! interface Serial0 ip address 192.168.3.2 255.255.255.0 no shut exit ! router rip network 192.168.0.0 ! end Các bước thực hiện như sau 1. Đặt hostname, cấu hình cho các cổng loopback, Ethernet và Serial trên R1 và R2.

Page 65: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 65

Đặt hostname Router(config)#hostname R1 R1(config)# _ Router(config)#hostname R2 R2(config)# _ Xác định thiết bị nào là DCE và DTE: R1#show controllers S0 Interface Serial0 Hardware is PowerQuiCC MPC860 DCE V.35, no clock ... R2#show controllers S1 HD unit 0, idb = 0xFBDB0, driver structure at 0x1020C8 buffer size 1524 HD unit 0, V.35 DTE cable cpb = 0x1, eda = 0x483C, cda = 0x4850 ... Cấu hình địa chỉ IP cho các cổng của R1 R1(config)#interface loopback0 R1(conig–if)# ip address 192.168.4.1 255.255.255.0 R1(config–if)#interface loopback1 R1(conig–if)# ip address 192.168.5.1 255.255.255.0 R1(config–if)#interface loopback2 R1(conig–if)# ip address 192.168.6.1 255.255.255.0 R1(conig–if)# exit R1(config)#interface Ethernet0 R1(conig–if)#ip address 192.168.1.1 255.255.255.0 R1(conig–if)#no shutdown %LINK-3-UPDOWN: Interface Ethernet0, changed state to up %LINK-5-UPDOWN: Line protocol on Interface Ethernet0, changed state to up R1(conig–if)#no keepalive R1(conig–if)# exit R1(config)#interface Serial0 R1(conig–if)#ip address 192.168.3.1 255.255.255.0 R1(conig–if)#clock rate 128000 R1(conig–if)#no shut

Page 66: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 66

Tương tự đối với R2 R2(config)#interface loopback0 R2(conig–if)# ip address 192.168.7.1 255.255.255.0 R2(config)#interface loopback1 R2(conig–if)# ip address 192.168.8.1 255.255.255.0 R2(config)#interface loopback2 R2(conig–if)# ip address 192.168.9.1 255.255.255.0 R2(config)#interface Ethernet0 R2(conig–if)#ip address 192.168.2.1 255.255.255.0 R2(conig–if)#no shutdown R2(conig–if)#no keepalive R2(conig–if)# exit R2(config)#interface Serial1 R2(conig–if)#ip address 192.168.3.2 255.255.255.0 R2(conig–if)#no shut 2. Kiểm tra bảng định tuyến IP trên các router R1# show ip route ... Gateway of last resort is not set 192.168.0.0/24 is subnetted, 5 subnets C 192.168.6.0 is directly connected, Loopback2 C 192.168.5.0 is directly connected, Loopback1 C 192.168.4.0 is directly connected, Loopback0 C 192.168.3.0 is directly connected, Serial0 C 192.168.1.0 is directly connected, Ethernet0 R2# show ip route ... Gateway of last resort is not set 192.168.0.0/24 is subnetted, 5 subnets C 192.168.9.0 is directly connected, Loopback2 C 192.168.8.0 is directly connected, Loopback1 C 192.168.7.0 is directly connected, Loopback0 C 192.168.3.0 is directly connected, Serial1 C 192.168.2.0 is directly connected, Ethernet0 3. Chạy giao thức định tuyến RIP trên cả hai router

Page 67: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 67

R1(config)#router rip R1(config–router)#network 192.168.0.0 R1(config–router)#end R1#copy run start ← lưu cấu hình vào NVRAM R2(config)#router rip R2(config–router)network 192.168.0.0 R2(config–router)#end R2#copy run start Xem quá trình cập nhật định tuyến trên router R1#debug ip rip RIP protocol debugging is on R1#debug ip rip events RIP event debugging is on 4. Xem lại bảng định tuyến trên R1 và R2 R1# show ip route ... Gateway of last resort is not set 192.168.0.0/24 is subnetted, 5 subnets R 192.168.9.0/24 [120/1] via 192.168.3.2, 00:00:00, Serial0 R 192.168.8.0/24 [120/1] via 192.168.3.2, 00:00:00, Serial0 R 192.168.7.0/24 [120/1] via 192.168.3.2, 00:00:00, Serial0 C 192.168.6.0 is directly connected, Loopback2 C 192.168.5.0 is directly connected, Loopback1 C 192.168.4.0 is directly connected, Loopback0 C 192.168.3.0 is directly connected, Serial0 R 192.168.2.0/24 [120/1] via 192.168.3.2, 00:00:00, Serial0 C 192.168.1.0 is directly connected, Ethernet0 R2# show ip route ... Gateway of last resort is not set 192.168.0.0/24 is subnetted, 5 subnets C 192.168.9.0 is directly connected, Loopback2 C 192.168.8.0 is directly connected, Loopback1 C 192.168.7.0 is directly connected, Loopback0 R 192.168.6.0/24 [120/1] via 192.168.3.1, 00:00:00, Serial1 R 192.168.5.0/24 [120/1] via 192.168.3.1, 00:00:00, Serial1 R 192.168.4.0/24 [120/1] via 192.168.3.1, 00:00:00, Serial1

Page 68: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 68

C 192.168.3.0 is directly connected, Serial1 C 192.168.2.0 is directly connected, Ethernet0 R 192.168.1.0/24 [120/1] via 192.168.3.1, 00:00:00, Serial1 5. Kiểm tra hoạt động bằng ping các mạng ơ xa (tất cả các lệnh ping phải thành công) R1#ping 192.168.9.1 R1#ping 192.168.8.1 R1#ping 192.168.7.1 R1#ping 192.168.2.1 R2#ping 192.168.4.1 R2#ping 192.168.5.1 R2#ping 192.168.6.1 R2#ping 192.168.1.1 Ví dụ ping thành công R1#ping 192.168.9.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.9.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 32/32/32 ms

Page 69: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 69

Lab 3.6: Dùng RIP version 2

Cấu hình hệ thống theo sơ đồ trên dùng định tuyến RIP version 2 sao cho các máy có thể Ping

thấy nhau

Page 70: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 70

Lab 3-7: Cấu hình EIGRP cơ bản

Mô tả –Router R1, R2 sử dụng EIGRP để quảng cáo thông tin định tuyến –Router R1 hoạt động như DCE cung cấp xung clock cho router R2 –Từ router R1, R2 ping được hết các địa chỉ trong mạng. - Mặc định, EIGRP cho phép summarization nên bạn cần sử dụng lệnh no auto-summarization để không cho phép tự động thực hiện summarization. - EIGRP hỗ trợ VLSM. Chú ý rằng mạng ethernet trên R1 và R2 sử dụng khoảng địa chỉ khác nhau là 192.168.1.0/25 và 192.168.1.128/25. - Metric của EIGRP bằng metric của IGRP nhân với 256. Cấu hình Router R1 hostname R1 ! enable mật khẩu cisco ! ip subnet-zero no ip domain-lookup ! interface Loopback0 ip address 199.100.4.1 255.255.255.0 ! interface Loopback1 ip address 199.100.5.1 255.255.255.0 ! interface Loopback2

Page 71: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 71

ip address 199.100.6.1 255.255.255.0 ! interface Ethernet0 ip address 192.168.1.1 255.255.255.128 ! interface Serial0 ip address 199.100.3.1 255.255.255.0 clock rate 64000 ! router eigrp 234 network 131.108.0.0 network 199.100.3.0 network 199.100.4.0 network 199.100.5.0 network 199.100.6.0 no auto-summary ! end Router R2 hostname R2 ! enable mật khẩu cisco ! ip subnet-zero no ip domain-lookup ! interface Loopback0 ip address 199.100.7.1 255.255.255.0 ! interface Loopback1 ip address 199.100.8.1 255.255.255.0 ! interface Loopback2 ip address 199.100.9.1 255.255.255.0 ! interface Ethernet0 ip address 131.108.1.129 255.255.255.128 ! interface Serial0 ip address 199.100.3.2 255.255.255.0 ! router eigrp 234 network 131.108.0.0 network 199.100.3.0 network 199.100.7.0 network 199.100.8.0 network 199.100.9.0

Page 72: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 72

no auto-summary ! end Các bước thực hiện 1. Đặt hostname, cấu hình cho cổng loopback, ethernet và serial trên router R1 Router> en Router# conf t Router(config)# hostname R1 R1(config)# no ip domain-lookup R1(config)# int e0 R1(config-if)# ip addr 131.108.1.1 255.255.255.128 R1(config-if)# no keepalive ← cho phép cổng Ethernet vẫn up khi không kết nối với bên ngoài R1(config-if)# no shut %LINK-3-UPDOWN: Interface Ethernet0, changed state to up %LINK-5-UPDOWN: Line protocol on Interface Ethernet0, changed state to up R1(config-if)# exit R1(config)# int lo0 ← Định nghĩa interface ảo để làm điểm kiểm tra R1(config-if)# ip addr 199.100.4.1 255.255.255.0 R1(config-if)# int lo1 R1(config-if)# ip addr 199.100.5.1 255.255.255.0 R1(config-if)# int lo2 R1(config-if)# ip addr 199.100.6.1 255.255.255.0 R1(config-if)# exit R1(config-if)# int s0 R1(config-if)# ip addr 199.100.3.1 255.255.255.0 R1(config-if)# clock rate 64000 ← hoạt động như DCE cung cấp xung clock R1(config-if)# no shut 2. Đặt hostname, cấu hình cho cổng loopback, ethernet và serial trên router R2 Router(config)# hostname R2 R2(config)# no ip domain-lookup R2(config)#int e0 R2(config-if)# ip addr 131.108.1.129 255.255.255.128 R2(config-if)# no keepalive R2(config-if)# no shut R2(config-if)# int lo0 R2(config-if)# ip addr 199.100.7.1 255.255.255.0

Page 73: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 73

R2(config-if)# int lo1 R2(config-if)# ip addr 199.100.8.1 255.255.255.0 R2(config-if)# int lo2 R2(config-if)# ip addr 199.100.9.1 255.255.255.0 R2(config-if)# int s0 R2(config-if)# ip addr 192.100.3.2 255.255.255.0 R2(config-if)# no shut 3. Cấu hình giao thức định tuyến EIGRP và lưu cấu hình vào NVRAM trên router R1 R1(config)# router eigrp 234 ← kích hoạt quá trình định tuyến EIGRP trên router R1(config-router)# network 131.108.1.0 ← chỉ ra mạng sẽ quảng cáo và xác định cổng nào sẽ gởi và nhận thông tin định tuyến R1(config-router)# network 199.100.4.0 R1(config-router)# network 199.100.5.0 R1(config-router)# network 199.100.6.0 R1(config-router)# network 199.100.3.0 R1(config-router)# end R1# copy run start 4. Cấu hình giao thức định tuyến EIGRP và lưu cấu hình vào NVRAM trên router R2 R2(config)# router eigrp 234 R2(config-router)# network 199.100.7.0 R2(config-router)# network 199.100.8.0 R2(config-router)# network 199.100.9.0 R2(config-router)# network 131.108.1.0 R2(config-router)# network 199.100.3.0 R2(config-rputer)# end R2# copy run start Kiểm tra 1. Dùng lệnh clear ip route * để xoá toàn bộ route từ bảng định tuyến. R1# clear ip route * 2. Xem quá trình gửi nhận thông tin định tuyến IGRP bằng lệnh debug ip eigrp events R1# debug ip igrp events EIGRP event debugging is on

Page 74: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 74

3. Tắt chế độ debug bằng lệnh undebug all. R1# undebug all All possible debugging has been turned off 4. Xem bảng định tuyến eigrp trên R1 và R2 bằng lệnh show ip route eigrp. R1# show ip route eigrp D 199.100.9.0/24 [90/2297856] via 199.100.3.2, 00:00:55, Serial0 D 199.100.8.0/24 [90/2297856] via 199.100.3.2, 00:00:55, Serial0 131.108.0.0/16 is variably subnetted, 2 subnets, 2 masks D 131.108.0.0/16 is a summary, 00:00:55, Null0 D 199.100.7.0/24 [90/2297856] via 199.100.3.2 00:00:55, Serial0 R1# Dựa vào bảng định tuyến, bạn có thể thấy có các route EIGRP học từ next-hop 199.100.3.2 và đi qua cổng S0. Trong các tuyến đường, có 1 tuyến đường đi đến Null0. Chú ý số AD trong trường hợp EIGRP là 90(RIP là 120, IGRP là 100 và OSPF là 110). D có nghĩa loại định tuyến là EIGRP. Metric của EIGRP bằng 256 lần metric của IGRP. Chú ý rằng mặc định EIGRP cho phép tự động thực hiện summarization. Router R1 không thấy mạng 131.108.1.128/25 bởi vì router R1 kết nối trực tiếp với mạng 131.108.1.0/25. Ta thấy tất cả các route đến từ mạng 131.108.0.0/16 đều được gửi đến Null0, nghĩa là tuyến đường đó sẽ bị loại bỏ. 5. Từ router R1, ta thực hiện ping mạng 131.108.1.129/25 R1#ping 131.108.1.129 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 131.108.1.130, timeout is 2 seconds: . . . . . Success rate is 0 percent (0/5) R1# Kết quả là không có hồi đáp do các gói gửi đến null0 sẽ bị loại bỏ. 6. Để giải quyết vấn đề này ta cần thực hiện lệnh no auto-summary để không cho phép router tự động thực hiện summarization. R1(config)#router eigrp 234 R1(config-router)#no auto-summary R2(config)#router eigrp 234 R2(config-router)#no auto-summary

Page 75: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 75

7. Kiểm tra kết quả thực hiện R1# show ip route eigrp D 199.100.9.0/24 [90/2297856] via 199.100.3.2, 00:00:01, Serial0 D 199.100.8.0/24 [90/2297856] via 199.100.3.2, 00:00:01, Serial0 131.108.0.0/16 is variably subnetted, 2 subnets, 2 masks D 131.108.1.128/25 [90/2195456] via 199.100.3.2, 00:00:01, Serial0 D 199.100.7.0/24 [90/2297856] via 199.100.3.2 00:00:01, Serial0 R1# R1#ping 131.108.1.129 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 131.108.1.130, timeout is 2 seconds: ! ! ! ! ! Success rate is 100 percent (5/5), round-trip min/avg/max = 16/16/16 ms R1# Chú ý rằng mạng 131.108.1.128/25 có trong bảng định tuyến. Từ router R1 ta ping thành công cổng Ethernet trên router R2. Để hiểu sâu thêm về vấn đề này, bạn cần tìm hiểu thêm về các chủ đề classful, classless và VLSM.

Lab 3.8: EIGRP

Cấu hình hệ thống theo sơ đồ trên dùng định tuyến EIGRP sao cho các máy có thể Ping thấy

nhau

Page 76: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 76

LAB 3-9: CẤU HÌNH OSPF

Mô tả: – Router R2 sử dụng OSPF để quảng bá thông tin định tuyến – Router R1 hoạt động như DCE cung cấp xung clock cho R2 – Các router cấu hình giao thức định tuyến OSPF để liên lạc giữa các area. – Từ router R1, R2 ping được hết các địa chỉ trong mạng. OSPF dùng giải thuật SPF để tính tóan đường đi. Giải thuật này còn được gọi là giải thuật Dijkstra. Các routing protocol nhóm link state không broadcast tòan bộ thông tin về bảng định tuyến giống như RIP/IGRP và thay vào đó, OSPF sẽ dùng một quá trình để khám phá các láng giềng (neighbor). Các láng giềng cũng có thể được định nghĩa tĩnh. Router láng giềng là các router khác, cũng chạy OSPF, có chung subnet với router hiện hành. Khi các router đã thiết lập quan hệ láng giềng với nhau, các router bắt đầu trao đổi các thông tin về đồ hình (topology) của mạng. Giải thuật SPF sẽ chạy trên các database này để tính ra các đường đi tốt nhất. Trong ospf định nghĩa một số vùng cơ bản sau:

1. Stub Area: đây là vùng sẽ không nhận những routing update từ bên ngoài (Type 5) nhưng vẫn nhận update từ những Area láng giềng (Type 3) 2. Totaly stub Area: đây có thể coi là vùng cực đoan nhất nó không nhận bất cứ routing update nào, và trong bảng routing của nó chỉ có một routing ra ngoai duy nhất là default route. vùng này thích hợp cho những site ở xa có ít network và cần sự giới hạn kết nối ra bên ngoài. 3. NSSA Stub Area: đây là vùng được sử dụng khi kết nối đến ISP hoặc khi có sự redistribute giữa các routing protocol khác nhau. vùng này sẽ nhận các route từ bên ngoài dưới dạng type 7 và sẽ chuyển đổi type 7 này thành type 5 để quảng bá vào các Area khác tại con NNSA ABR. 4. Backbone Area: đây chính là vùng Area 0 và nó connect tới tất cả các area

Page 77: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 77

khác còn lại, nếu một area nào đó muốn nối tới Area0 nhưng không nối trực tiếp được thì lúc đó ta phải tao virtual link cho Area này.

Cấu hình: Router R1

hostname R1 ! enable password cisco ! ip subnet-zero no ip domain-lookup ! interface Loopback0 ip address 131.108.4.1 255.255.255.255 ! interface Loopback1 ip address 131.108.5.1 255.255.255.255 ! interface Loopback2 ip address 131.108.6.1 255.255.255.255 ! interface Ethernet0 ip address 131.108.1.1 255.255.255.0 ! interface Serial0 ip address 131.108.3.1 255.255.255.252 clock rate 64000 ! router ospf 1 network 131.108.1.0 0.0.0.255 area 1 network 131.108.3.1 0.0.0.0 area 0 network 131.108.4.1 0.0.0.0 area 1 network 131.108.5.1 0.0.0.0 area 1 network 131.108.6.1 0.0.0.0 area 1 ! end

Router R2

hostname R2 ! enable password cisco ! ip subnet-zero no ip domain-lookup !

Page 78: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 78

interface Loopback0 ip address 131.108.7.1 255.255.255.255 ! interface Loopback1 ip address 131.108.8.1 255.255.255.255 ! interface Loopback2 ip address 131.108.9.1 255.255.255.255 ! interface Ethernet0 ip address 131.108.2.1 255.255.255.0 ! interface Serial0 ip address 131.108.3.2 255.255.255.252 ! router ospf 2 network 131.108.2.0 0.0.0.255 area 2 network 131.108.3.2 0.0.0.0 area 0 network 131.108.7.1 0.0.0.0 area 2 network 131.108.8.1 0.0.0.0 area 2 network 131.108.9.1 0.0.0.0 area 2 ! end

Các bước thực hiện: 1. Đặt hostname, cấu hình cho interface loopback, ethernet và serial trên Router R1.

Router> en Router# conf t Router(config)# hostname R1 R1(config)# no ip domain-lookup R1(config)# int e0 R1(config-if)# ip addr 131.108.1.1 255.255.255.0 R1(config-if)# no keepalive R1(config-if)# no shut %LINK-3-UPDOWN: Interface Ethernet0, changed state to up %LINK-5-UPDOWN: Line protocol on Interface Ethernet0, changed state to up R1(config-if)# exit R1(config)# int lo0 R1(config-if)# ip addr 131.108.4.1 255.255.255.255 R1(config-if)# int lo1 R1(config-if)# ip addr 131.108.5.1 255.255.255.255 R1(config-if)# int lo2

Page 79: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 79

R1(config-if)# ip addr 131.108.6.1 255.255.255.255 R1(config-if)# exit R1(config-if)# int s0 R1(config-if)# ip addr 131.108.3.1 255.255.255.252 R1(config-if)# clock rate 64000 R1(config-if)# no shut

2. Đặt hostname, cấu hình cho interface loopback, ethernet và serial trên Router R2.

Router> en Router# conf t Router(config)# hostname R2 R2(config)# no ip domain-lookup R2(config)#int e0 R2(config-if)# ip addr 131.108.2.1 255.255.255.0 R1(config-if)# no keepalive R2(config-if)# no shut R2(config-if)# int lo0 R2(config-if)# ip addr 131.108.7.1 255.255.255.255 R2(config-if)# int lo1 R2(config-if)# ip addr 131.108.8.1 255.255.255.255 R2(config-if)# int lo2 R2(config-if)# ip addr 131.108.9.1 255.255.255.255 R2(config-if)# int s0 R2(config-if)# ip addr 131.108.3.2 255.255.255.252 R2(config-if)# no shut

3. Cấu hình giao thức định tuyến OSPF với process number là 1 trên router R1 và lưu cấu hình lên NVRAM.

R1(config)# router ospf 1 R1(config-router)# network 131.108.1.0 0.0.0.255 area 1 R1(config-router)# network 131.108.4.1 0.0.0.0 area 1 R1(config-router)# network 131.108.5.2 0.0.0.0 area 1 R1(config-router)# network 131.108.6.3 0.0.0.0 area 1 R1(config-router)# network 131.108.3.1 0.0.0.0 area 0 R1(config-router)# end R1# copy run start

Chú ý: - Giá trị process chỉ mang ý nghĩa cục bộ trên mỗi router, có thể chạy cùng lúcn

Page 80: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 80

hiều process ospf khác nhau. - Wildcard mask 0.0.0.0 sẽ chỉ chính xác địa chỉ nào được kiểm tra Wildcard mask 0.0.0.255 nghĩa là chỉ 3 octet đầu sẽ bị kiểm tra - Ví dụ network 131.108.1.0 0.0.0.255 nghĩa là sẽ kiểm tra các địa chỉ từ 131.108.1.1 đến 131.108.1.254. 4. Cấu hình giao thức định tuyến OSPF với process number là 2 trên router R2 và lưu cấu hình lên NVRAM.

R2(config)# router ospf 2 R2(config-router)# network 131.108.2.1 0.0.0.255 area 2 R2(config-router)# network 131.108.7.1 0.0.0.0 area 2 R2(config-router)# network 131.108.8.1 0.0.0.0 area 2 R2(config-router)# network 131.108.9.1 0.0.0.0 area 2 R2(config-router)# network 131.108.3.2 0.0.0.0 area 0 R2(config-router)# end R2# copy run start

- Trong ospf có sử dụng ba ID:

o Router ID: Được gửi đi từ các router trong các gói tin hello.Nó có độ dài 32bit.No có giá trị bằng địa chỉ địa chỉ IP lớn nhất được sủ dụng trên router.Nếu trên router có giao diện loopback được cấu hình thì router ID bằng địa chỉ IP của giao diện loopback đó.Trong trường hợp có nhiều giao diện loopback thì nó lấy địa chỉ lớn nhất của giao diện loopback làm router ID.Router ID được sử dụng để phân biệt các router nằm trong cùng một autonmous system.

o Process ID: là tham số cấu hình khi ta đánh lệnh router ospf prcess-id. o Area ID: là tham số để group một nhóm các router vào cùng một area.Các

router này cùng chia sẻ hiểu biết về các đường học được trong miền OSPF. Việc chia thành nhiều area là để tiện việc quản lý đồng thời nó giúp ta giới hạn kích thước của topology database, giả sử nếu ta có duy nhất một vùng với kích thước lớn thì lúc đó ta cũng sẽ có một topology database rất lớn tương ứng khiến cho việc xử lý của router chậm đi.......

Kiểm tra và giải quyết sự cố: –Dùng lệnh clear ip route * để xoá toàn bộ route từ bảng định tuyến.

R1# clear ip route *

–Dùng lệnh clear ip ospf process hoặc reload để kích hoạt lại quá trình định tuyến ospf.

R1#clear ip ospf process

Page 81: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 81

–Xem quá trình gửi nhận thông tin định tuyến OSPF bằng lệnh debug ip ospf events, debug ip ospf packet.

R1#debug ip ospf events OSPF:hello with invalid timers on interface Ethernet0 hello interval received 10 configured 10 net mask received 255.255.255.0 configured 255.255.255.0 dead interval received 40 configured 30 R1# debug ip ospf packet OSPF: rcv. v:2 t:1 l:48 rid:200.0.0.117 aid:0.0.0.0 chk:6AB2 aut:0 auk: R1#debug ip ospf packet OSPF: rcv. v:2 t:1 l:48 rid:200.0.0.116 aid:0.0.0.0 chk:0 aut:2 keyid:1 seq:0x0

–Tắt chế độ debug bằng lệnh undebug all.

R1# undebug all All possible debugging has been turned off

–Xem bảng định tuyến trên R1 bằng lệnh show ip route.

R1# show ip route ... Gateway of last resort is not set 131.108.0.0/16 is variably subnetted, 9 subnets, 3 masks C 131.108.6.1/32 is directly connected, Loopback2 C 131.108.5.1/32 is directly connected, Loopback1 C 131.108.4.1/32 is directly connected, Loopback0 C 131.108.3.0/30 is directly connected, Serial0 O IA 131.108.6.1/32 [110/65] via 131.108.3.2, 00:01:29, Serial0 O IA 131.108.5.1/24 [110/74] via 131.108.3.2, 00:01:29, Serial0 O IA 131.108.4.1/32 [110/65] via 131.108.3.2, 00:01:29, Serial0 C 131.108.1.0/24 is directly connected, Ethernet0 O IA 131.108.4.1/32 [110/65] via 131.108.3.2, 00:01:29, Serial0 R1#

Page 82: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 82

Từ R1, bạn có thể thấy có 4 route OSPF học từ next-hop 131.108.3.2 và đi qua cổng S0. Chú ý số AD trong trường hợp OSPF là 110 (RIP là 120 và IGRP là 100). Ký tự O chỉ ra đây là route loại OSPF, IA chỉ rằng mạng ở xa thuộc area khác. –Dùng lệnh show ip route ospf trên router R2 để xem các route OSPF

R2# show ip route ospf 131.108.0.0/16 is variably subnetted, 9 subnets, 3 masks O IA 131.108.4.3/32 [110/782] via 131.108.3.2, 00:13:09, Serial0 O IA 131.108.1.0/24 [110/791] via 131.108.3.2, 00:12:54, Serial0 O IA 131.108.4.2/32 [110/782] via 131.108.3.2, 00:13:09, Serial0 O IA 131.108.4.1/32 [110/782] via 131.108.3.2, 00:13:09, Serial0 R2#

Lab 3.10. OSPF

Cấu hình hệ thống theo sơ đồ trên dùng định tuyến OSPF sao cho các máy có thể Ping thấy nhau

Page 83: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 83

Lab 4-1: Standard Access-List

Mô tả: – Access–list dùng để giám sát lưu lượng vào hoặc ra trên một cổng. Các điều kiện so sánh dựa vào access-list được

định nghĩa trước, có thể đơn giản (standard access list) hay khá phức tạp (extended access list).

– Lab này mô tả lọc gói dữ liệu sử dụng standard access-list thực hiện cấm tất cả dữ liệu từ PC2 và các PC trong

mạng 200.200.200.0/24 đến tất cả Pc trong mạng 172.16.0.254/16

Cấu hình: Router R2:

!

hostname R2

!

interface Loopback0

ip address 162.16.0.1 255.255.0.0

no ip directed-broadcast

!

interface FastEthernet0/0

ip address 172.16.0.254 255.255.0.0

ip access-group 1 out <- lọc các gói đi ra khỏi cổng F0/0 của router

no ip directed-broadcast

!

interface Serial0/0

ip address 203.162.0.2 255.255.255.0

no ip directed-broadcast

clockrate 64000

!

ip classless

ip route 192.168.0.0 255.255.255.0 203.162.0.1 <- Cấu hình định tuyến tĩnh cho router

ip route 200.200.200.0 255.255.255.0 203.162.0.1

no ip http server

!

access-list 1 deny 192.168.0.2 0.0.0.0 <- Cấm PC2

access-list 1 deny 200.200.200.0 0.0.0.255 <- Cấm tất cả PC trong mạng 200

access-list 1 permit any <- phải có lệnh này vì mặc định cuối access-list sẽ là cấm

tất cả (deny)

!

line con 0

transport input none

line aux 0

line vty 0 4

Page 84: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 84

no login <- cho phép router kg cần mật khẩu

!

end

Router R1:

!

hostname R1

!

no ip domain-lookup

!

interface Loopback0

ip address 200.200.200.1 255.255.255.0

!

interface FastEthernet0/0

ip address 192.168.0.254 255.255.255.0

duplex auto

speed auto

!

interface Serial0/0

ip address 203.162.0.1 255.255.255.0

no fair-queue

!

ip classless

ip route 162.16.0.0 255.255.0.0 203.162.0.2

ip route 172.16.0.0 255.255.0.0 203.162.0.2

no ip http server

!

line con 0

transport input none

line aux 0

line vty 0 4

no login

!

end

Thuật ngữ liên quan:

- Wilcard mask: wilcard mask bit nào trong địa chỉ IP sẽ được bỏ qua khi so sánh với địa chỉ IP khác. <1> trong

wildcard mask có nghĩa bỏ qua vị trí bit đó khi so sánh với địa chỉ IP, và <0> xác định vị trí bit phải giống nhau. Với

Standard access-list, nếu không thêm wildcard mask trong câu lệnh tạo access-list thì 0.0.0.0 ngầm hiểu là wildcard

mask. Với standard access list, nếu không thêm wilcard mark trong câu lệnh tạo access-list thì 0.0.0.0 ngầm hiểu là

wildcard mask.

- Inbound và outbound: Khi áp dụng một access–list trên một cổng, phải xác định access–list phải được dùng cho

luồng dữ liệu vào (inbound) hay ra (outbound). Mặc định access–list áp dụng với luồng dữ liệu outbound.

- Chiều của luồng dữ liệu xác định trên cổng của router. Chẳng hạn, lấy ví dụ hình bên dưới: RouterA muốn loại bỏ

(deny) tất cả luồng dữ liệu từ host 150.1.1.2 tới PCA (152.1.1.2). Có hai nơi có thể áp dụng access–list trên RouterA:

inbound access–list áp dụng trên cổng serial hay outbound access–list áp dụng trên cổng Ethernet. Tốt nhất là áp

dụng access–list trên cổng gần nơi luồng dữ liệu sẽ bị loại bỏ.

Page 85: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 85

Thực hiện: Hai bước để cấu hình access list trên router:

1. Tạo access list tại global config mode:

Tạo access-list trên R2 cấm PC2 và mạng 200.200.200.0/24.

R2(config)# access-list 1 deny 192.168.0.2 0.0.0.0

R2(config)# access-list 1 deny 200.200.200.0 0.0.0.255

R2(config)# access-list 1 permit any

2. Áp access-list vào cổng

–Áp access-list này vào chiều ra của cổng F0/0 trên R2.

–Khi áp access-list vào một cổng, xem như đang trên router. Vì vậy nếu muốn cấm dữ liệu đi ra khỏi cổng, ta dùng

từ khóa out; muốn cấm dữ liệu vào một cổng, ta dùng từ khóa in.

–Vì standard access-list chỉ kiểm tra được địa chỉ nguồn nên phải áp access-list vào cổng gần đích nhất.

R2(config)# cổng f0/0

R2(config-if)# ip access-group 1 out

Kiểm tra: –Dùng extended ping trên R1, lấy địa chỉ nguồn là 200.200.200.1 hoặc

192.168.0.2 lệnh ping sẽ không thành công.

R1#ping

Protocol [ip]:

Target IP address: 172.16.0.3

Repeat count [5]:

Datagram size [100]:

Timeout in seconds [2]:

Extended commands [n]: y

Source address or interface: 200.200.200.1

Type of service [0]:

Set DF bit in IP header? [no]:

Validate reply data? [no]:

Data pattern [0xABCD]:

Loose, Strict, Record, Timestamp, Verbose[none]:

Sweep range of sizes [n]:

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 172.16.0.3, timeout is 2 seconds:

U.U.U <- không thể tới được (Unreachable)

Success rate is 0 percent (0/5)

–Lệnh ping không thành công do access-list đã hoạt động trên R2, kiểm tra các gói vào trên R2 bằng lệnh debug ip

packet. Lưu ý rằng các gói bị loại bỏ bản tin ICMP host unreachable được gởi ngược trở lại R1:

R2#debug ip packet

IP packet debugging is on

R2#

IP: s=200.200.200.1 (Serial0/0), d=172.16.0.3 (FastEthernet0/0), len 100,

access denied

IP: s=203.162.0.2 (local), d=200.200.200.1 (Serial0/0), len 56, sending <- gởi bản tin

ICMP host unreachable

Page 86: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 86

–Dùng extended ping trên R2 tới PC3, lấy địa chỉ nguồn là 162.16.0.1

R2#ping

Protocol [ip]:

Target IP address: 172.16.0.3

Repeat count [5]:

Datagram size [100]:

Timeout in seconds [2]:

Extended commands [n]: y

Source address or interface: 162.16.0.1

Type of service [0]:

Set DF bit in IP header? [no]:

Validate reply data? [no]:

Data pattern [0xABCD]:

Loose, Strict, Record, Timestamp, Verbose[none]:

Sweep range of sizes [n]:

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 172.16.0.3, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms

–Có thể ping PC3 từ PC1 được do access–list chỉ cấm PC2 vào mạng 172.16.0.0/24

C:\Windows\Desktop>ping 172.16.0.3

Pinging 172.16.0.3 with 32 bytes of data:

Reply from 172.16.0.3: bytes=32 time=18ms TTL=126

Reply from 172.16.0.3: bytes=32 time=18ms TTL=126

Reply from 172.16.0.3: bytes=32 time=18ms TTL=126

Reply from 172.16.0.3: bytes=32 time=18ms TTL=126

Ping statistics for 172.16.0.3:

Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),

Approximate round trip times in milli-seconds:

Minimum = 18ms, Maximum = 18ms, Average = 18ms

Page 87: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 87

LAB 4-2: EXTENDED ACCESS-LIST

Mô tả: –Lab này mô tả cách lọc các gói sử dụng extended access-list. Router A cho phép tất cả lưu lưu lượng từ PCC (150.1.1.2) đến PCA (152.1.1.2) và từ chối tất cả các lưu lượng từ PCC (150.1.1.2) tới PCB (152.1.1.3). Extened Access-list được sử dụng vì cần lọc trên cả địa chỉ IP nguồn và đích. –Router A và RouterB nối bằng đường serial và đặt địa chỉ IP như trên hình. RouterA và RouterB có địa chỉ IP secondary tạo trên cổng Ethernet để làm điểm kiểm tra. –Access-list được dùng để lọc ngõ vào trên cổng serial của RouterA, cho phép các gói từ PCC 150.1.1.2 tới PCA và không cho phép các gói từ PCC tới PCB.

Cấu hình: Router A:

! hostname Router1 ! no ip domain-lookup ! interface Ethernet0 ip address 152.1.1.2 255.255.255.0 secondary ← Địa chỉ IP thứ hai để làm điểm kiểm tra ip address 152.1.1.3 255.255.255.0 secondary ip address 152.1.1.1 255.255.255.0 no keepalive ← vô hiệu hóa keepalive trên router cho phép cổng ethernet0 vẫn up khi không kết nối ra bên ngoài ! interface Serial0 ip address 195.1.1.4 255.255.255.0 ip access-group 100 in ← Dùng Access-list 100 cho tất cả lưu lượng vào trên đường serial0 ! no ip classless ip route 150.1.1.0 255.255.255.0 Serial0 ← dùng định tuyến tĩnh (không dùng định tuyến động) ip route 151.1.1.1 255.255.255.255 Serial0 access-list 100 permit ip host 150.1.1.2 host 152.1.1.2 log ← tổng hợp các bản tin thông tin về các gói thoả điều kiện. access-list 100 deny ip host 150.1.1.2 host 152.1.1.3 log ← Loại tất cả các gói IP từ 150.1.1.2 tới 152.1.1.3; tổng hợp bản tin thông báo về các gói thoả điều kiện. (Chú ý: tất cả các gói khác ngầm hiểu là bị loại bỏ; tất cả các access list đều kết thúc bằng câu lệnh loại bỏ tất cả) ! ! line con 0 line vty 0 4 login ! end

Page 88: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 88

Router 2:

! hostname RouterB ! interface Loopback0 ip address 150.1.1.1 255.255.255.255 ! interface Ethernet0 ip address 150.1.1.2 255.255.255.0 secondary ip address 150.1.1.1 255.255.255.0 no keepalive ! interface Serial0 ip address 195.1.1.10 255.255.255.0 clock rate 64000 ! no ip classless ip route 152.1.1.0 255.255.255.0 Serial0 ! line con 0 line vty 0 3 login ! end

Chú ý:Khi tạo access list tất cả các mục tuần tự theo thứ tự như khi ta đánh vào. Tất cả các câu lệnh thêm vào sau đó sẽ đặt ở vị trí tiếp của access list. Cuối access list luôn có câu lệnh loại bỏ tất cả, do đó một access list phải có ít nhất một lệnh permit. Tốt nhất là soạn thảo access list trước (dùng Notepad chẳng hạn) sau đó cut và paste vào CLI của router.

Kiểm tra: - Sử dụng ping mở rộng (extended ping) trên RouterB hướng gói tới các địa chỉ IP secondary tạo ra trong cấu hình dùng địa chỉ nguồn khác nhau (cách này dùng thay cho nhiều PC ở trong mạng LAN của RouterA và RouterB). 1. Từ RouterB, ping 152.1.1.3 dùng nguồn là 1501.1.2 –Dùng lệnh debug ip packet trên RouterA, ta thấy các gói bị loại bỏ và bản tin ICMP host unreachable được gởi

IP: s=150.1.1.2 (Serial0), d=152.1.1.3, len 100, access denied IP: s=195.1.1.4 (local), d=150.1.1.2 (Serial0), len 56, sending ← ICMP host unreachable

–Dùng lệnh show ip access-list trên RouterA. Chú ý các dòng hiển thị chỉ loại access list và số các điều kiện thoả của mỗi mục.

RouterA#show ip access-lists Extended IP access list 100 permit ip host 150.1.1.2 host 152.1.1.2 log (5 matches) deny ip host 150.1.1.2 host 152.1.1.3 log (105 matches)

–Tùy chọn log sẽ tổng hợp các bản tin thông báo mọi gói thoả điều kiện. Từ khóa log được đặt ở cuối câu lệnh access-list. Bản tin logging là công cụ tốt để kiểm soát lỗi access list.

SEC-6-IPACCESSLOGDP: list 100 denied icmp 150.1.1.2 -> 152.1.1.3 (0/0). 4 packets

2. Từ RouterB, ping 152.1.1.3 dùng nguồn 150.1.1.2 –Tại RouterA, lệnh debug ip packet hiển thị trên RouterA, ta có thể thấy các gói được cho phép.

Page 89: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 89

IP: s=150.1.1.2 (Serial0), d=152.1.1.2, len 100, rcvd 7

–Dùng lệnh show ip access-list để xem số lượng các gói thoã điều kiện.

RouterA# show ip access-lists Extended IP access list 100 permit ip host 150.1.1.2 host 152.1.1.2 log (308 matches) deny ip host 150.1.1.2 host 152.1.1.3 log

Page 90: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 90

LAB 4-3: KIỂM SOÁT TRUY CẬP VÀO ROUTER

Mô tả:

Access-list có thể dùng để kiểm soát các kết nối telnet tới router. Access-list cho phép xác định

trạm nào được telnet vào router dựa trên địa chỉ IP. Lab này mô tả các hạn chế truy cập vào

router thông qua giao diện web và telnet sử dụng stadard access-list, theo các yêu cầu sau:

o Chỉ cho PC1 telnet vào R2. o Chỉ cho R1 telnet vào R2 với địa chỉ nguồn là 200.200.200.1 o Chỉ cho PC2 truy cập vào R2 qua giao diện web.

Cấu hình:

Router R1:

!

hostname R1

!

enable password cisco

!

ip subnet-zero

!

ip telnet source-interface Loopback0 <- dùng để thay đổi địa chỉ

nguồn của các gói telnet từ router này

no ip domain-lookup

!

interface Loopback0

ip address 200.200.200.1 255.255.255.0

!

interface FastEthernet0/0

ip address 192.168.0.254 255.255.255.0

duplex auto

speed auto

Page 91: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 91

no shutdown

!

interface Serial0/0

ip address 203.162.0.1 255.255.255.0

no shut

!

ip classless

ip route 162.16.0.0 255.255.0.0 203.162.0.2

ip route 172.16.0.0 255.255.0.0 203.162.0.2

no ip http server

!

line con 0

transport input none

line aux 0

line vty 0 4

no login

!

end

Router R2:

!

hostname R2

!

enable password cisco

!

ip subnet-zero

no ip domain-lookup

!

interface Loopback0

ip address 162.16.0.1 255.255.0.0

no ip directed-broadcast

!

interface FastEthernet0/0

ip address 172.16.0.254 255.255.0.0

no ip directed-broadcast

!

interface Serial0/0

ip address 203.162.0.2 255.255.255.0

no ip directed-broadcast

clockrate 64000

!

ip classless

ip route 192.168.0.0 255.255.255.0 203.162.0.1

ip route 200.200.200.0 255.255.255.0 203.162.0.1

Page 92: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 92

ip http server <- bật web server lên, cho phép cấu hình router

qua giao diện web

ip http access-class 3 <- bật access-list 3 để hạn chế truy cập

vào giao diện web

!

access-list 2 permit 192.168.0.1

access-list 2 permit 200.200.200.1

access-list 3 permit 192.168.0.2 <- không khai báo wildcard mask,

router sẽ cho là 0.0.0.0

!

line con 0

transport input none

line aux 0

line vty 0 4

access-class 2 in <- áp access-list 2 để hạn chế telnet vào

router R2

no login <- cho phép telnet vào router không cần mật khẩu

!

end

Thực hiện:

1. Tạo các access-list:

R2(config)# access-list 2 permit 192.168.0.1 0.0.0.0

R2(config)# access-list 2 permit host 200.200.200.1 <- có thể

thay thế wildcard mask 0.0.0.0 bằng từ khóa host

R2(config)# access-list 3 permit host 192.168.0.2

2. Áp access-list 2 vào các line vty để hạn chế truy cập vào R2 qua telnet.

R2(config)# line vty 0 4

R2(config-line)# access-class 2 in <- sử dụng từ khóa in trong

lệnh access-class. Nếu dùng từ khóa out sẽ cấm khả năng telnet

của R2 đến các host khác.

3. Bât web server trên R2 và áp access list 3 vào h�p server đê han chế truy câp vào giao diê n

web:

R2(config)# ip http server

R2(config)# ip http access-class 3 <- xác định access-list 3 sẽ

áp dụng trên mọi HTTP Request.

Khi áp access-class vào IOS webserver, không sử dụng từ khóa in . vì IOS Webserver chỉ có thể

nhận các yêu cầu để tạo kết nối. access- list không thể áp cho các traffic chiều ra.

Page 93: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 93

Kiểm tra:

- Telnet vào R2 từ R1:

R1#telnet 203.162.0.2 <- lúc này chưa cấu hình lệnh ip telnet

source-interface lo0

Trying 203.162.0.2 ...

% Connection refused by remote host <- kết nối bị từ chối vì địa

chỉ nguồn của gói telnet là 203.162.0.1 không thỏa access-list 2.

- Cần phải cấu hình R1 để các gói telnet có địa chỉ nguồn thỏa access-list 2 (200.200.200.1 –

interface lo0)

R1#conf t

Enter configuration commands, one per line. End with CNTL/Z.

R1(config)#ip telnet source-interface lo0

R1(config)#^Z

R1#telnet 203.162.0.2

Trying 203.162.0.2 ... Open

R2> <- telnet đến R2 thành công

- Telnet từ PC3 (172.16.0.3) vào R2.

C:\Windows\Desktop>telnet 172.16.0.254

Connecting To 172.16.0.254...Could not open connection to the host, on port 23.

No connection could be made because the target machine actively refused it. <- kết nối

bị từ chối vì địa chỉ của PC3 không thỏa mãn access-list 2

- Telnet từ PC1 vào R2.

C:\Windows\Desktop>telnet 203.162.0.2

- Tư PC2 có thê truy câ p vào R2 qua giao diê n Web: Tư Internet Explorer gõ http://203.162.0.2 vào thanh Address Nhâ p User Name là R2 và mật khẩu là cisco

Page 94: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 94

Phan bai tap nang cao

Bai 1: NAT

Implement network by the following picture

Implement network by the following picture

Bai 3: IPV6 RIP

Implement network by the following picture

Page 95: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 95

Bai 4

Cisco Catalyst Switch Configuration

Configure the switch with a host name of Cat1900. Set the enable password to falcons. Assign the management console an IP address of 192.168.1.3/24 and a default gateway of

192.168.1.10 (the terminal server). Configure ports 1 and 2 (refer to Figure 3-2, if needed) to be in VLAN 1, and name the

VLAN vlan-r1r2. Configure port 3 for VLAN 2, and name the VLAN vlan-r2e1. Configure port 4 for VLAN 3, and name the VLAN vlan-r3e0. Configure port 5 for VLAN 4, and name the VLAN vlan-r4e0.

Page 96: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 96

Cisco Router Configuration

Configure all routers to have the following:

Host name (that is, host names are to be according to the number R1, R2, R3, and so on). Enable password of falcons. Enable console login with password falcons. Telnet access (vty 0 4), password falcons. No DNS resolution (no domain name lookups). Configure all routers so that the console port will not time out your connection. Configure all routers so that messages from the router to the console screen will not be

appended to the command line. Configure all routers to have a description on all active interfaces (except loopback

interfaces) stating to which router they are connected and which interface they are using. Configure all routers to show a banner when you log into the console port. In the banner,

state which router you are logging into. For example, on Router 1, the banner should read "This is Router 1."

Create a host table on all routers using the loopback addresses you just created for each router.

IP Addressing

Create loopback interfaces on all routers. Use IP address 192.169.X.X/24 (where X is the router number). So, R1 would have a loopback address of 192.169.1.1/24, R2 would be 192.169.2.2/24, and so on.

Look at the network diagram for IP addressing assignments. Don't forget to look at the netmasks! The BRI ports on R5 and R6 should use the IP addresses 192.168.200.1/30 and 192.168.200.2/30, respectively.

Routing Information Protocol

Routing Information Protocol (RIP) is a very common routing protocol used in small to medium-size networks. RIP is very important to the CCNA exam, and, in addition, you should have a working knowledge of configuring and troubleshooting routing issues in RIP.

Place R2's loopback 0, E0, and E1 networks into RIP. R1's E0 and loopback 0 networks should be configured for RIP as well.

Figure 3-3 shows the routers that you will be working with in this section.

Page 97: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 97

Interior Gateway Routing Protocol

Interior Gateway Routing Protocol (IGRP) is a similar routing protocol to RIP. We have included a section in the lab so that you can see the configuration commands and routing issues with IGRP.

Place R3's S1, loopback 0, and R5's To0, loopback 0, and S0 networks into IGRP autonomous system 200.

Figure 3-4 depicts the routers that you will configure in this section.

Page 98: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 98

Enhanced IGRP

Enhanced IGRP (EIGRP) is a very common routing protocol, and you will see it used many networks. It is very important that you understand the configuration process of EIGRP and know some troubleshooting processes for EIGRP. Having a strong working knowledge of EIGRP will be very beneficial in the real world. We have included EIGRP even though the CCNA exam does not cover it in depth.

Place R3's S0, R2's S0, R4's S0, and R4's Loopback 0 networks into EIGRP autonomous System 100.

Place R3's E0 network and R4's E0 into EIGRP AS 100. Create two loopback interfaces on R4 with the following addresses: loopback 1 =

200.200.1.4/24, loopback 2 = 200.200.2.4/24. Add these two networks into the EIGRP routing domain, and configure R4 so that all

other routers see only one route to these two addresses.

Figure 3-5 shows the router setup involved in this section.

Route Redistribution

Route redistribution is not covered on the CCNA exam, but it is imperative in a working environment that you understand how different routing processes interact. You will see very few networks that do not have some sort of route redistribution occurring at some level.

On R2, redistribute RIP into EIGRP and redistribute EIGRP into RIP.

Page 99: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 99

On R3, redistribute EIGRP into IGRP and redistribute IGRP into EIGRP. Fix any routing problems that you encounter as you see fit.

All routers should be capable of pinging all interfaces at the end of this section.

ISDN Dial-on-Demand Routing

Dial backup is an important element in most networks. We have included a basic dial-on-demand routing (DDR) situation so that you can see the configuration commands and see how it affects the network logically.

Configure the BRI interfaces on R5 and R6. See Figure 12-2 for ISDN information such as switch type and dial numbers.

Use PPP encapsulation. The ISDN link should be active only when IP traffic is present. R6 should call R5. No

routing protocols are to be used across the link. Use static routes on R5 and R6, but ensure that workstations on R6's Token Ring network (192.168.60.0) can reach the rest of your network.

The link should be brought down after 5 minutes of inactivity. Test R6 connectivity to the rest of your network through Telnet. You must use the host

name of each router, which was configured previously (that is, R1, R2, R3, and so on), to initiate the Telnet session.

Figure 3-6 shows the routers involved in configuring DDR.

Page 100: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 100

Internetwork Packet Exchange

Internetwork Packet Exchange (IPX) is a very common protocol. Although its popularity has diminished, it can be found in many networks. You will find it very helpful to have a good understanding of how IPX is configured on Cisco routers and how the Cisco routers route between IPX networks.

Configure R2's S0, R3's S0, and R4's S1 with IPX network number 1000. Configure R3's S1 and R5's S0 for IPX network number 3500. Configure R5's To0 for IPX network number 5000. Configure R4's E0 for IPX network 4000. Configure R1's E0 and R2's E0 for IPX network 2100. Configure R2's Ethernet 1 for IPX network 2000. Configure R3's E0 with IPX network 3000. Use the default encapsulation type. Configure a secondary IPX network number 3001 on R3's E0. Make the encapsulation

Novell SAP.

Figure 3-7 shows the IPX network topology. Note that we will not be configuring ISDN DDR for IPX in this book.

Page 101: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 101

IPX EIGRP

Use IPX EIGRP as the routing protocol for the interfaces in the Frame Relay cloud and R4's E0. Figure 3-8 identifies the router interfaces that will be configured for IPX EIGRP.

IPX RIP

Use IPX RIP for all other router interfaces that are not configured for IPX EIGRP. Figure 3-9 identifies the IPX networks that will be configured for IPX RIP.

Page 102: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 102

IPX Routing Redistribution

To make all IPX networks reachable by all IPX routers, redistribute IPX EIGRP and IPX RIP. Make sure that all IPX networks are reachable by using the IPX ping command.

Standard Access Lists

Create a standard outgoing access list and apply it on R2's S0 that fulfills the following requirements:

Deny access to users on network 192.168.12.0 to the Frame Relay network. (Assume that this network exists off R1.)

Extended Access Lists

Create an extended incoming access list and apply it on R3's S0 that fulfills the following requirements:

- Deny HTTP (www) traffic from reaching the Token Ring 1s network.

- Deny SMTP traffic from reaching R3's E0 network.

- Permit anything else.

Cisco Router Operations

The CCNA exam covers some basic router commands and operations. We have included a section that will help you master these commands and give you an understanding of how these commands are applied on routers in a working network environment.

Page 103: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 103

Cisco Router Boot Configuration— Configure R1 to boot from the TFTP server and then Flash. (Use the Cisco IOS Software image filename igs-j-l.111-18.bin.).

Cisco Router IOS Software Backup— Backup the Cisco IOS Software image on R1 to the TFTP server 192.168.1.5.

Cisco Router IOS Software Upgrade— Upgrade the Cisco IOS Software on R1 to image c2500-js-l_112-17.bin from the TFTP server.

Cisco Router Configuration Backup— Backup the current configurations of R1 to the TFTP server.

Cisco Router Configuration Restore— Restore the startup config on R1 from the saved image on the TFTP server.

Figure 3-10 gives a depiction of how the TFTP server is incorporated into the network.

Page 104: Switching LAb V3

Leturer: Ta Duy Cong Chien Page 104

Bai 5 : ACL

1. ACL01: network 10.0 40.0: deny and 40.0 10.0: allow

2. ACL02: 10.5 50.7: deny and 50.7 10.5: allow

3. ACL03: 10.5 using telnet to router Red Deer is allow and deny for another host

4. ACL04: 20.3 using telnet to 70.2 is allow but another host in network 20.x.x.x are

deny

5. ACL05: 50.1 - 50.63 using web to connect to 80.16 is deny but 50.64 – 50.254 are

allow