CISCO 2811 路由器配置命令全集

xsdan發表於2009-09-03
命令狀態
1. router>
路由器處於使用者命令狀態,這時使用者可以看路由器的連線狀態,訪問其它網路和主機,但不能看到和更改路由器的設定內容。[@more@]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命令也可進入此狀態,這時可透過對話方式對路由器進行設定。

三、設定對話過程
1. 顯示提示資訊
2. 全域性引數的設定
3. 介面引數的設定
4. 顯示結果
利用設定對話過程可以避免手工輸入命令的煩瑣,但它還不能完全代替手工設定,一些特殊的設定還必須透過手工輸入的方式完成。
進入設定對話過程後,路由器首先會顯示一些提示資訊:
--- 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
是否使用TCP頭壓縮:
Configure for TCP Header Compression? [yes]:
9) 是否在非同步口上使用路由表更新:
Configure for routing updates on async links? [no]: y
10) 是否設定非同步口上的其它協議。
接下來,系統會對每個介面進行引數的設定。
1.Configuring interface Ethernet0:
1) 是否使用此介面:
Is this interface in use? [yes]:
2) 是否設定此介面的IP引數:
Configure IP on this interface? [yes]:
3) 設定介面的IP地址:
IP address for this interface: 192.168.162.2
4) 設定介面的IP子網掩碼:
Number of bits in subnet field [0]:
Class C network is 192.168.162.0, 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
進入埠設定狀態 interface type slot/number
進入子埠設定狀態 interface type number.subinterface [point-to-point | multipoint]
進入線路設定狀態 line type slot/number
進入路由設定狀態 router protocol
退出區域性設定狀態 exit
3. 顯示命令
任務 命令
檢視版本及引導資訊 show version
檢視執行設定 show running-config
檢視開機設定 show startup-config
顯示埠資訊 show interface type slot/number
顯示路由資訊 show ip router
4. 複製命令
用於IOS及CONFIG的備份和升級

5. 網路命令
任務 命令
登入遠端主機 telnet hostname|IP address
網路偵測 ping hostname|IP address
路由跟蹤 trace hostname|IP address

6. 基本設定命令
任務 命令
全域性設定 config terminal
設定訪問使用者及密碼 username username password password
設定特權密碼 enable secret password
設定路由器名 hostname name
設定靜態路由 ip route destination subnet-mask next-hop
啟動IP路由 ip routing
啟動IPX路由 ipx routing
埠設定 interface type slot/number
設定IP地址 ip address address subnet-mask
設定IPX網路 ipx network network
啟用埠 no shutdown
物理線路設定 line type number
啟動登入程式 login [local|tacacs server]
設定登入密碼 password password


五、配置IP定址

