lab 4 cau hinh router co ban

19
Lab thực hành Router cơ bản ThS.Đào Anh Vũ LAB 4: CẤU HÌNH ROUTER CƠ BẢN Làm quen với chế độ dòng lệnh (CLI) và một số lệnh của router Cisco Hướng dẫn 1. Nối cá p Để đảm bảo an toàn thiết bị trong khi thực hành, cần phải tắt hoàn toàn nguồn điện các thiết bị trong khi nối cáp. Dùng cáp Console nối cổng COM1 của máy PC (dùng Terminal chuyển đổi từ DB-9 sang RJ45) với cổng Console của Router. Kiểm tra lại dây và jack cắm đảm bảo đã nối chắc chắn. 2. Đăng nhập vào router Khởi động Windows, vào HyperTerminal 1

Upload: daodai-vu

Post on 10-Nov-2014

106 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lab 4 Cau Hinh Router Co Ban

Lab thực hành Router cơ bản ThS.Đào Anh Vũ

LAB 4: CẤU HÌNH ROUTER CƠ BẢN

Làm quen với chế độ dòng lệnh (CLI) và một số lệnh của router Cisco

Hướng dẫn1. Nối cá p Để đảm bảo an toàn thiết bị trong khi thực hành, cần phải tắt hoàn toàn nguồn điện các thiết bị trong khi nối cáp. Dùng cáp Console nối cổng COM1 của máy PC (dùng Terminal chuyển đổi từ DB-9 sang RJ45) với cổng Console của Router. Kiểm tra lại dây và jack cắm đảm bảo đã nối chắc chắn.

2. Đăng nhập vào router Khởi động Windows, vào HyperTerminal Start – Programs – Accessories – Communicatons – Hyper Terminal Đặt tên và các thông số như hình Name: <tên file lưu trữ> Icon: chọn biểu tượng tùy thích Connect using: COM1

1

Page 2: Lab 4 Cau Hinh Router Co Ban

Lab thực hành Router cơ bản ThS.Đào Anh Vũ

Đây là dạng cơ bản nhất để có thể thông qua một máy tính cấu hình các thiết bị cisco. Nhưng cách thức này rất bị động, vì một máy tính chỉ cấu hình được một router.

Trong thực tế phòng LAB, ta thường đấu nối theo sơ đồ sau, để cấu hình các router thông qua Terminal Server.Terminal Server cung cấp truy cập out-of-band, nghĩa là có thể sử dụng telnet để truy cập router thông qua cổng console hay cổng aux. Termial server là router có các Asynchronous

port nối trực tiếp với console port của các thiết bị router, switch.

2

Page 3: Lab 4 Cau Hinh Router Co Ban

Lab thực hành Router cơ bản ThS.Đào Anh Vũ

3

Page 4: Lab 4 Cau Hinh Router Co Ban

Lab thực hành Router cơ bản ThS.Đào Anh Vũ

LỆNH CISCO CĂN BẢN:

Giao diện terminal khi vừa khởi động router

Bấm ? tại Router>? để xem trợ giúp tại mode này có bao nhiêu lệnh tất cả

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 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--

Vào Priviledge mode:

Router>enableRouter#

Để quay lại user mode bằng lệnh disable

Router>enableRouter#Router#disableRouter>

4

F3: 7712008+112808+595100 at 0x3000060

Restricted Rights Legend

Use, duplication, or disclosure by the Government issubject to restrictions as set forth in subparagraph(c) of the Commercial Computer Software - RestrictedRights clause at FAR sec. 52.227-19 and subparagraph(c) (1) (ii) of the Rights in Technical Data and ComputerSoftware clause at DFARS sec. 252.227-7013.

cisco Systems, Inc. 170 West Tasman Drive San Jose, California 95134-1706

Cisco Internetwork Operating System Software IOS (tm) 2500 Software (C2500-I-L), Version 12.1(1)T, RELEASE SOFTWARE (fc1)Copyright (c) 1986-2000 by cisco Systems, Inc.Compiled Thu 16-Mar-00 16:10 by ccaiImage text-base: 0x0303F64C, data-base: 0x00001000

cisco 2500 (68030) processor (revision D) with 4096K/2048K bytes of memory.Processor board ID 03874635, with hardware revision 00000000Bridging software.X.25 software, Version 3.0.0.1 Ethernet/IEEE 802.3 interface(s)2 Serial network interface(s)32K bytes of non-volatile configuration memory.8192K bytes of processor board System flash (Read ONLY)

