思科路由器配置基礎
思科(Cisco)路由器是智能信息網絡的基礎,為當今要求最嚴格的網絡服務,包括 IP 通信、視頻、客户關係管理、金融交易和其他實時應用提供了高 可用性、全面的安全性、易管理性和先進的服務質量( QoS )。下面小編準備了思科路由器配置基礎,歡迎大家參考!
一、基本設置方式
一般來説,可以用5種方式來設置路由器:
ole口接終端或運行終端仿真軟件的微機;
口接MODEM,通過電話線與遠方的終端或運行終端仿真軟件的微機相連;
3.通過Ethernet上的TFTP服務器;
4.通過Ethernet上的TELNET程序;
5.通過Ethernet上的SNMP網管工作站。
但路由器的第一次設置必須通過第一種方式進行,此時終端的硬件設置如下:
波特率 :9600
數據位 :8
停止位 :1
奇偶校驗: 無
二、命令狀態
1. router>
路由器處於用户命令狀態,這時用户可以看路由器的連接狀態,訪問其它網絡和主機,但不能看到和更改路由器的設置內容。
2. router#
在router>提示符下鍵入enable,路由器進入特權命令狀態router#,這時不但可以執行所有的用户命令,還可以看到和更改路由器的設置內容。
3. router(config)#
在router#提示符下鍵入configure terminal,出現提示符router(config)#,此時路由器處於全局設置狀態,這時可以設置路由器的全局參數。
4. router(config-if)#; router(config-line)#; router(config-router)#;…
路由器處於局部設置狀態,這時可以設置路由器某個局部的參數。
5. >
路由器處於RXBOOT狀態,在開機後60秒內按ctrl-break可進入此狀態,這時路由器不能完成正常的功能,只能進行軟件升級和手工引導。
6. 設置對話狀態
這是一台新路由器開機時自動進入的狀態,在特權命令狀態使用SETUP命令也可進入此狀態,這時可通過對話方式對路由器進行設置。
三、設置對話過程
顯示提示信息
全局參數的設置
接口參數的設置
顯示結果
利用設置對話過程可以避免手工輸入命令的煩瑣,但它還不能完全代替手工設置,一些特殊的設置還必須通過手工輸入的方式完成。
進入設置對話過程後,路由器首先會顯示一些提示信息:
--- 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 '[]'.
這是告訴你在設置對話過程中的任何地方都可以鍵入“?”得到系統的幫助,按ctrl-c可以退出設置過程,缺省設置將顯示在‘[]’中。然後路由器會問是否進入設置對話:
Would you like to enter the initial configuration dialog? [yes]:
如果按y或回車,路由器就會進入設置對話過程。首先你可以看到各端口當前的狀況:
First, would you like to see the current interface summary? [yes]:
Any interface listed with OK? value "NO" does not have a valid configuration
Interface | IP-Address | OK? | Method | Status | Protocol |
Ethernet0 | unassigned | NO | unset | up | up |
Serial0 | unassigned | NO | unset | up | up |
……… | ……… | … | …… | … | … |
Configuring global parameters:
1.設置路由器名:
Enter host name [Router]:
2.設置進入特權狀態的密文(secret),此密文在設置以後不會以明文方式顯示:
The enable secret is a one-way cryptographic secret used
instead of the enable password when it exists.
Enter enable secret: cisco
3.設置進入特權狀態的密碼(password),此密碼只在沒有密文時起作用,並且在設置以後會以明文方式顯示:
The enable password is used when there is no enable secret
and when using older software and some boot images.
Enter enable password: pass
4.設置虛擬終端訪問時的密碼:
Enter virtual terminal password: cisco
5.詢問是否要設置路由器支持的各種網絡協議:
Configure SNMP Network Management? [yes]:
Configure DECnet? [no]:
Configure AppleTalk? [no]:
Configure IPX? [no]:
Configure IP? [yes]:
Configure IGRP routing? [yes]:
Configure RIP routing? [no]:
………
6.如果配置的是撥號訪問服務器,系統還會設置異步口的參數:
Configure Async lines? [yes]:
1) 設置線路的最高速度:
Async line speed [9600]:
2) 是否使用硬件流控:
Configure for HW flow control? [yes]:
3) 是否設置modem:
Configure for modems? [yes/no]: yes
4) 是否使用默認的modem命令:
Configure for default chat script? [yes]:
5) 是否設置異步口的PPP參數:
Configure for Dial-in IP SLIP/PPP access? [no]: yes
6) 是否使用動態IP地址:
Configure for Dynamic IP addresses? [yes]:
7) 是否使用缺省IP地址:
Configure Default IP addresses? [no]: yes
8) 是否使用TCP頭壓縮:
Configure for TCP Header Compression? [yes]:
9) 是否在異步口上使用路由表更新:
Configure for routing updates on async links? [no]: y
10) 是否設置異步口上的其它協議。
接下來,系統會對每個接口進行參數的設置。
iguring interface Ethernet0:
1) 是否使用此接口:
Is this interface in use? [yes]:
2) 是否設置此接口的IP參數:
Configure IP on this interface? [yes]:
3) 設置接口的IP地址:
IP address for this interface:
4) 設置接口的IP子網掩碼:
Number of bits in subnet field [0]:
Class C network is , 0 subnet bits; mask is /24
在設置完所有接口的參數後,系統會把整個設置對話過程的結果顯示出來:
The following configuration command script was created:
hostname Router
enable secret 5 $1$W5Oh$p6J7tIgRMBOIKVXVG53Uh1
enable password pass
…………
請注意在enable secret後面顯示的是亂碼,而enable password後面顯示的是設置的內容。
顯示結束後,系統會問是否使用這個設置:
Use this configuration? [yes/no]: yes
如果回答yes,系統就會把設置的結果存入路由器的`NVRAM中,然後結束設置對話過程,使路由器開始正常的工作。
四、常用命令
1. 幫助
在IOS操作中,無論任何狀態和位置,都可以鍵入“?”得到系統的幫助。
2. 改變命令狀態
任務 | 命令 |
進入特權命令狀態 | enable |
退出特權命令狀態 | disable |
進入設置對話狀態 | setup |
進入全局設置狀態 | config terminal |
退出全局設置狀態 | end |
進入端口設置狀態 | interfacetype slot/number |
進入子端口設置狀態 | interfacetype number.subinterface[point-to-point | multipoint] |
進入線路設置狀態 | linetype slot/number |
進入路由設置狀態 | routerprotocol |
退出局部設置狀態 | exit |
任務 | 命令 |
查看版本及引導信息 | show version |
查看運行設置 | show running-config |
查看開機設置 | show startup-config |
顯示端口信息 | show interfacetype slot/number |
顯示路由信息 | show ip router |
用於IOS及CONFIG的備份和升級
5. 網絡命令
任務 | 命令 |
登錄遠程主機 | telnethostname|IP address |
網絡偵測 | pinghostname|IP address |
路由跟蹤 | tracehostname|IP address |
任務 | 命令 |
全局設置 | config terminal |
設置訪問用户及密碼 | usernameusernamepasswordpassword |
設置特權密碼 | enable secretpassword |
設置路由器名 | hostnamename |
設置靜態路由 | ip routedestination subnet-mask next-hop |
啟動IP路由 | ip routing |
啟動IPX路由 | ipx routing |
端口設置 | interfacetype slot/number |
設置IP地址 | ip addressaddress subnet-mask |
設置IPX網絡 | ipx networknetwork |
激活端口 | no shutdown |
物理線路設置 | linetype number |
啟動登錄進程 | login [local|tacacs server] |
設置登錄密碼 | passwordpassword |
1. IP地址分類
IP地址分為網絡地址和主機地址二個部分,A類地址前8位為網絡地址,後24位為主機地址,B類地址16位為網絡地址,後16位為主機地址,C類地址前24位為網絡地址,後8位為主機地址,網絡地址範圍如下表所示:
種類 | 網絡地址範圍 |
A | 到有效 和保留 |
B | 到有效 和保留 |
C | 到有效 和保留 |
D | 到用於多點廣播 |
E | 到保留 用於廣播 |
任務 | 命令 |
接口設置 | interfacetype slot/number |
為接口設置IP地址 | ip addressip-addressmask |
3. 使用可變長的子網掩碼
通過使用可變長的子網掩碼可以讓位於不同接口的同一網絡編號的網絡使用不同的掩碼,這樣可以節省IP地址,充分利用有效的IP地址空間。
如下圖所示:
Router1和Router2的E0端口均使用了C類地址作為網絡地址,Router1的E0的網絡地址為,掩碼為, Router2的E0的網絡地址為,掩碼為,這樣就將一個C類網絡地址分配給了二個網,既劃分了二個子網,起到了節約地址的作用。
4. 使用網絡地址翻譯(NAT)
NAT(Network Address Translation)起到將內部私有地址翻譯成外部合法的全局地址的功能,它使得不具有合法IP地址的用户可以通過NAT訪問到外部Internet.
當建立內部網的時候,建議使用以下地址組用於主機,這些地址是由Network Working Group(RFC 1918)保留用於私有網絡地址分配的.
l Class A: to
l Class B: to
l Class C: to
命令描述如下:
任務 | 命令 |
定義一個標準訪問列表 | access-list access-list-number permit source[source-wildcard] |
定義一個全局地址池 | ip nat pool name start-ip end-ip {netmask netmask | prefix-length prefix-length} [type rotary] |
建立動態地址翻譯 | ip nat inside source {list {access-list-number | name} pool name [overload] | static local-ip global-ip} |
指定內部和外部端口 | ip nat {inside | outside} |
路由器的Ethernet 0端口為inside端口,即此端口連接內部網絡,並且此端口所連接的網絡應該被翻譯,Serial 0端口為outside端口,其擁有合法IP地址(由NIC或服務提供商所分配的合法的IP地址),來自網絡的主機將從IP地址池c2501中選擇一個地址作為自己的合法地址,經由Serial 0口訪問Internet。命令ip nat inside source list 2 pool c2501 overload中的參數overload,將允許多個內部地址使用相同的全局地址(一個合法IP地址,它是由NIC或服務提供商所分配的地址)。命令ip nat pool c2501 netmask 定義了全局地址的範圍。
設置如下:
ip nat pool c2501 netmask
interface Ethernet 0
ip address
ip nat inside
!
interface Serial 0
ip address
ip nat outside
!
ip route Serial 0
access-list 2 permit
! Dynamic NAT
!
ip nat inside source list 2 pool c2501 overload
line console 0
exec-timeout 0 0
!
line vty 0 4
end
六、配置靜態路由
通過配置靜態路由,用户可以人為地指定對某一網絡訪問時所要經過的路徑,在網絡結構比較簡單,且一般到達某一網絡所經過的路徑唯一的情況下采用靜態路由。
任務 | 命令 |
建立靜態路由 | ip routeprefix mask {address | interface}[distance][tagtag] [permanent] |
mask :子網掩碼
address :下一個跳的IP地址,即相鄰路由器的端口地址。
interface :本地網絡接口
distance :管理距離(可選)
tag tag :tag值(可選)
permanent :指定此路由即使該端口關掉也不被移掉。
Router1:
ip route
Router3:
ip route
ip route
同時由於路由器Router3除了與路由器Router2相連外,不再與其他路由器相連,所以也可以為它賦予一條默認路由以代替以上的二條靜態路由,
ip route
即只要沒有在路由表裏找到去特定目的地址的路徑,則數據均被路由到地址為的相鄰路由器。