1. IP地址分類
IP地址分為網路地址和主機地址二個部分,A類地址前8位為網路地址,後24位為主機地址,B類地址16位為網路地址,後16位為主機地址,C類地址前24位為網路地址,後8位為主機地址,網路地址範圍如下表所示:
種類 網路地址範圍
A 1.0.0.0 到126.0.0.0有效 0.0.0.0 和127.0.0.0保留
B 128.1.0.0到191.254.0.0有效 128.0.0.0和191.255.0.0保留
C 192.0.1.0 到223.255.254.0有效 192.0.0.0和223.255.255.0保留
D 224.0.0.0到239.255.255.255用於多點廣播
E 240.0.0.0到255.255.255.254保留 255.255.255.255用於廣播
2. 分配介面IP地址
任務 命令
介面設定 interface type slot/number
為介面設定IP地址 ip address ip-address mask
掩瑪(mask)用於識別IP地址中的網路地址位數,IP地址(ip-address)和掩碼(mask)相與即得到網路地址。
3. 使用可變長的子網掩碼
透過使用可變長的子網掩碼可以讓位於不同介面的同一網路編號的網路使用不同的掩碼,這樣可以節省IP地址,充分利用有效的IP地址空間。
如下圖所示:
Router1和Router2的E0埠均使用了C類地址192.1.0.0作為網路地址,Router1的E0的網路地址為192.1.0.128,掩碼為255.255.255.192, Router2的E0的網路地址為192.1.0.64,掩碼為255.255.255.192,這樣就將一個C類網路地址分配給了二個網,既劃分了二個子網,起到了節約地址的作用。
4. 使用網路地址翻譯(NAT)
NAT(Network Address Translation)起到將內部私有地址翻譯成外部合法的全域性地址的功能,它使得不具有合法IP地址的使用者可以透過NAT訪問到外部Internet.
當建立內部網的時候,建議使用以下地址組用於主機,這些地址是由Network Working Group(RFC 1918)保留用於私有網路地址分配的.
l Class A:10.1.1.1 to 10.254.254.254
l Class B:172.16.1.1 to 172.31.254.254
l Class C:192.168.1.1 to 192.168.254.254
命令描述如下:
任務 命令
定義一個標準訪問列表 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地址),來自網路10.1.1.0/24的主機將從IP地址池c2501中選擇一個地址作為自己的合法地址,經由Serial 0口訪問Internet。命令ip nat inside source list 2 pool c2501 overload中的引數overload,將允許多個內部地址使用相同的全域性地址(一個合法IP地址,它是由NIC或服務提供商所分配的地址)。命令ip nat pool c2501 202.96.38.1 202.96.38.62 netmask 255.255.255.192定義了全域性地址的範圍。
設定如下:
ip nat pool c2501 202.96.38.1 202.96.38.62 netmask 255.255.255.192
interface Ethernet 0
ip address 10.1.1.1 255.255.255.0
ip nat inside
!
interface Serial 0
ip address 202.200.10.5 255.255.255.252
ip nat outside
!
ip route 0.0.0.0 0.0.0.0 Serial 0
access-list 2 permit 10.0.0.0 0.0.0.255
! Dynamic NAT
!
ip nat inside source list 2 pool c2501 overload
line console 0
exec-timeout 0 0
!
line vty 0 4
end

六、配置靜態路由
透過配置靜態路由,使用者可以人為地指定對某一網路訪問時所要經過的路徑,在網路結構比較簡單,且一般到達某一網路所經過的路徑唯一的情況下采用靜態路由。
任務 命令
建立靜態路由 ip route prefix mask {address | interface} [distance] [tag tag] [permanent]
Prefix :所要到達的目的網路
mask :子網掩碼
address :下一個跳的IP地址,即相鄰路由器的埠地址。
interface :本地網路介面
distance :管理距離(可選)
tag tag :tag值(可選)
permanent :指定此路由即使該埠關掉也不被移掉。

以下在Router1上設定了訪問192.1.0.64/26這個網下一跳地址為192.200.10.6,即當有目的地址屬於192.1.0.64/26的網路範圍的資料包,應將其路由到地址為192.200.10.6的相鄰路由器。在Router3上設定了訪問192.1.0.128/26及192.200.10.4/30這二個網下一跳地址為192.1.0.65。由於在Router1上埠Serial 0地址為192.200.10.5,192.200.10.4/30這個網屬於直連的網,已經存在訪問192.200.10.4/30的路徑,所以不需要在Router1上新增靜態路由。
Router1:
ip route 192.1.0.64 255.255.255.192 192.200.10.6
Router3:
ip route 192.1.0.128 255.255.255.192 192.1.0.65
ip route 192.200.10.4 255.255.255.252 192.1.0.65
同時由於路由器Router3除了與路由器Router2相連外,不再與其他路由器相連,所以也可以為它賦予一條預設路由以代替以上的二條靜態路由,
ip route 0.0.0.0 0.0.0.0 192.1.0.65
即只要沒有在路由表裡找到去特定目的地址的路徑,則資料均被路由到地址為192.1.0.65的相鄰路由器。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/262387/viewspace-1026595/,如需轉載,請註明出處,否則將追究法律責任。

相關文章