--- System Configuration Dialog ---

Would you like to enter the initial configuration dialog? [yes/no]: n

Would you like to terminate autoinstall? [yes]:

Press RETURN to get started!

00:01:01: %IP-5-WEBINST_KILL: Terminating DNS process00:01:07: %SYS-5-RESTART: System restarted --Cisco Internetwork Operating System Software IOS (tm) 2500 Software (C2500-I-L), Version 12.1(1)T, RELEASE SOFTWARE (fc1)Copyright (c) 1986-2000 by cisco Systems, Inc.Compiled Thu 16-Mar-00 16:10 by ccai00:01:07: %LINK-5-CHANGED: Interface Ethernet0, changed state to administratively down00:01:07: %LINK-5-CHANGED: Interface Serial1, changed state to administratively down00:01:08: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0, changed state to down00:01:08: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1, changed state to downRouter>

Bấm Enter để bắt đầu vào cấu hình router

Page 5: Lab 4 Cau Hinh Router Co Ban

Lab thực hành Router cơ bản ThS.Đào Anh Vũ

Để thoát hẳn trở ra khỏi chế độ dòng lệnhRouter con0 is now available

Press RETURN to get started.

Router>enableRouter#logout

Router con0 is now available

Press RETURN to get started.

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 lệnh được phép sử dụng và ý nghĩa của lệnh đó.

Ví dụ muốn đánh lệnh enable tại user mode để vào Priviledge mode, nhưng bạn lại quên, không nhớ rõ lệnh enable phải đánh như thế nào, bạn chỉ cần đánh e?

Router>e?enable exit

Router liệt kê cho biết, ngay tại mode này có 2 lệnh bắt đầu bằng chữ e là lệnh enable và lệnh exit.

Bây giờ, bạn đánh vào :

Router>en?enable

Router liệt kê cho biết chỉ có 1 lệnh tại mode này là lệnh enable, do vậy ta có thể đánh tắt lệnh enable = en cũng được.

Router>enRouter#

Như vậy, dấu hỏi được đặt liền kề vào lệnh (không có khoảng trắng) sẽ cho ta biết những lệnh nào có trong mode này bắt đầu bằng những chữ trước ?

Tại priviledg mode, ví dụ bạn muốn xem tiếp các phần của lệnh show, bạn gõ :

Router#show ? access-expression List access expression access-lists List access lists accounting Accounting data for active sessions adjacency Adjacent nodes aliases Display alias commands arp ARP table

5

Page 6: Lab 4 Cau Hinh Router Co Ban

Lab thực hành Router cơ bản ThS.Đào Anh Vũ

async Information on terminal lines used as router................................................................................................................................................................................................................................................................................. cops COPS information debugging State of each debugging option --More—

traffic-shape traffic rate shaping configuration users Display information about terminal lines version System hardware and software status vtemplate Virtual Template interface information whoami Info on current tty line x25 X.25 information x29 X.29 information

router liệt kê cho ta thấy tất cả những sub-comand đi theo sau lệnh show, tại đây bạn lưu ý có sub-command là version, dùng để xem tình trạng của hardware và software

Router#s?*s=show send set setup showslip start-chat systat

//có 4 lệnh bắt đầu bằng chữ s, nhưng lệnh show được ưu tiên (có dấu * đứng trước lệnh show), tức là chỉ cần đánh vào là s, thì router vẫn tự hiểu là ta đang cần đánh lệnh show. Nhưng thông thường ta đánh tắt là sh.

Router#shRouter#show v?version vtemplate

// có 2 lệnh sub-command

Router#show ve?version

Router#show veRouter#show version

Router#sh verCisco Internetwork Operating System SoftwareIOS (tm) 2500 Software (C2500-I-L), Version 12.1(1)T, RELEASE SOFTWARE (fc1)Copyright (c) 1986-2000 by cisco Systems, Inc.Compiled Thu 16-Mar-00 16:10 by ccaiImage text-base: 0x0303F64C, data-base: 0x00001000

ROM: System Bootstrap, Version 11.0(10c), SOFTWAREBOOTFLASH: 3000 Bootstrap Software (IGS-BOOT-R), Version 11.0(10c), RELEASE SOFTWARE (fc1)

Router uptime is 55 minutesSystem returned to ROM by reloadSystem image file is "flash:R1_Flash_New"

6

