啟動路由器 初次啟動一個Cisco路由器時,它將運行一個開機自檢過程。假如通過,他將在閃存中查找IOS系統,假如有IOS文件存在則執行裝載操作。閃存世一個電子可擦寫變成的制度存儲器。然后,IOS將繼續加載并查找一個合法的配置文件,它默認時是存儲在NVRAM中。 當路由器被首次引導或重新裝載時,會出現的信息: System Bootstrap, Version 11.0(10c), SOFTWARE Copyright (c) 1986-1996 by cisco Systems 2500 processor with 14336 Kbytes of main memory 這是一臺2501路由器啟動時的信息 第一行寫了,IOS版本是11.0 第二行是CISCO的版權信息 第三行行是內存的大小 路由器啟動以后,會出現一個提示 Would you like to enter the initial configuration dialog [yes/no]: n 假如選擇yes,將進入setup模式,選擇No我們將進入擴展設置模式。 Setup模式只配置購治理系統使用的連接性能,而擴展設置會答應你配置更多的內容。
登陸到路由器 Router> 這就是用戶模式,通常用來查看統計信息的 在特許模式中你可以查看并修改Cisco路由器的配置,但要進入此模式需要使用enable命令 具體步驟如下: Router> Router>enable Router# --------------------- 現在得到一個Router#提示符,表明已經在特許模式中了,在這里可以修改路由器的配置。 在這里可以通過使用disable命令,從特許模式中返回用戶模式。 Router#disable Router> 在用戶模式里,可以用logout命令來退出控制臺操作: Router>logout Router con0 is now available Press RETURN to get started. 也可以在特許模式下鍵入logout或exit來退出: Router>enable Router#logout Router con0 is now available Press RETURN to get started. 路由器模式概述 要從CLI上進行配置,可能會需要用configure terminal命令進入全局模式才能修改當權運行配置中的內容。你也可以在特許模式下鍵入config,然后按Enter鍵以默認方式進入全局模式。 Router#config Configuring from terminal, memory, or network [terminal] (Enter) Enter configuration commands, one per line. End with CNTL/Z. Router(config)# CLI提示符 在配置路由器時,理解所碰到的不同提示符的含義,是非常重要的。
獲取基本的路由信息 Router#sh version Cisco Internetwork Operating System Software IOS (tm) 2500 Software (C2500-JS-L), Version 12.2(27), RELEASE SOFTWARE (fc3) Copyright (c) 1986-2004 by cisco Systems, Inc. Compiled Tue 02-Nov-04 22:01 by kellmill Image text-base: 0x0307D390, data-base: 0x00001000
ROM: System Bootstrap, Version 5.2(8a), RELEASE SOFTWARE BOOTLDR: 3000 Bootstrap Software (IGS-RXBOOT), Version 10.2(8a), RELEASE SOFTWARE (fc1)
Router uptime is 17 minutes System returned to ROM by power-on System image file is "Flash:c2500-js-l.122-27.bin"
cisco 2500 (68030) processor (revision D) with 16384K/2048K bytes of memory. Processor board ID 02096577, with hardware revision 00000000 Bridging software.
X.25 software, Version 3.0.0. SuperLAT software (copyright 1990 by Meridian Technology Corp). TN3270 Emulation software. 1 Ethernet/IEEE 802.3 interface(s) 2 Serial network interface(s) 32K bytes of non-volatile configuration memory. 16384K bytes of processor board System flash (Read ONLY)
Configuration register is 0x2142
設置口令 啟用口令 可以在全局配置模式下設置啟用口令: Router(config)#enable last-resort Define enable action if no TACACS servers respond passWord Assign the privileged level password secret Assign the privileged level secret use-tacacs Use TACACS to check enable passwords 輔助口令 要配置輔助接口口令,需要進入到全局配置模式并輸入Line aux 。 Router(config)#line aux <0-0> First Line number
Router(config)#line aux 0 Router(config-line)#password 12345 Router(config-line)#login Router(config-line)#
Telnet口令 要為Telnet訪問路由器設置用戶模式口令,是用line vty命令。 Router(config)#line vty 0 <1-197> Last Line number <cr>
Router(config)#line vty 0 4 Router(config-line)#password 12345 Router(config-line)#login Router(config-line)# 加密你的口令 在默認時只有啟用加密口令是加密的,為了安全,需要手工配置用戶模式口令和啟用口令。 要實現口令加密,需要在全局模式下使用service password-encryption命令。 Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#service password-encryption Router(config)#
標志區 使用標志區是為那些撥號到你的互聯網絡中的用戶提供了一個安全的提示。 在Cisco路由器上設置一個標志區,這樣當任一用戶登錄到路由器上或遠程訪問路由器時,標志區顯示你希望他們看到的信息。 設置標志區,是用banner motd命令 Router(config)#banner motd # Enter TEXT message. End with the character '#'. Welcome to Hu Lian Shen Zhou # Router(config)#exit 現在顯示出來的就是剛才設置的標志區: Welcome to Hu Lian Shen Zhou User Access Verification Password:
串行接口命令 接口將被接到一個CSU/DSU類型的設備上,它要為線路提供時鐘。假如是用背對背的配置模式,DCE的連接端必須提供式中。默認時,Cisco的路由器都是數據終端設備(DTE)。 配置DEC串行接口使用clock rate命令: Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int s0 Router(config-if)#clock rate 64000 主機名 使用hostname命令來設置路由器的標識。它只在局部有作用,并不影響路由器的名稱查找或路由器在互聯網上的工作。 舉例: Router(config)#hostname SZ_Lab SZ_Lab(config)#hostname Cisco Cisco(config)#
描述 在接口上設置描述非常有意義,以免忘記了哪個接口是連接到哪里的這些。 和主機名一樣,它是只在本地有意思的設置。 Cisco(config)#int s0 Cisco(config-if)#description WAN to school 以下是show run信息 ! interface Serial0 description WAN to school ip address 192.168.0.1 255.255.255.0 ! 查看并保存配置 使用copy running-config startup-config命令,將配置從DRAM中手工保存到NVRAM中。 Cisco#copy run start Destination filename [startup-config] [ENTER] Building configuration... [OK]
要刪除啟動配置文件,使用erase startup-config命令 Cisco#erase startup-config Erasing the nvram filesystem will remove all configuration files! Continue [confirm][ENTER] [OK] Erase of nvram: complete Cisco#reload(從啟路由器命令)
驗證配置 show interface命令 sh ip interface命令 sh ip interface brief命令 sh controllers命令。
1 default Enable 1-12, AUI, A, B 2 sales Enable 2 3 marketing Enable 4 (略) 2950下的配置,使用switchport access vlan [vlan#]命令,如下: 2950(config-if)#int f0/2 2950(config-if)#switchport access vlan 2 2950(config-if)#int f0/3 2950(config-if)#switchport access vlan 3 2950(config-if)#int f0/4 2950(config-if)#switchport access vlan 4 2950(config-if)#exit 2950(config)#exit 2950# 驗證配置信息,如下: 2950#sh vlan brief VLAN Name Status Ports ---------------------------------------------------------------------------- 1 default active Fa0/1 Fa0/5...Fa0/12 2 Marketing active Fa0/2 3 Accounting active Fa0/3 (略)
配置中繼端口
1900只使用動態ISL(DISL)封裝方式,在快速以太網配置trunk,在接口配置模式下使用trunk [參數]的命令,如下,將26接口設置為trunk端口: 1900(config)#int f0/26 1900(config-if)#trunk auto Set DISL state to AUTO desirable Set DISL state to DESIRABLE nonegotiate Set DISL state to NONEGOTIATE off Set DISL state to OFF on Set DISL state to ON 1900(config-if)#trunk on 設置參數為on即接口將作為永久ISL的trunk端口,可以和和相連的設備協商,并且把連接轉換成trunk link 2950下在接口配置模式,使用switchport命令,如下: 2950(config)#int f0/12 2950(config-if)#switchport mode trunk 2950(config-if)#^Z 2950# 驗證配置信息: 2950#sh run (略) ! interface FastEthernet0/12 switchport mode trunk no ip address !
2950C(config)#up default-gateway 172.16.10.1 2950C(config)#^Z 2950C#copy run start 配置2950B,如下: 2950B(config)#enable secret noko 2950B(config)#line con 0 2950B(config-line)#login 2950B(config-line)#password noco 2950B(config-line)#line vty 0 15 2950B(config-line)#login 2950B(config-line)#password noco 2950B(config-line)#banner motd # 2950B # 2950B(config-line)#exit 2950B(config)#int vlan1 2950B(config-if)#ip address 172.16.10.3 255.255.255.0 2950B(config-if)#no shut 2950B(config-if)#exit 2950B(config)#up default-gateway 172.16.10.1 2950B(config)#^Z 2950B#copy run start 配置trunk,2950B如下: 2950B(config)#int f0/1 2950B(config-if)#switchport mode trunk 2950B(config-if)#int f0/4 2950B(config-if)#switchport mode trunk 2950B(config-if)#int f0/5 2950B(confgi-if)#switchport mode trunk 配置trunk,2950C如下: 2950C(config)#int f0/4 2950C(confgi-if)#switchport mode trunk 2950C(config-if)#int f0/5 2950C(config-if)#switchport mode trunk 驗證trunk信息,使用show interface trunk命令.如下: 2950B#sh int trunk Port Mode Encapsulation Status Native vlan Fa0/1 on 802.1q trunking 1 Fa0/4 on 802.1q trunking 1 Fa0/5 on 802.1q trunking 1 (略) 之前我們已經對2950B和2950C做了基本配置和trunk端口的配置,接下來應該設置VTP和創建VLAN,并且進行驗證.2950C如下: 2950C(config)#vtp mode server 2950C(config)#vtp domain Cisco 2950C(config)#^Z 2950C#vlan database 2950C(vlan)#vlan 2 name sales 2950C(vlan)#vlan 3 name marketing 2950C(vlan)#apply 2950C(vlan)#^C 2950C#sh vlan brief (略) 接下來分配端口,把Fa0/2分配給VLAN2,Fa0/3分配給VLAN3,默認所有的端口都處在VLAN1下,配置如下: 2950C(config)#int fa0/2 2950C(config-if)#switchport access vlan2 2950C(config)#int fa0/3 2950C(config-if)#switchport access vlan3 驗證信息,注重VLAN1里的Ports欄,如下: 2950C#sh vlan brief VLAN Name Status Ports ---------------------------------------------------------------------------- 1 default active Fa0/1 Fa0/5...Fa0/10 2 sales active Fa0/2 3 marketing active Fa0/3 配置2950B,把它設置成客戶模式,2950B從2950C接收VLAN信息,如下: 2950B(config)#vtp mode client 2950B(config)#vtp domain Cisco 2950B(config)#^Z 驗證,注重2950B已經從2950C知道了VLAN的信息,如下: 2950B#sh vlan brief VLAN Name Status Ports ---------------------------------------------------------------------------- 1 default active Fa0/1...Fa0/12 2 sales active 3 marketing active 但是仍然要給2950B分配端口,如下: 2950B(config)#int fa0/2 2950B(config-if)#switchport access vlan2 2950B(config)#int fa0/3 2950B(config-if)#switchport access vlan3 驗證信息,如下: VLAN Name Status Ports ---------------------------------------------------------------------------- 1 default active Fa0/1 Fa0/5...Fa0/12 2 sales active Fa0/2 3 marketing active Fa0/3 到現在,2950C和2950B的配置就算是完成了,經過驗證,我們也沒發現什么問題,接下來該配置什么呢當然是配置VLAN間的通信,根據上面的拓撲圖,可以知道需要在RouterB上進行配置,如下:
RouterB(config)#hostname Trunkrouter Trunkrouter(config)#int f0/0 Trunkrouter(config-if)#no ip address Trunkrouter(config-if)#no shut 創建子接口,并定義封裝類型,如下: Trunkrouter(config-if)#int f0/0.1 Trunkrouter(config-subif)#encapsulation dot1q 1 Trunkrouter(config-subif)#ip address 172.16.10.1 255.255.255.0 Trunkrouter(config-if)#int f0/0.2 Trunkrouter(config-subif)#encapsulation dot1q 2 Trunkrouter(config-subif)#ip address 172.16.20.1 255.255.255.0 Trunkrouter(config-if)#int f0/0.3 Trunkrouter(config-subif)#encapsulation dot1q 3 Trunkrouter(config-subif)#ip address 172.16.30.1 255.255.255.0 Trunkrouter(config-if)#exit 創建子接口,每個接口對應1個VLAN.注重,假如你試圖在第一個子接口分配IP地址,將收到錯誤信息,除非你先定義了封裝類型,如下: Trunkrouter(config-if)#int f0/0.1 Trunkrouter(config-subif)#ip address 172.16.10.1 255.255.255.0 Configuring IP routing on a LAN subinterface is only allowed if that subinterface is already configured as part of an IEEE 802.10, IEEE 802.1Q, or ISL VLAN.
備份和恢復Cisco配置 對于路由器配置進行的任何修改存儲在running-config文件中。在修改了running-config后沒有執行copy run start命令,那么路由器重載或掉電后修改的內容會丟失。 備份Cisco路由器配置 要把路由器的配置文件從路由器復制到TFTP服務器,可以使用copy running-config tftp或copy startup-config tftp。其中一個備份當前正在DRAM中運行的路由器配置,一個備份存儲在NVRAM中的路由器配置。 驗證當前配置 可以使用sh running-config命令 Router>en Router#sh run Building configuration...
Current configuration : 547 bytes ! version 12.1 當前信息表明路由器運行的是IOS 12.1版本
驗證存儲的配置 下面,應當檢查NVRAM中存儲的配置。要察看此配置,使用sh start命令: Router#sh start Using 547 out of 32762 bytes ! version 12.1 將當前配置復制到NVRAM 將running-config復制到NVRAM作為備份,可以確信路由器重載時總是重載Running-config文件。 Router#copy run start Destination filename [startup-config] [Enter] Building configuration... [OK] Router# 將配置復制到TFTP服務器 使用copy run tftp命令 恢復Cisco路由器配置 使用copy tftp run命令 刪除配置 使用erase startup-config命令 Router#erase startup-config Erasing the nvram filesystem will remove all files! Continue [confirm][Enter] [OK] Erase of nvram: complete Router# 使用Cisco發現協議 Cisco發現協議(CDP)是Cisco私有,幫助用來治理員收集本地相連和遠程設備的信息. 獲取CDP定時器和保持時間信息
之前提到過CDP的一些介紹,show cdp命令提供2個信息給你:
1.CDP timer:CDP包傳給每個活躍接口的時間間隔,默認是60秒 2.CDP holdtime:某設備從相鄰設備收到的包的保持時間,默認是180秒 如下: Router#sh cdp Global CDP information: Sending CDP packets every 60 seconds Sending a holdtime value of 180 seconds Router#
收集鄰居信息 使用show cdp neighbour可以顯示直接相連的設備的信息,如下: Router#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 Intrfce Holdtime Capability Platform Port ID 1900Switch Eth 0 238 T S 1900 2 2500B Ser 0 138 R 2500 Ser 0 Router#
2500#disconnect <1-2> The number of an active network connection WORD The name of an active network connection <cr> 2500#disconnect 1 Closing connection to 172.16.10.2 [confirm] 2500#
驗證如下: 2600#sh users Line User Host(s) Idle Location *0 con 0 idle 0 1 aux 0 idle 0 2 vty 0 idle 172.16.10.1 清除連接,使用clear line命令,并驗證,如下: 2600#clear line 2 [confirm] [OK] 2600#sh users Line User Host(s) Idle Location *0 con 0 idle 0 1 aux 0 idle 1 2600#
解析主機名 2種解析主機名到IP地址的辦法: 1.在每個router上建立主機表(host table) 2.建立DNS服務器(Domain Name System server),這個類似動態主機表 建立主機表 主機表只提供包含其中的解析,建立主機表的命令是ip host [主機名] [TCP端口號] [IP地址],默認TCP端口號為23.1個主機可以對應最多8個IP地址.如下: 2500(config)#ip host 2501B 172.16.10.2 2500(config)#ip host 1900S 192.168.0.32 2500(config)#^Z 使用show hosts命令驗證新建的主機表,如下: 2500#sh hosts Default domain is not set Name/address lookup uses domain service Name servers are 255.255.255.255 Host Flags Age Type Address(es) 2501B (perm, OK) 0 IP 172.16.10.2 1900S (perm, OK) 0 IP 192.168.0.32 2500# 注重Flags選項的perm,代表是手動輸入的,假如這項是temp的話,表明是由DNS解析的 使用DNS解析名稱 假如你在CLI下輸入了1個Cisco設備不能識別的命令,它會默認通過DNS來進行解析(它認為是主機名).這個不好的地方是要花費額外的時間等待DNS解析完.可以在全局配置模式下使用no ip domain-lookup命令關閉它
假如你在你的網絡里有DNS服務器,可以使用1些命令使DNS解析開始工作: 1.第一條命令是:ip domain-lookup,這個命令默認是打開了的.假如你之前使用了no ip domain-lookup的話,就要用這條命令打開它 2.第二條命令是:ip name-server.設置DNS服務器的IP地址,可以使1個IP地址對應多達6個服務器 3.最后條命令是:ip domain-name.雖然這個命令是可選的,但是最好還是設置1下 實例如下: 2500(config)#ip domain-lookup 2500(config)#ip name-server 192.168.0.23 2500(config)#ip domain-name noko.com 2500(config)#^Z 2500# 可以使用ping命令來嚴正下,如下: 2500#ping 1900S Translating “1900S”…domain server (192.168.0.23) [OK] (略) 使用show hosts命令驗證下,如下: 2500#sh hosts Default domain is noko.com Name/address lookup uses domain service Name servers are 192.168.023 Host Flags Age Type Address(es) 2501B (perm, OK) 0 IP 172.16.10.2 1900S.noko.com (temp, OK) 0 IP 192.168.0.32 2500# 檢查網絡連接 使用ping命令和Traceroute命令 __________________ WEB:www.cc-ie.com/bbs 互聯神州CCIE實驗室論壇 Q Q:95554545 MSN:fumin_0830@hotmail.com
PPP認證方法 PPP鏈路可以使用兩種認證方法: 口令認證協議(PAP) 口令認證協議是兩種方法中安全程度較低的一種。口令以明文發送,并且PAP值在初始鏈路建立時執行。 問答握手認證協議(CHAP) 問答握手認證協議用于鏈路初始啟動,和為了證實路由器連接的仍然是同一個主機而進行周期性鏈路檢查。 在Cisco路由器上配置PPP Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#int s0 Router(config-if)#encapsulation ppp Router(config-if)#^Z Router#
配置PPP認證 將串行接口配置為支持PPP封裝后,可以使用PPP在路由器之間配置認證。 Router#config t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname RouterA RouterA(config)#username RouterB password 12345 當使用hostname命令時,要記住用戶名師連接你路由器的遠程路由器的主機名。 當設置了主機名、用戶名和口令后,選擇認證類型、CHAP和PAP: RouterA#config t Enter configuration commands, one per line. End with CNTL/Z. RouterA(config)#int s0 RouterA(config-if)#ppp authentication chap pap RouterA(config-if)#^Z RouterA#
單個接口 RouterA#config 05:41:11: %SYS-5-CONFIG_I: Configured from console by consolet Enter configuration commands, one per line. End with CNTL/Z. RouterA(config)#int s0 RouterA(config-if)#encapsulation frame-relay RouterA(config-if)#ip addr 172.16.20.1 255.255.255.0 RouterA(config-if)#frame-relay lmi-type ansi RouterA(config-if)#frame-relay interface-dlci 101 RouterA(config-fr-dlci)#^Z