進入設置對話過程后,路由器首先會顯示一些提示信息: --- 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 ’[]’.
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
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) 是否設置異步口上的其它協議。
接下來,系統會對每個接口進行參數的設置。 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 $W5Oh$p6J7tIgRMBOIKVXVG53Uh1 enable password pass …………
Router# show controllers e1 e1 0/0 is up. Applique type is Channelized E1 - unbalanced Framing is CRC4, Line Code is HDB3 No alarms detected. Data in current interval (725 seconds elapsed): 0 Line Code Violations, 0 Path Code Violations 0 Slip Secs, 0 Fr Loss Secs, 0 Line Err Secs, 0 Degraded Mins 0 Errored Secs, 0 Bursty Err Secs, 0 Severely Err Secs, 0 Unavail Secs Total Data (last 24 hours) 0 Line Code Violations, 0 Path Code Violations,
以下例子為E1連接3條64K專線, 幀類型為NO-CRC4,非平衡鏈路,路由器具體設置如下: shanxi#wri t Building configuration...
Current configuration: ! version 11.2 no service udp-small-servers no service tcp-small-servers ! hostname shanxi ! enable secret 5 $1$XN08$Ttr8nfLoP9.2RgZhcBzkk/ enable password shanxi ! ! ip subnet-zero ! controller E1 0 framing NO-CRC4 channel-group 0 timeslots 1 channel-group 1 timeslots 2 channel-group 2 timeslots 3 ! interface Ethernet0 ip address 133.118.40.1 255.255.0.0 media-type 10BaseT ! interface Ethernet1 no ip address shutdown ! interface Serial0:0 ip address 202.119.96.1 255.255.255.252 no ip mroute-cache ! interface Serial0:1 ip address 202.119.96.5 255.255.255.252 no ip mroute-cache ! interface Serial0:2 ip address 202.119.96.9 255.255.255.252 no ip mroute-cache ! no ip classless ip route 133.210.40.0 255.255.255.0 Serial0:0 ip route 133.210.41.0 255.255.255.0 Serial0:1 ip route 133.210.42.0 255.255.255.0 Serial0:2 ! line con 0 line aux 0 line vty 0 4 password shanxi login ! end
二、PPP
PPP(Point-to-Point Protocol)是SLIP(Serial Line IP protocol)的繼續者,它提供了跨過同步和異步電路實現路由器到路由器(router-to-router)和主機到網絡(host-to-network)的連接。
3. 幀中繼point to point配置實例: Router1: interface serial 0 encapsulation frame-relay ! interface serial 0.1 point-to-point ip address 172.16.1.1 255.255.255.0 frame-reply interface-dlci 105 ! interface serial 0.2 point-to-point ip address 172.16.2.1 255.255.255.0 frame-reply interface-dlci 102 ! interface serial 0.3 point-to-point ip address 172.16.4.1 255.255.255.0 frame-reply interface-dlci 104 ! Router2: interface serial 0 encapsulation frame-relay ! interface serial 0.1 point-to-point ip address 172.16.2.2 255.255.255.0 frame-reply interface-dlci 201 ! interface serial 0.2 point-to-point ip address 172.16.3.1 255.255.255.0 frame-reply interface-dlci 203 ! 相關調試命令: show frame-relay lmi show frame-relay map show frame-relay pvc show frame-relay route show interfaces serial go top 4. 幀中繼 Multipoint 配置實例:
Router1: interface serial 0 encapsulation frame-reply ! interface serial 0.1 multipoint ip address 172.16.1.2 255.255.255.0 frame-reply map ip 172.16.1.1 201 broadcast frame-reply map ip 172.16.1.3 301 broadcast frame-reply map ip 172.16.1.4 401 broadcast ! Router2: interface serial 0 encapsulation frame-reply ! interface serial 0.1 multipoint ip address 172.16.1.1 255.255.255.0 frame-reply map ip 172.16.1.2 102 broadcast frame-reply map ip 172.16.1.3 102 broadcast frame-reply map ip 172.16.1.4 102 broadcast !
四、常用命令
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的備份和升級
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用于廣播
定義一個全局地址池 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
顯示ISDN有關信息 show isdn {active history memory services status [dsl interface-type number] timers}
注:1.交換機類型如下表,國內交換機一般為basic-net3。
按區域分要害字 交換機類型
Australia basic-ts013 Australian TS013 switches Europe basic-1tr6 German 1TR6 ISDN switches basic-nwnet3 Norway NET3 switches (phase 1) basic-net3 NET3 ISDN switches (UK, Denmark, and other nations); covers the Euro-ISDN E-DSS1 signalling system primary-net5 NET5 switches (UK and Europe) vn2 French VN2 ISDN switches vn3 French VN3 ISDN switches Japan ntt Japanese NTT ISDN switches primary-ntt Japanese ISDN PRI switches North America basic-5ess AT&T basic rate switches basic-dms100 NT DMS-100 basic rate switches basic-ni1 National ISDN-1 switches primary-4ess AT&T 4ESS switch type for the U.S. (ISDN PRI only) primary-5ess AT&T 5ESS switch type for the U.S. (ISDN PRI only) primary-dms100 NT DMS-100 switch type for the U.S. (ISDN PRI only) New Zealand basic-nznet3 New Zealand Net3 switches 3. ISDN實現DDR(dial-on-demand routing)實例: 設置如下: Router1: hostname router1 user router2 password cisco ! isdn switch-type basic-net3 ! interface bri 0 ip address 192.200.10.1 255.255.255.0 encapsulation ppp dialer map ip 192.200.10.2 name router2 572 dialer load-threshold 80 ppp multilink dialer-group 1 ppp authentication chap ! dialer-list 1 protocol ip permit !
Router2: hostname router2 user router1 password cisco ! isdn switch-type basic-net3 ! interface bri 0 ip address 192.200.10.2 255.255.255.0 encapsulation ppp dialer map ip 192.200.10.1 name router1 571 dialer load-threshold 80 ppp multilink dialer-group 1
ppp authentication chap ! dialer-list 1 protocol ip permit ! Cisco路由器同時支持回撥功能,我們將路由器Router1作為Callback Server,Router2作為Callback Client。
與回撥相關命令:
任務 命令
映射協議地址和電話號碼,并在接口上使用在全局模式下定義的PPP回撥的映射類別。 dialer map protocol address name hostname class classname dial-string
設置如下: Router1: hostname router1 user router2 password cisco ! isdn switch-type basic-net3 ! interface bri 0 ip address 192.200.10.1 255.255.255.0 encapsulation ppp dialer map ip 192.200.10.2 name router2 class s3 572 dialer load-threshold 80 ppp callback accept ppp multilink dialer-group 1 ppp authentication chap ! map-class dialer s3 dialer callback-server username dialer-list 1 protocol ip permit ! Router2: hostname router2 user router1 password cisco ! isdn switch-type basic-net3 ! interface bri 0 ip address 192.200.10.2 255.255.255.0 encapsulation ppp dialer map ip 192.200.10.1 name router1 571 dialer load-threshold 80 ppp callback request ppp multilink dialer-group 1 ppp authentication chap ! dialer-list 1 protocol ip permit ! 相關調試命令: debug dialer debug isdn event debug isdn q921 debug isdn q931 debug ppp authentication debug ppp error debug ppp negotiation debug ppp packet show dialer show isdn status 舉例:執行debug dialer命令觀察router2呼叫router1,router1回撥router2的過程. router1#debug dialer router2#ping 192.200.10.1
router1# 00:03:50: %LINK-3-UPDOWN: Interface BRI0:1, changed state to up 00:03:50: BRI0:1PP callback Callback server starting to router2 572 00:03:50: BRI0:1: disconnecting call 00:03:50: %LINK-3-UPDOWN: Interface BRI0:1, changed state to down 00:03:50: BRI0:1: disconnecting call 00:03:50: BRI0:1: disconnecting call 00:03:51: %LINK-3-UPDOWN: Interface BRI0:2, changed state to up 00:03:52: callback to router2 already started 00:03:52: BRI0:2: disconnecting call
00:03:52: %LINK-3-UPDOWN: Interface BRI0:2, changed state to down 00:03:52: BRI0:2: disconnecting call 00:03:52: BRI0:2: disconnecting call 00:04:05: : Callback timer eXPired 00:04:05: BRI0:beginning callback to router2 572 00:04:05: BRI0: Attempting to dial 572 00:04:05: Freeing callback to router2 572 00:04:05: %LINK-3-UPDOWN: Interface BRI0:1, changed state to up 00:04:05: BRI0:1: No callback negotiated 00:04:05: %LINK-3-UPDOWN: Interface Virtual-Access1, changed state to up 00:04:05: dialer Protocol up for Vi1 00:04:06: %LINEPROTO-5-UPDOWN: Line protocol on Interface BRI0:1, changed state to up 00:04:06: %LINEPROTO-5-UPDOWN: Line protocol on Interface Virtual-Access1, chang ed state to up 00:04:11: %ISDN-6-CONNECT: Interface BRI0:1 is now connected to 572 #router1
設定登錄263的用戶名和口令 ppp pap sent-username 263 password 263
設定默認路由 ip route 0.0.0.0 0.0.0.0 bri 0
設定符合訪問列表2的所有源地址被翻譯為bri 0所擁有的地址 ip nat inside source list 2 interface bri 0 overload
設定訪問列表2,答應所有協議 access-list 2 permit any
具體配置如下:
hostname Cisco2503 ! isdn switch-type basic-net3 ! ip subnet-zero no ip domain-lookup ip routing ! interface Ethernet 0 ip address 10.0.0.1 255.255.255.0 ip nat inside no shutdown ! interface Serial 0 shutdown no description no ip address ! interface Serial 1 shutdown no description no ip address ! interface bri 0 ip address negotiated ip nat outside encapsulation ppp ppp authentication pap callin ppp multilink dialer-group 1 dialer hold-queue 10
dialer string 2633 dialer idle-timeout 120 ppp pap sent-username 263 password 263 no cdp enable no ip split-horizon no shutdown ! ip classless ! ! Static Routes ! ip route 0.0.0.0 0.0.0.0 bri 0 ! ! Access Control List 2 ! access-list 2 permit any ! dialer-list 1 protocol ip permit ! ! Dynamic NAT ! ip nat inside source list 2 interface bri 0 overload snmp-server community public ro ! line console 0 exec-timeout 0 0 ! line vty 0 4 ! end
〉set system c765 c765〉 set multidestination on c765〉 set switch net3 c765〉 set ppp multilink on c765〉 cd lan c765:LAN〉 set ip routing on c765:LAN〉 set ip address 10.0.0.1 c765:LAN〉 set ip netmask 255.0.0.0 c765:LAN〉 set briding off c765:LAN〉cd c765〉 set user remotenet New user remotenet being created c765:remotenet〉 set ip routing on c765:remotenet〉 set bridging off c765:remotenet〉 set ip framing none c765:remotenet〉 set ppp clientname 263 c765:remotenet〉 set ppp password client Enter new Password: 263 Re-Type new Password: 263 c765:remotenet〉 set ppp authentication out none c765:remotenet〉 set ip address 0.0.0.0 c765:remotenet〉 set ip netmask 0.0.0.0 c765:remotenet〉 set ppp address negotiation local on c765:remotenet〉 set ip pat on c765:remotenet〉 set ip route destination 0.0.0.0/0 gateway 0.0.0.0 c765:remotenet〉 set number 2633 c765:remotenet〉 set active
命令描述如下:
任務 命令 設置路由器系統名稱 set system c765
答應路由器呼叫多個目的地 set multidestination on
設置ISDN交換機類型為NET3 set switch net3
答應點到點間多條通道連接實現負載均衡 set ppp multilink on
關掉橋接 set briding off
建立用戶預制文件用于設置撥號連接參數- 可以設置多個用戶預制文件用于相同的物理端口對應于不同的連接。 set user remotenet
使用PPP/IPCP set ip framing none
設置上網用戶帳號 set ppp clientname 263
設置上網口令 set ppp password client Enter new Password: 263 Re-Type new Password: 263
不用PPP/CHAP或PAP做認證 set ppp authentication out none
答應地址磋商 set ppp address negotiation local on
設置地址翻譯 set ip pat on
設置默認路由 set ip route destination 0.0.0.0/0 gateway 0.0.0.0
Router: hostname Router enable secret 5 $1$EFqU$tYLJLrynNUKzE4bx6fmH// ! interface Ethernet0 ip address 10.111.4.20 255.255.255.0 ! interface Async1 ip unnumbered Ethernet0 encapsulation ppp keepalive 10 async mode interactive peer default ip address pool Cisco2511-Group-142 ! ip local pool Cisco2511-Group-142 10.111.4.21 10.111.4.36 ! line con 0 exec-timeout 0 0 password cisco ! line 1 16 modem InOut modem autoconfigure discovery flowcontrol hardware ! line aux 0 transport input all line vty 0 4 password cisco ! end
hostname c2522rb ! enable secret 5 $1$J5vn$ceYDe2FwPhrZi6qsIIz6g0 enable password cisco ! username c4700 password 0 cisco ip subnet-zero chat-script cisco-default ““ “AT“ TIMEOUT 30 OK “ATDT /T“ TIMEOUT 30 CONNECT /c chat-script reset atz ! interface Ethernet0 ip address 16.122.51.254 255.255.255.0 no ip mroute-cache ! interface Serial0 backup delay 10 10 backup interface Serial2 ip address 16.250.123.18 255.255.255.252 no ip mroute-cache no fair-queue ! interface Serial1 no ip address no ip mroute-cache shutdown ! interface Serial2 physical-layer async ip address 16.249.123.18 255.255.255.252 encapsulation ppp async mode dedicated dialer in-band dialer idle-timeout 60 dialer map ip 16.249.123.17 name c4700 6825179 dialer-group 1 ppp authentication chap ! interface Serial3 no ip address shutdown no cdp enable ! interface Serial4 no ip address shutdown no cdp enable ! interface Serial5 no ip address no ip mroute-cache shutdown ! interface Serial6 no ip address no ip mroute-cache shutdown ! interface Serial7 no ip address no ip mroute-cache shutdown ! interface Serial8 no ip address no ip mroute-cache shutdown ! interface Serial9 no ip address no ip mroute-cache shutdown ! interface BRI0 no ip address no ip mroute-cache shutdown ! router eigrp 200 network 16.0.0.0 ! ip classless ! dialer-list 1 protocol ip permit ! line con 0 line 2 script dialer cisco-default script reset reset modem InOut modem autoconfigure discovery rxspeed 38400 txspeed 38400 flowcontrol hardware line aux 0 line vty 0 4 password cisco login ! end c2522rb#
ip subnet-zero chat-script cisco-default ““ “AT“ TIMEOUT 30 OK “ATDT /T“ TIMEOUT 30 CONNECT /c chat-script reset atz interface Ethernet0 ip address 202.96.38.100 255.255.255.0 ! interface Serial0 ip address 202.96.0.1 255.255.255.0 encapsulation x25 x25 address 10112227 x25 htc 16 x25 map ip 202.96.0.2 10112225 broadcast ! interface Serial1 no ip address shutdown ! ! interface Async 1 ip address 202.96.1.1 255.255.255.252 encapsulation ppp dialer in-band dialer idle-timeout 60 dialer map ip 202.96.1.2 name router2 modem-script cisco-default 2113470 dialer-group 1 ppp authentication chap ! router eigrp 200 redistribute connected network 202.96.0.0 ! ip route 202.96.37.0 255.255.255.0 202.96.1.2 200 dialer-list 1 protocol ip permit line con 0 line aux 0 script dialer cisco-default script reset reset modem InOut modem autoconfigure discovery transport input all rxspeed 38400 txspeed 38400 flowcontrol hardware line vty 0 4 password cisco login ! end
路由器Router2配置如下: hostname router2 ! enable secret 5 $1$T4IU$2cIqak8f/E4Ug6dLT0k.J0 enable password cisco ! username router1 password cisco ip subnet-zero chat-script cisco-default ““ “AT“ TIMEOUT 30 OK “ATDT /T“ TIMEOUT 30 CONNECT /c chat-script reset atz ! interface Ethernet0 ip address 202.96.37.100 255.255.255.0 ! interface Serial0 ip address 202.96.0.2 255.255.255.0 no ip mroute-cache encapsulation x25 x25 address 10112225 x25 htc 16 x25 map ip 202.96.0.1 10112227 broadcast ! interface Serial1 no ip address shutdown ! interface Async1 ip address 202.96.1.2 255.255.255.252 encapsulation ppp keepalive 30 async default routing async mode dedicated dialer in-band dialer idle-timeout 60 dialer wait-for-carrier-time 120 dialer map ip 202.96.1.1 name router1 modem-script cisco-default 2113469 dialer-group 1 ppp authentication chap ! router eigrp 200 redistribute static network 202.96.0.0 ! no ip classless ip route 202.96.38.0 255.255.255.0 202.96.1.1 200
dialer-list 1 protocol ip permit ! line con 0 exec-timeout 0 0 line aux 0 script reset reset modem InOut modem autoconfigure discovery transport input all rxspeed 38400 txspeed 38400 flowcontrol hardware line vty 0 4 password cisco login ! end
九、路由協議
(一)RIP協議
RIP(Routing information Protocol)是應用較早、使用較普遍的內部網關協議(Interior Gateway Protocol,簡稱IGP),適用于小型同類網絡,是典型的距離向量(distance-vector)協議。文檔見RFC1058、RFC1723。