Page 7: Lab 4 Cau Hinh Router Co Ban

Lab thực hành Router cơ bản ThS.Đào Anh Vũ

cisco 2511 (68030) processor (revision M) with 2048K/2048K bytes of memory.Processor board ID 20475723, with hardware revision 00000000Bridging software.X.25 software, Version 3.0.0.1 Ethernet/IEEE 802.3 interface(s)2 Serial network interface(s)16 terminal line(s)32K bytes of non-volatile configuration memory.8192K bytes of processor board System flash (Read ONLY) --More—Configuration register is 0x2102

Router#

Vào chế độ Global-configuration-mode, dùng lệnh configuration terminalRourter#config terminal //có thể đánh tắt là : conf tRouter(config)#

Đặt tên cho router là R1Router(config)#hostname R1R1(config)#

Đặt banner cho Router :R1(config)#banner motd & chao mung cac ban den voi VIEN DONG &R1(config)#endR1#logout

Sau khi làm xong banner thì bạn logout rồi vào lại router sẽ thấy banner mỗi khi kết nối vào router

Các lệnh đặt thông số cho line console :R1>enR1#conf tEnter configuration commands, one per line. End with CNTL/Z.r1(config)#line console 0r1(config-line)#loggin sync //dùng để tự động xuống hàngr1(config-line)#exec-timeout 0 0 //dùng đặt thời gian timeoutr1(config-line)#endR1#Sau khi làm xong lệnh loggin sync thì trên màn hình console không còn hiện tượng bị mất con trỏ. Lệnh exec-timeout X Y có hai tham số X là phút, Y là giây. Dùng để đặt thời gian tự khóa router nếu không gõ phím nào bất kỳ. Với thời gian 0 0 có nghĩa là không bao giờ timeout.

Để vào mode interface :R1>enR1#conf tEnter configuration commands, one per line. End with CNTL/Z.R1(config)#interface ethernet 0 //lệnh tắt int e0R1(config-if)#exit

7

Page 8: Lab 4 Cau Hinh Router Co Ban

Lab thực hành Router cơ bản ThS.Đào Anh Vũ

Đặt địa chỉ IP cho interface ethernet 0 R1(config)#interface ethernet 0R1(config-if)#ip address 192.168.2.151 255.255.255.0R1(config-if)#no shutdown //để up int e0 lên.R1(config-if)#end

Đặt description cho interface :R1#conf tEnter configuration commands, one per line. End with CNTL/Z.R1(config)#int e0R1(config-if)#description day la int noi vao mang lanR1(config-if)#endR1#sh int e0

Sau khi làm xong lệnh description cho int e0, bạn dùng lệnh sh int e0 để kiểm tra kết quả.R1#sh int e0Ethernet0 is up, line protocol is up Hardware is Lance, address is 0010.7be8.5847 (bia 0010.7be8.5847) Description: day la int noi vao mang lan Internet address is 192.168.2.151/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:00:01, output 00:00:09, output hang never

Lệnh Sh ip int brief dùng để kiểm tra tất cả các ip address của các interface trên router.

r1#sh ip int brief

Interface IP-Address OK? Method Status Protocol

Ethernet0 192.168.2.151 YES NVRAM up up

Serial0 unassigned YES NVRAM administratively down down

Serial1 unassigned YES NVRAM administratively down down

PASSWORD:

Thông thường có 5 loại password để bảo mật cho một router Cisco.

1. Hai loại password đầu tiên là enable password, sử dụng để vào chế độ priviledge mode, password này sẽ yêu cầu bạn nhập vào khi đánh lệnh enable từ user mode để vào privilegde mode.2. Ba loại còn lại đặt password cho các chế độ cho user mode khi truy cập qua cổng console, cổng Aux, hay Telnet

IOS password 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à khoảng cách.

8

Page 9: Lab 4 Cau Hinh Router Co Ban

Lab thực hành Router cơ bản ThS.Đào Anh Vũ

Password truy cập vào Priviledge Mode:- Password dạng không mã hóa khi lưu trữ (clear-text), Password secrect là password khi lưu trữ sẽ

được mã hoá dạng MD5 theo mặc định, ta có thể kiểm lại bằng lệnh show run.- Nếu vừa tồn tại password enable password và enable secrect thì enable password không có tác dụng.

R1#conf tR1(config)#enable password 456R1(config)#enalbe secrect 789R1(config)#end

R1#show runBuilding configuration...

Current configuration:!version 12.1service timestamps debug uptimeservice timestamps log uptimeno service password-encryption!hostname R1!enable secret 5 $1$nsVj$eErWsNTNwP.jmJckAv8qE. //789 đã được mã hóaenable password 456 //456 vẫn giữ nguyên !!!ip subnet-zero!!!interface Ethernet0 --More--

Password truy cập vào User Mode: Đặt password 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.

R1(config)#line ? <0-22> First Line number aux Auxiliary line console Primary terminal line tty Terminal controller vty Virtual terminal

Aux đặt password cho cổng aux, thường dùng khi cấu hình cho modem gắn router, quay số vào để cấu hình router.Console đặt password trước khi vào user modevty đặt password để telnet vào router. Nếu không đặt password, không thể thực hiện telnet vào router.

9

Page 10: Lab 4 Cau Hinh Router Co Ban

Lab thực hành Router cơ bản ThS.Đào Anh Vũ

Để đặt password user mode, cần xác định line muốn cấu hình và dùng lệnh login để cho router biết đưa ra thông báo chứng thực đòi hỏi nhập password.Câu lệnh login rất quan trọng, nếu không có router sẽ không thông báo đòi hỏi chứng thực.

1. Đặt password aux trên router : vào global config mode đánh lệnh line aux 0. Chú ý rằng chỉ được chọn số 0 ví chỉ có một port aux.

R1(config)#line aux 0R1(config-line)#loginR1(config-line)#password passaux

2. Đặt console password trên router : dùng lệnh line console 0R1(config)#line console 0R1(config-line)#loginR1(config-line)#password 123

3. Đặt password telnet: dùng lệnh line vty 0 4 R1(config)#line vty 0 4R1(config)#loginR1(config)#password telnet

4. Kiểm tra laị tất cả bằng lệnh : show running-configR1(config)#^ZR1#show runCurrent configuration:!version 12.1service timestamps debug uptimeservice timestamps log uptimeno service password-encryption!hostname R1!enable secret 5 $1$nsVj$eErWsNTNwP.jmJckAv8qE.enable password 456!!!ip subnet-zero!!interface Ethernet0 --More— no ip address shutdown!interface Serial0 no ip address shutdown no fair-queue!interface Serial1 no ip address shutdown!

10

Page 11: Lab 4 Cau Hinh Router Co Ban

Lab thực hành Router cơ bản ThS.Đào Anh Vũ

ip classlessno ip http server!line con 0 password 123 login transport input noneline 1 16line aux 0 password passaux

--More—

CÁC LỆNH DÙNG ĐỂ LƯU TRỮ CẤU HÌNH CỦA ROUTER:

R1#WriteR1#Copy running startup

Hai lệnh trên dùng để lưu cấu hình từ RAM của router đến NVRAM của router. Nên thường xuyên dùng lệnh này trong quá trình thao tác cấu hình router để tránh sự cố bất ngờ như mất điện đột ngột.

R1#Copy startup running

Lệnh trên dùng để copy cấu hình từ NVRAM đến RAM, dùng trong mục đích recovery password sẽ đề cập trong phần sau.Lưu ý: cả 3 lệnh đều thực hiện tại priviledge mode

Để thử lại các password đã đặt đầu tiên logout rồi vào lại router. Để vào được priviledge mode, các bạn phải trải qua 2 lần kiểm tra password.

Password USER mode là 123Password Priviledge mode là 789.

Press RETURN to get started.

User Access Verification

Password: //đánh vào 123 lưu ý bạn sẽ không thấy pass khi gõR1>enPassword: //đánh vào 789 lưu ý bạn sẽ không thấy pass khi gõ

11

Page 12: Lab 4 Cau Hinh Router Co Ban

Lab thực hành Router cơ bản ThS.Đào Anh Vũ

R1#

TÓM TẮT:Các lệnh cơ bản dùng để cấu hình router như sau:Router>enRouter#conf tEnter configuration commands, one per line. End with CNTL/Z.Router(config)#hostname r”X”R”X”(config)#enable password 456R”X”(config)#enable secret 789R”X”(config)#banne motd & chao mung cac ban den voi CCNA tai NHATNGHE &R”X”(config)#line console 0R”X”(config-line)#loggin synR”X”(config-line)#loginR”X”(config-line)#password 123R”X”(config-line)#exec-timeout 0 0R”X”(config-line)#exitR”X”(config)#line vty 0 4R”X”(config-line)#loginR”X”(config-line)#password telnetR”X”(config-line)#exitR”X”(config)#int e 0R”X”(config-if)#ip add 192.168.2.150+”X” 255.255.255.0R”X”(config-if)#description day la int noi vao mang lanR”X”(config-if)#no shutR”X”(config-if)#endR”X”#sh verR”X”#sh runR”X”#wrBuilding configuration...[OK]R”X”#

LƯU Ý: “X” LÀ SỐ THỨ TỰ CỦA ROUTER BẠN ĐANG KẾT NỐI

CÁC LỆNH ĐỂ XÓA CẤU HÌNH ROUTER   :

Để xóa cấu hình router và đưa router về trạng thái default, ta xóa NVRAM, cấu hình thông số register thành 0X2102 rồi reload lại router. Bạn thực hiện việc này mỗi khi cần reset lại router để thực hiện bài lab mới.

LUÔN THỰC HIỆN CÁC CÂU LỆNH NÀY TRƯỚC MỖI BUỔI THỰC HÀNH ĐỂ RESET ROUTER.

R”X”>enR”X”#conf tR”X”(config)#config 0x2102R”X”(config)#no boot systemR”X”(config)#endR”X”#write erase Erasing the nvram filesystem will remove all configuration files! Continue? [confirm] //bấm phím enter[OK]Erase of nvram: completeR”X”#

12

Page 13: Lab 4 Cau Hinh Router Co Ban

Lab thực hành Router cơ bản ThS.Đào Anh Vũ

*Mar 1 00:05:46.743: %SYS-7-NV_BLOCK_INIT: Initialized the geometry of nvramR”X”#reload //dùng khởi động lại routerProceed with reload? [confirm] //bấm phím enter

Chú ý: nếu router của bạn xuất hiện câu hỏi yêu cầu save cấu hình router thì phải trả lời NO

00:04:56: %SYS-5-RELOAD: Reload requestedSystem Bootstrap, Version 11.0(10c)XB1, PLATFORM SPECIFIC RELEASE SOFTWARE (fc1)

%SYS-4-CONFIG_NEWER: Configurations from version 12.1 may not be correctly understood.F3: 7873484+123020+586988 at 0x3000060..........................................................cisco 2620 (MPC860) processor (revision 0x200) with 45056K/4096K bytes of memory.Processor board ID JAD05030IL1 (1384535827)M860 processor: part number 0, mask 49Bridging software.X.25 software, Version 3.0.0.1 FastEthernet/IEEE 802.3 interface(s)2 Serial(sync/async) network interface(s)32K bytes of non-volatile configuration memory.16384K bytes of processor board System flash (Read/Write)

--- System Configuration Dialog ---

Would you like to enter the initial configuration dialog? [yes/no]: n

Would you like to terminate autoinstall? [yes]: //bấm phím enterPress RETURN to get started!

BÀI TẬP CÁC CÂU LỆNH CĂN BẢN   :

A.Thực hiện cấu hình router với yêu cầu như sau : Đặt tên router của bạn là RouterX (X là số thứ tự router của bạn

đang kết nối) Password priviledge không mã hóa là 456 Password priviledge mã hóa là 789 Password console là 123

13

Page 14: Lab 4 Cau Hinh Router Co Ban

Lab thực hành Router cơ bản ThS.Đào Anh Vũ

Mỗi khi kết nối vào router thì có câu thông báo : «CCNA VIEN DONG» 

Thời gian để router tự khóa là 5 phút 30 giây Các câu thông báo của router tự động xuống hàng Password để telnet vào router là « Telnet_RouterX » Đặt địa chỉ cho interface ethenet 0 của router là

192.168.2.150+X Đặt câu ghi nhớ cho int e0 là « connect to LAN » Lưu cấu hình vào NVRAM Reload và kiểm tra lại các cấu hình vừa làm xong. Router của

bạn phải kiểm tra password 2 lần, luôn có câu thông báo mỗi khi connect vào router, phải ping được các router khác.

B.Thực hiện tiếp phần sau nếu còn thời gian : đổi password console thành « 321 » bỏ hẳn password priviledge mode không cho router tự logout (tự khóa) bỏ đỉa chỉ IP ADD của Ether 0 đồng thời tắt Ether 0

Sau khi thực hiện phần B thì router của bạn chỉ còn 1 password duy nhất là « 321 », không có địa chỉ IP ADD và không tự logout.

14