CCNA

 

1、  定義網絡組件redis

    Cisco對網絡分爲三層:核心層、分佈層、訪問層算法

1.核心層:鏈接服務器,利用三層或多層交換設備。 數據庫

功能:高速傳輸數據緩存

2.分佈層:對網絡提供策略,通常由路由器來承擔。安全

        功能:服務器

3.訪問層:通常由二層交換機來擔當網絡

2、  幾個名詞解釋app

1.ISO:國際標準化組織        OSI:開放系統互聯參考模型負載均衡

2.IEEE:電子電器工程師協會dom

3.ANSI:美國國家標準化協會

4.EIA/TIA:電子工業聯合會/通訊工業聯合會

5.ITU:國際通訊聯盟

6.IETF:Internet工程任務組

3、OSI模式概述

(一)應用層(高三層的統一名):應用層、表示層、會話層

1.應用層(Application  Layer):提供應用服務

        相關協議:Telnet(23) 遠程登陸

                  Smtp(25) 簡單郵件管理協議

                  Http(80) 超文本傳輸協議

                  Https(443) 增強超文本傳輸協議(通常用於銀行等保密性部門)

                  Ftp(21/20)  文件傳輸協議   21端口:數據傳輸      20端口:數據控制

                  Snmp(161/162) 簡單網絡管理協議

                  Pop3(110) 郵件協議

                  Dns(53) 域名解析

                  RIP(520) 路由信息協議

2.表示層(Presentation  Layer):數據的表示、加密/解密、壓縮/解壓縮

3.會話層(Session  Layer):會話的創建、保持、終止

(二)數據流層(下四層):規定如何創建鏈接,如何傳輸數據。

分爲:物理層、數據鏈路層、網絡層、傳輸層

1.物理層(Physical  Layer定義一些物理規範 如:線纜的規則,傳輸速率等。

          T1=1.544Mbps            E1=2.048Mbps

 (1)設備:集線器(HUB)、中繼器

 (2)協議:CSMA/CD  載波偵聽多路訪問/衝突檢測

 (3)標準:IEEE 802.3u   快速以太網

            IEEE 802.3ab  吉比特以太網(雙絞線)

            IEEE 802.3z   吉比特以太網(光纖)

            IEEE 802.3ae  10G比特以太網

 (4)HUB特色:全部端口都處於同一廣播域和衝突域,共享同一帶寬。

(5)PDU(協議數據單元):比特

 

2.數據鏈路層(Data link  Layer

  (1)設備:交換機(Switch)、網橋、網卡

  (2)標準:IEEE 802.3    IEEE 802.2

  (3)組成:LLC:邏輯鏈路控制(向上)           MAC:介質訪問控制(向下)

前導符(8)

目標地址(6)

源地址(6)

長度(2)

數據(變長)

FCS

 

  (4)特色:尋址,錯誤檢測但不提供錯誤恢復,幀校驗,幀標記(主要指MAC子層)

  (5)協議:HDLC 高級數據鏈路控制             幀標記:0000  Ehternet  以太網

             ATM  異步傳輸模式                         0001  Token Ring  令牌環網 

             Framerelay:幀中繼                        0010  FDDI 光纖分佈式數據接口

             PPP                                       0011  ATM  異步傳輸模式

(6)PDU(協議數據單元):幀

1、MAC(media access control)介質訪問控制:負責MAC地址尋址和定義介質訪問控制方法

  (1)標準:IEEE802.3

  (2)MAC地址:長48比特,用12位十六進制數表示。前24位爲廠商編碼,也成組織惟一標示

符(OUI)後24位爲廠商自行分配,一般是接口的序列號。

   2、LLC:邏輯鏈路控制

  (1)標準:IEEE802.2

  (2)組成:LLC1  LLC2

  (3)LLC幀有兩種:服務訪問點(SAP)和子網訪問點(SNAP)

   3、交換機特色:全部端口同在一個廣播域,每一個接口一個衝突域,獨佔一條帶寬。

3.網絡層(Network layer)

  (1)設備:路由器、三層交換機

  (2)特色:尋址、路由選路

  (3)PDU:包(packet)

(4)路由器特色:分割廣播域,每一個端口都是一個衝突域,獨佔一條帶寬。

  (5)路由器在選路時應該注意到:源IP、目標IP、可能有的路徑、最佳路徑、維護路由選擇信

息。

  (6)路由器在網絡層的功能:廣播信息控制;多點發送信息控制

4.傳輸層(Transport  Layer)

  (1)協議:TCP協議:面向連接,可靠,慢

UDP協議:面向無鏈接,不可靠,快

(2)功能:差錯恢復,流量控制(包括:緩存機制 buffering,避免擁塞congestion avoidance、窗

口機制windowing)

(3)PDU:分組(segment)

概念總結:1.衝突域:一組與同一條物理介質相鏈接的設備,其中任何兩臺設備同時訪問該介質

都將致使衝突。

2.廣播域:網絡中一組相互接收廣播消息的設備

3.PDU(協議數據單元):每一層使用本身層的協議和別的系統的對應層相互通訊,協議層的協議在

對等層交換的信息叫協議數據單元。

如下爲OSI各層的PDU表示:(1)上三層:message

                         (2)傳輸層(transport layer):分組(segment)

                         (3)網絡層(network layer):包(packet)

                         (4)數據鏈路層(data-link layer):幀(frame)

                         (5)物理層(physical layer):比特(bit)

 

OSI下四層小結

OSI模型各層設備:

(1)物理層:集線器:它轉發分組,用於將其餘網絡設備鏈接起來。與集線器鏈接的全部設備都屬

於一個網段,同在一個衝突域和廣播域。

(2)數據鏈路層:交換機、網橋,他們將網絡劃分紅多個網段,從而減小了每一個網段中的用戶數,

每一個網段是一個獨立的衝突域,並且與交換機或網橋鏈接的設備都同在一個廣播域。

(3)網絡層:路由器,它將網絡劃分紅多個衝突域和廣播域,所以一個端口就是一個衝突域。

4、實驗                                        

(一)基本配置

1.用戶模式進入特權模式

 Router>enable

 Router#

2.特權模式進入全局模式

 Router#config terminal

 Router(config)#

3.全局模式進入接口模式(如接口:f0/0)

 Router(config)#interface fastethernet 0/0

 Router(config-if)#

4.兩個退出命令

 (1)從特權模式退出到用戶模式

      Router#disable

 (2)從全局模式退出到特權模式

      快捷鍵:Ctrl+Z   

5.幾個實用命令(特權模式下)

  (1)清除配置:Router#erase startup-config         !清除

                 Router#reload                       !重啓設備

  (2)保存當前配置:Router#write terminal  === Router#copy running-config startup-config

  (3)提取保存前的配置:Router#copy startup-config running-config

  (4)給設備重命名(全局模式下):Router(config)#hostname rack01  

 !通常路由器命名爲rack0一、rack02……

                                  rack01(config)#

  (5)router(config)#default int s1/0   !將在接口上的配置還原成默認狀態

(二)設置密碼(全局配置模式下)

1.enable密碼

Router(config)#enable password ******         !設置明文密碼

Router(config)#enable secret ******           !設置密文密碼

注:在同時設置兩種密碼時,以secret密碼爲主。

2.Telnet密碼

Router(config)#line vty 0 4     !0 4 表示0,1,2,3,4 五個用戶

Router(config-line)#password ******     !設置密碼

Router(config-line)#login               !加載,保存

 例:遠程登陸(特權模式下)

  Router#telnet 192.168.1.1 (必須事先設置IP地址)

退出遠程登陸(特權模式下)

  Router#q

 

3.console密碼

Router(config)#line console 0     !console口通常只有一個所以爲0

Router(config-line)#password ******         !設置密碼

Router(config-line)#login                   !保存

(三)取消設置的密碼

1.取消enable密碼

Router(config)#no enable/secret password

2.取消telnet密碼

  Router(config)#line vty 0 4

  Router(config-line)#no password

3.取消console密碼

  Router(config)#line console 0

  Router(config-line)#no password

5、專業英語

1.model 模型                                  2.characteristics  特色

3.collision  domains衝突域                   4.broadcast domains  廣播域

5.encapsulation   封裝                        6.types 類型

7.flow control   流量控制                     8.rather than  而不是

9.destination address 目標地址                10.source address 源地址

11.frame  幀                                  12.packet  包

13.receives  收到                             14.appears  出現

15.requests 請求

 

次日課

1、路由選路

F1

                           
     
           
       
               
 
 

 

 

 

 

(1)PC1 1.1.100訪問PC2 4.4.4.100。

PC1把1.1.1.100作爲本身的源地址,把4.4.4.100作爲目標地址,而後封裝以太網格式,而且封裝裏面有本身的源MAC,這時發出廣播。

(2)PC1的數據包給了1.1.1.1網關,網關收到後檢查目標地址爲4.4.4.100,不是同一個網段,首

先檢查A路由器的路由表,發現4.4.4.100 B路由器知道。

(3)A路由器用本身的網關的MAC替換掉PC1的MAC,而後把包交給了2.2.2.1,2.2.2.1收到包,

而後用本身的MAC替換了1.1.1.1的MAC,並封裝HDLC的格式。

(4)2.2.2.1將包交給了2.2.2.2 ,收到後替換了2.2.2.1的MAC,而後查看B路由器的路由表,,而後轉發給3.3.3.1,3.3.3.1用本身的MAC來替換2.2.2.2,用幀中繼封裝這個包,而後把它傳給3.3.3.2

(5)此時3.3.3.32可收到數據包,收到數據包後,用本身的MAC替換了3.3.3.1的MAC,而後查看

C路由表,發現4.4.4.0網段爲本身的直連網段,路由表給了直鏈接口4.4.4.1,而後用4.4.4.1的封裝結構來封裝此數據包

(6)4.4.4.1 在本身的網段發送一個廣播,源爲4.4.4.1,4.4.4.100迴應, 4.4.4.100將本身的MAC送給了4.4.4.1,按源IP爲1.1.1.100原路返回傳給PC1。

2、IP地址

1.組成:網絡位和主機位

2.分類:A類,B類,C類,D類,E類

 

類 型            範圍                    二進制                 子網掩碼

A          1———126                0                255.0.0.0

B          128——191               10                255.255.0.0

C          192——223              110                255.255.255.0

D          224——239             1110                 用於組播

      E          240——254            11110                 用於實驗

1表明網絡位,0表明主機位。

     3.幾個特殊的IP地址

      (1)127.0.0.1        本地迴環測試(loopback)地址

      (2)255.255.255.255  廣播地址

      (3)IP地址0.0.0.0:表明任何網絡

(4)網絡號全爲0:表明本網絡或本網段   如:192.168.1.0/24
    (5)網絡號全爲1:表明全部的網絡

廣播地址TCP/IP協議規定,主機號部分各位全爲1的IP地址用於廣播。所謂廣播地址指同時向網上全部的主機發送報文,也就是說,無論物理網絡特性如何,Internet網支持廣播傳輸.如136.78.255.255就是B類地址中的一個廣播地址,你將信息送到此地址,就是將信息送給網絡號爲136.78的全部主機。有時須要在本網內廣播,但又不知道本網的網絡號時,TCP/IP協議規定32比特全爲1的IP地址用於本網廣播,即255.255.255.255

4.幾個私有地址(Private IP Address

私有IP地址(private IP address):節約了IP地址是空間,增長了安全性.處於私有IP地址的網絡稱爲內網,與外部進行通訊就必須靠網絡地址翻(network address translation,NAT)
一些私有地址的範圍:
     A類地址中:10.0.0.0到10.255.255.255

     B類地址中:172.16.0.0到172.31.255.255
     C類地址中:192.168.0.0到192.168.255.255

總結:當主機位全爲1時表明廣播,主機位全爲0時表明一個網段,此時的IP不可用。

 

1  0   0   0   0   0   0   0   =   128

1  1   0   0   0   0   0   0   =   192

1  1   1   0   0   0   0   0   =   224

1  1   1   1   0   0   0   0   =   240

1  1   1   1   1   0   0   0   =   248

1  1   1   1   1   1   0   0   =   252

1  1   1   1   1   1   1   0   =   254

1  1   1   1   1   1   1   1   =   255

 

 

 

3、子網的劃分

例1.

       60臺主機                                              70臺主機

                             R1     兩個接口    R2

 

要求:以192.199.1.1開始,並且60臺主機、兩個接口、70臺主機之間的IP地址不能相同。

題目:1.給出60臺主機的首地址和末地址

      2.給出兩個接口的IP地址

      3.給出70臺主機的首地址和末地址

      4.寫出以上三個的子網掩碼

1.步驟:

      (1)2(n)-2=60    因此:n=6

      (2)由於192.199.1.1爲C類地址,它的原子網掩碼爲255.255.255.0轉換爲二進制爲:

           11111111.11111111.11111111.00000000   由於N爲6即主機位爲6個0,其他0取反。此時子網掩碼爲:11111111.11111111.11111111.11000000=255.255.255.192

因此:60臺主機的IP範圍爲:192.199.1.0——192.199.1.63

      60臺主機的首IP爲:192.199.1.1      末IP爲:192.199.1.62

2.步驟:

      (1)2(n)-2=2     因此:n=2

         將255.255.255.0轉換爲二進制爲:

           11111111.11111111.11111111.00000000   由於N爲2即主機位爲2個0,其他0取反。

此時子網掩碼爲:11111111.11111111.11111111.11111100=255.255.255.254

因此:2個接口的IP範圍爲:192.199.1.64——192.199.1.67

      2個接口的IP爲:192.199.1.65   192.199.1.66

3.步驟:

      (1)2(n)-2=70    因此:n=7

255.255.255.0轉換爲二進制爲:

           11111111.11111111.11111111.00000000   由於N爲2即主機位爲7個0,其他0取反。

此時子網掩碼爲:11111111.11111111.11111111.10000000=255.255.255.128

因此70臺主機的IP地址範圍爲:192.199.1.128——192.199.1.255

                首IP爲:192.199.1.129              末IP爲:192.168.1.254

       
       

 

 

例2 192.168.1.0  24(網絡位爲24個1)                192.168.1.0  29

 

問:(1)有多少個子網?

   (2)主機數是多少?

   (3)第一個網段的首地址和末地址各是什麼?

   (4)最後一個網段的首地址和末地址各是什麼?

步驟:

  (1)子網=2(29-24)=32

  (2)主機=2(3)-2=6   即255.255.255.0轉換成二進制=11111111.11111111.11111111.00000000

由於要將24個1轉化爲29一個1,即將5個主機位轉化成5個網絡位,此時爲:

11111111. 11111111. 11111111.11111000=255.255.255.248(子網掩碼)

   (3)第一個網段首IP=192.168.1.1          末IP=192.168.1.6(主機)

        最後一個網段首IP=192.168.1.248      末IP=192.168.1.254

4、路由的彙總

【問題一】

有三個地址分別爲1.1.1.0/24,1.1.2.0/24,1.1.3.0/24,1.1.4.0/24,將其進行彙總。

【步驟】

 方法一:(1)將其轉換成二進制

1.1.1.0/24           1.1.00000 001.0

1.1.2.0/24           1.1.00000 010.0

1.1.3.0/24           1.1.00000 011.0

1.1.4.0/24           1.1.00000 100.0

             
       
     
 
     
 
 

 

 

(2)虛線標註出了相同處和不一樣處,算出相同處爲0,所以彙總地址爲1.1.0.0,而主機爲佔

用了三位,做爲網絡位數爲24-3=21

(3)最終結果爲1.1.0.0/21

【問題二】

 有三個地址分別爲1.1.9.0/24,1.1.11.0/24,1.1.13.0/24,將其進行彙總。

【步驟】

 方法一:(1)由9-13可知它們之間有5臺主機即2(n)-2>=5,因此得出n=3

        (2)如今看一下第一個子網的範圍爲:0-7

                       第二個子網的範圍爲:8-15(在這個範圍內能夠包括題名中的主機)

        (3)結果爲1.1.8.0/21(24-3)

方法二:二進制算法同上

【問題三】

有三個地址分別爲:138.16.195.6/24,138.16.239.1/24,138.16.240.7/24,138.16.253.8/24

將其進行彙總。

【步驟】

方法一:(1)由195-253能夠得出它們之間有59臺主機。所以2(6)能夠包含全部的主機

            那麼第一個子網的範圍爲:0-63;第二個子網的範圍爲:64-127;

                第三個子網的範圍爲:128-191;第四個子網的範圍爲:192-255(能夠包括)

        (2)從上面得出192-255這個網段能夠包含因此主機,192爲本網絡的網絡地址

        (3)從6,1,7,8能夠得出一個範圍爲0-7

        (4)得出最後的結果爲138.16.192.0/18(24-6)

方法二:算出二進制

5、實驗

1.幾個實用命令:

(1) 中止域名解析

  Route>en

Route#conf t

Rouet(config)# no ip domain-lookup

(2) 不容許第二條命令附加到前一條的尾部

Route>en

Route#conf t

Route(config)#line console 0

Route(config-line)#logging synchronous

(3)路由器長時間不使用也不退出到控制檯

Route>en

Route#conf t

Route(config)#line cons 0

Route(config-line)#exec-timeout 0 0

Router(config-line)#login    !加載  此時console口必須設置密碼

(4)修改寄存器的值:

0x2102 :工業默認值,從FLASH中啓動且從NVRAM中加載配置文件

0x2142 :從FLASH中啓動,但不使用NVRAM中的配置文件(用於口令恢復)

0x2101 :從Boot RAM中啓動,應用於更新系統文件

0x2141 :從Boot RAM中啓動,但不使用NVRAM中的配置文件

其中C位的第三位爲1時表示關閉Break鍵,反之表示打開Break鍵。

0x141:表示關閉Break鍵,不使用NVRAM中的配置文件,而且從系統默認的ROM中的系統中啓動。

0x0040:表示容許路由氣讀取NVRAM中的配置文件。

Route>en

Route#config ter

Route(config)#config-register 0x2102或0x2142或0x2101

(5)Router#clear ip route   !清理路由表信息

 (6)Router#show ip protocols     !查看當前所配置的IP協議

 (7)Router(config-if)#clock rate 6400  !設置某個端口的時鐘頻率

2.Show命令(特權模式下)

  Router#show running-config       !查看當前配置信息

  Router#show ip interface brief   !查看因此接口的配置信息

  Router#show ip interface f0/0    !查看如:f0/0接口的詳細信息

  Router#show ip route             !查看路由表信息

  Router#show controllers s0/0     !查看路由器某個S端口的時鐘頻率      

  Router#show ip route rip         !查看RIP的信息

  Router#show ip route igrp        !查看IGRP的信息

3.loopback接口   !路由器的環回測試接口

  Router(config)#interface loopback 0     !loopback後的值能夠任意

4.路由器的操做方式:經過Telnet訪問

                    超級終端          經常使用方式

                    經過HTTP(網頁)配置

5.路由器的啓動順序:(1)加電自檢,找flash,IOS操做系統

                   (2)當無IOS時,從TFTP軟件中調用

                   (3)當TFTP中也找不到,到NVRAM中尋找啓動

7.幾種配線所使用的線纜類型

(1)路由器的以太網E口與主機Rj45相鏈接用交叉線(crossover)

(2)路由器的配置:用的是console線(也叫反轉線:rollover),計算機端用的是9針COM口

(3)同種設備之間相連用交叉線,不一樣種設備之間用直通線(straight-through),而PC與PC之間能夠用交叉線也可用直通線。

(4)任何設備與集線器相連都是用交叉線,走的都是半雙工。

 

第三天課

1、路由

前言:每一個路由器在尋找路由時須要知道的五部分信息:1.目的地址  

2.源地址         

3.全部可能的路由路徑

                                                  4.最佳路由路徑

                                                  5.管理路由信息

兩個概念:1.路由協議(Routing Protocol): 本質是建立和維護路由表,可路由協議利用他實現路由功能 例如:RIP;IGRP;EIGRP;OSPF;BGP;IS-IS 等;

2.可路由協議( Routed Protocol) :利用網絡層完成通訊的協議,容許數據包從一個主機主機一尋址方案轉發到另外一主機。例如;IP;IPX;AppleTalk

1.分類:

靜態路由:由網絡管理員在路由器上手工添加路由信息以實現路由的目的。即手工配置

 

動態路由:根據網絡結構或流量的變化,路由協議會自動調整路由信息以實現路由。

即自動學習

(1)靜態路由:通常在小型網絡中事宜設置靜態路由

 實驗配置:Rack(config)#ip route network[mask]{address|interface}[distance][permanent]

 含義:ip route+一個網段(192.168.1.0)+掩碼+下一跳

       其中:network是網段,mask是掩碼

             下一跳:能夠是一個網絡地址也能夠是接口(如s0/0)

Eg:Rack(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1

         其中:192.168.1.0爲目標IP      192.168.2.1爲下一跳地址

 (2)浮動靜態路由:有備份做用,即當一條鏈路down掉時,另外一條鏈路即時起來。

(3)動態路由

內部網關協議(IGP)

RIP:路由信息協議

IGRP:

EIGRP

思科公司專有協議

 

 

OSPF:開放式最短路徑優先

IS-IS:自治系統—自治系統

分類:

外部網關協議(EGP):BGP(邊界網關協議)

 

註解:IS:被成爲自治系統,它是使用相同的路由準則的網絡的集合

      IGP:在一個自治系統內運行

2、關於路由的幾個問題

1.在如下狀況下路由表才更新:(1)網絡結構的改變將致使路由表的更新

                           (2)在下一個週期後路由器發送更新過的路由表給相鄰的路由器

2.路由迴環

(1)產生的緣由:因爲網絡的路由匯聚時間的存在,路由表中新的路由或更改的路由不可以很快在全網中穩定,使得有不一致的路由存在,因而會產生路由環。

(2)解決的方法:定義最大跳數:跳到16跳後再也不轉發信息

                 水平分割(horizon split):發出一條信息,再也不接收回答信息。

                 路由毒殺:路由器將路由信息(即down的路由信息)的跳數標記爲無限大

                 反轉毒殺:傳出去的消息(down的消息),若是再接收到了,那麼將其毒殺

計時器(Hold-Down Time):路由器在計時時間內將記錄標記爲Possibly down即一會UP一會Down

     當達到規定的時間後,若是還一會UP一會Down,那麼就永遠的down掉了。

觸發更新:當路由表發生變化時路由器當即向全網發送更新信息

3、RIP(路由信息協議)

 1.RIP計時器:       類型                               時間

(1)保持時間(Hold-down)             180秒

               (2)更新計時器(Update time)         30秒

               (3)無效計時器(Invalid time)        180秒

               (4)刷新計時器(Flush time)          240秒

2.RIP的特徵:

(1)是一種距離矢量路由協議

          (2)使用跳數做爲度量值來選擇路徑

          (3)容許的最大跳數爲15跳

          (4)管理距離(distance)爲:120   

             更改管理距離的方法:

Router(config-router)#diatance 120(此值可能夠隨意修改,最大值爲255)

                (5)發送的包是:更新包

3.RIP v1 和v2各自的特徵

1.RIPv1(version1):

(1)只能通告主類網絡號。每一個網絡只能使用一個子網掩碼;子網掩碼是定長的。

(2)不提供觸發更新;報文爲廣播報文,每30秒發送一次更新,發送目的地址255.255.255.255(本地廣播)。

(3)它是有類路由協議。更新時不發送子網掩碼信息,不支持VLSM(可變長子網掩碼)。(4)不支持路由認證。

(5)最多支持6條路徑的負載均衡(默認爲4條)

2.RIPv2:(1)容許使用VLSM。

(2)標準RIPv2支持觸發更新,RIPv2採用組播更新,報文發送到目的地址224.0.0.9(組播地址)

(3)它是無類路由協議

(4)支持明文和MD5的路由認證。

(5)V2版本向下兼容V1版本,即V1能夠收到V2的更新,V2收不到V1的更新

4. RIP路由表的表項的信息說明了什麼?

  RIP路由表的每個表項都提供了必定的信息,包括最終目的地址、到目的地的下一跳地址和度量值。這個度量值表示到目的終端的距離(跳步數)。其餘的信息也能夠包括。

4、幾個小知識

1.經常使用度量值

   HOP(跳)  bandwidth(帶寬)  delay(延遲)  load(加載)  reliability(可靠性)

Mtu(最大傳輸單元)  cost(開銷)

2.metric值(度量值):路由協議算法由度量得出度量值,根據度量值斷定路由最佳路由,來建立和維護路由表。

 3.收斂時間(convergence time):從網絡拓撲發生變化到網絡中全部路由器都知道這個變化的時 

間。   只有動態路由中才有收斂時間

4.默認的管理距離(distance):RIP=120    靜態路由:1   OSPF110       IS—IS115  

直連路由:0  內部EIGRP:90  外部EIGRP:170

 注:設置管理距離的範圍爲1-255,並且使用出站接口配置的靜態路由管理距離爲0,使用下一跳地址的爲1

5.靜態路由經常使用於將分組路由到末節網絡,而末節網絡是隻能經過一條路由才能到達的網絡。

5、實驗

 一.【實驗名稱】靜態路由的配置

【實驗設備】兩臺Cisco 7200系列路由器

【實驗目標】配置各路由器,最終1.1.1.1能夠Ping通2.2.2.2

S0/0

192.168.1.2

    【實驗拓撲】   

192.168.1.1

F0/0

R1     199.99.1.1

LOOP0

LOOP0                                                                                                                                                                                                                                                                                                                                                      

199.99.1.2        R2

2.2.2.2

1.1.1.1

 

【實驗步驟】

(一)設置R1和R2各端口的IP地址

1.設置R1各端口的IP地址

        (1)給R1的LOOP0端口設置IP

             rack01(config)#interface loop 0

             rack01(config)#ip address 1.1.1.1 255.255.255.0

        (2)給R1的S0/0端口設置IP

             rack01(config)#interface serial0/0

             rack01(config)#ip address 192.168.1.1 255.255.255.0

             rack01(config)#no shutdown

        (3)給R1的F0/0端口設置IP

             rack01(config)#interface fastethernet0/0

             rack01(config)#ip address 199.99.1.1 255.255.255.0

             rack01(config)#no shutdown

          2.設置R2各端口的IP地址

         (1)給R2的LOOP0設置IP

             rack02(config)#interface loop 0

             rack02(config)#ip address 2.2.2.2 255.255.255.0

         (2)給R2的S0/0設置IP

             rack02(config)#interface s0/0

             rack02(config)#ip address 192.168.1.2 255.255.255.0

             rack02(config)#no shutdown

         (3)給R2的F0/0端口設置IP

             rack02(config)#interface f0/0

             rack02(config)#ip address 199.99.1.2 255.255.255.0

             rack02(config)#no shutdown

         (二)設置R1和R2各靜態路由

          1.設置R1的靜態路由 即R1         R2

             rack01(config)#ip route 2.2.2.0 255.255.255.0 192.168.1.2

                     !設置R1目標地址2.2.2.0,S0/0端的下一跳地址192.168.1.2

             rack01(config)#ip route 2.2.2.0 255.255.255.0 199.99.1.2

                     !設置R1目標地址2.2.2.0,F0/0端的下一跳地址199.99.1.2

注:設置兩條鏈路的目的是使之達到負載均衡的目的

  2.設置缺省路由 即R2        R1

rack02(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.1   !S0/0端

rack02(config)#ip route 0.0.0.0 0.0.0.0 199.99.1.1    !F0/0端

注:其中0.0.0.0 0.0.0.0是默認靜態路由

更改管理距離(靜態路由默認的管理距離爲1):

(1)在R1上 (如改成150)  

rack01(config)#ip route 2.2.2.0 255.255.255.0 192.168.1.2 150(管理距離)

                    !更改S0/0端口的管理距離爲150

        rack01(config)#ip route 2.2.2.0 255.255.255.0 199.99.1.2

                            !F0/0端管理距離不變,默認爲1

注:這時當數據從R1到達R2時,就會只走F0/0端了,由於它的管理距離小於S0/0端。

但當F0/0端口被down掉時,S0/0端口即時起來。在這裏充當備份鏈路的角色。

 

二. 【實驗名稱】靜態路由的配置

【實驗設備】三臺Cisco 7200系列路由器

【實驗目標】配置各路由器,最終1.1.1.1能夠Ping通2.2.2.2

【實驗拓撲】

LOOP0

2.2.2.2

                         S1/0             199.99.2.1  S1/1    

199.99.1.2 

             R2  

                                                                       

199.99.2.2  

R3                                                                    

LOOP0

1.1.1.1       R1                                                          

 

 

【實驗步驟】(一)設置R1,R2和R3各個端口的IP地址

           1.設置R1的IP

           rack01(config)#interface loop 0

           rack01(config-if)#ip address 1.1.1.1 255.255.255.0

           rack01(config)#interface s1/0

           rack01(config-if)#ip address 199.99.1.1 255.255.255.0

           rack01(config-if)#no shut

          2.設置R2的IP

           rack02(config)#interface s1/0

           rack02(config-if)#ip address 199.99.1.2 255.255.255.0

           rack02(config-if)#no shut

           rack02(config)#interface s1/1

           rack02(config-if)#ip address 199.99.2.1 255.255.255.0

           rack02(configif)#no shut

          3.設置R3的IP

           Rack(config)#interface loop 0

           Rack(config-if)#ip address 2.2.2.2 255.255.255.0

           Rack(config)#interface s1/1

           Rack(config)#ip address 199.99.2.2 255.255.255.0

           Rack(config)#no shut

         (二)設置靜態路由

          1.設置R1上的靜態路由

           rack01(config)#ip route 199.99.2.0 255.255.255.0 199.99.1.2

           rack01(config)#ip route 2.2.2.0 255.255.255.0 199.99.1.2

          2.設置R2上的靜態路由

           rack02(config)#ip route 2.2.2.0 255.255.255.0 199.99.2.2

           rack02(config)#ip route 1.1.1.0 255.255.255.0 199.99.1.1

          3.設置R3上的靜態路由

           rack03(config)#ip route 0.0.0.0 0.0.0.0 199.99.2.1

3、【實驗名稱】配置RIP動態路由

【實驗設備】三臺Cisco 7200系列路由器,兩個LOOP迴環測試接口

【實驗目的】最終讓1.1.1.1能夠Ping通2.2.2.2

【實驗拓撲】

 

LOOP0

2.2.2.2

                         S1/0                199.99.2.1  S1/1  

199.99.1.2 

             R2  

                                                                       

199.99.2.2  

R3                                                                    

LOOP0

1.1.1.1       R1      

                                                  

【實驗步驟】(一)設置R1,R2和R3各個端口的IP地址

          1.設置R1的IP

           rack01(config)#interface loop 0

           rack01(config-if)#ip address 1.1.1.1 255.255.255.0

           rack01(config)#interface s1/0

           rack01(config-if)#ip address 199.99.1.1 255.255.255.0

           rack01(config-if)#no shut

          2.設置R2的IP

           rack02(config)#interface s1/0

           rack02(config-if)#ip address 199.99.1.2 255.255.255.0

           rack0k(config-if)#no shut

           rack02(config)#interface s1/1

           rack02(config-if)#ip address 199.99.2.1 255.255.255.0

           rack02(configif)#no shut

          3.設置R3的IP

           rack03(config)#interface loop 0

           rack03(config-if)#ip address 2.2.2.2 255.255.255.0

           rack03(config)#interface s1/1

           rack03(config)#ip address 199.99.2.2 255.255.255.0

           rack03(config)#no shut

          (二)在R1,R2和R3上設置RIP(此時的版本爲V1版本)

          1.R1上

           rack01(config)#router rip

           rack01(config-rack)#network 1.1.1.0

           rack01(config-rack)#network 199.99.1.0

          2.R2上

           rack02(config)#router rip

           rack02(config-rack)#network 199.99.1.0

           rack02(config-rack)#network 199.99.2.0

          3.R3上

           rack03(config)#router rip

           rack03(config-rack)#network 199.99.2.0

           rack03(config-rack)#network 2.2.2.0

 

4、【實驗名稱】靜態路由+動態路由(RIP)

【實驗設備】四臺Cisco 7200系列路由器,兩個LOOP接口

【實驗目標】在R1,R2,R3三臺路由器上設置RIP路由,即將這三臺路由器看做爲一個網絡。

          在R3和R4上設置靜態路由,使之最終R1——R4之間能夠互相Ping通。

【實驗拓撲】

 

LOOP0

1.1.1.1

LOOP0

2.2.2.2

S1/1

S1/2

192.168.1.2

192.168.2.1

R1

192.168.2.2

192.168.3.1

           192.168.1.1 S1/0

R2

R3

R4

192.168.3.2

 

【實驗步驟】(一)給R1,R2,R3,R4各端口設置IP地址

          1.設置R1的IP

           rack01(config)#interface loop 0

           rack01(config-if)#ip address 1.1.1.1 255.255.255.0

           rack01(config)#interface s1/0

           rack01(config-if)#ip address 192.168.1.1 255.255.255.0

           rack01(config-if)#no shut

          2.設置R2的IP

           rack02(config)#interface s1/0

           rack02(config-if)#ip address 192.168.1.2 255.255.255.0

           rack02(config-if)#no shut

           rack02(config)#interface s1/1

           rack02(config-if)#ip address 192.168.2.1 255.255.255.0

           rack02(configif)#no shut

          3.設置R3的IP

           rack03(config)#interface s1/1

           rack03(config-if)#ip address 192.168.3.1 255.255.255.0

           rack03(config-if)#no shut

           rack03(config)#interface s1/2

           rack03(config-if)#ip address 192.168.3.2 255.255.255.0

           rack03(configif)#no shut

          4.設置R4的IP

           rack04(config)#interface loop 0

           rack04(config-if)#ip address 2.2.2.2 255.255.255.0

           rack04(config)#interface s1/2

           rack04(config)#ip address 192.168.3.2 255.255.255.0

           rack04(config)#no shut

(二)給R1,R2,R3上設置RIP版本爲V2,並設置RIP

1.在R1上設置

 rack01(config)#router rip

rack01(config-router)#no auto-summary         !關閉自動彙總

rack01(config-router)#version 2               !選擇版本爲V2

rack01(config-router)#network 1.1.1.0         !宣告1.1.1.0網段

rack01(config-router)#network 192.168.1.0

          2.在R2上設置

 rack02(config)#router rip

rack02(config-router)#no auto-summary         !關閉自動彙總

rack02(config-router)#version 2               !選擇版本爲V2

rack02(config-router)#network 192.168.1.0         !宣告1.1.1.0網段

 rack02(config-router)#network 192.168.2.0

3.在R3上設置

 rack03(config)#router rip

rack03(config-router)#no auto-summary         !關閉自動彙總

rack03(config-router)#version 2               !選擇版本爲V2

rack03(config-router)#network 192.168.2.0         !宣告1.1.1.0網段

rack03(config)#ip route 0.0.0.0 0.0.0.0 192.168.3.2  !在設置R3設置靜態路由

注:通常狀況下還要宣告162.168.3.0網段,可是在這裏R3和R4之間設置靜態路由,所以不用宣告162.168.3.0網段

4.在R4上設置靜態路由

rack04(config)#ip route 0.0.0.0 0.0.0.0 192.168.3.1

注:由於R3與R4在不一樣的網絡內,所以R3與R4之間不知道準確的地址,因此設置爲缺省路由。

(三)路由再發布:只有在R3上再設置一條命令,R4才能Ping通R1,R2,R3,即路由的再發布)

           rack03(config)#router rip

           rack03(config-router)#redistribute static   

!在RIP中再發布一條靜態路由信息,讓R1和R2知道R4使用的是靜態路由

實驗結果:在R1和R2中show ip route 會出現R*這表示從外部學來的路由,S*表示缺省路由

Rack01#show ip route

1.0.0.0/24 is subnetted, 1 subnets

C       1.1.1.0 is directly connected, Loopback0

C    192.168.1.0/24 is directly connected, Serial1/0

R    192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:25, Serial1/0

R*   0.0.0.0/0 [120/2] via 192.168.1.2, 00:00:07, Serial1/0

 

     表示從外部學來的路由(在這裏經過R3知道了R4走的是靜態路由)

 

Rack03#show ip route

R    1.0.0.0/8 [120/2] via 192.168.2.1, 00:00:18, Serial1/1

R    192.168.1.0/24 [120/1] via 192.168.2.1, 00:00:18, Serial1/1

C    192.168.2.0/24 is directly connected, Serial1/1

C    192.168.3.0/24 is directly connected, Serial1/2

S*   0.0.0.0/0 [1/0] via 192.168.3.2

 

     表示缺省路由

注:加劇字體標記的數值表示各自的默認管理距離

 

 

 

 

 

 

 

 

5、【實驗名稱】靜態路由的負載均衡及浮動靜態路由

   【實驗設備】兩臺Cisco 7200系列路由器

 【實驗目標】利用靜態路由實現的負載均衡;

,        理解負載均衡的原理;,

理解負載均衡中數據傳輸的過程。

   【實驗拓撲】

           
     
       
   
 
 

 

 

 

 

 

  【實驗步驟】

              1.基本配置

              (1)在R1上設置

                  rack01(config)#int loop 0

rack01(config-if)#ip add 1.1.1.1 255.255.255.0

rack01(config-if)#int s1/0

rack01(config-if)#ip add 192.168.1.1 255.255.255.0

rack01(config-if)#no shut

rack01(config-if)#int s1/1

rack01(config-if)#ip add 192.168.2.1 255.255.255.0

rack01(config-if)#no shut

(2)在R2上設置

rack02(config)#int s1/0

rack02(config-if)#ip add 192.168.1.2 255.255.255.0

rack02(config-if)#no shut

rack02(config-if)#int s1/1

rack02(config-if)#ip add 192.168.2.2 255.255.255.0

rack02(config-if)#no shut

               2.設置靜態路由

                (1)在R1上設置

rack01(config)#ip route 2.2.2.0 255.255.255.0 192.168.1.2

rack01(config)#ip route 2.2.2.0 255.255.255.0 192.168.3.2

                (2)在R2上設置

rack02(config)#ip route 1.1.1.0 255.255.255.0 192.168.1.1

rack02(config)#ip route 2.2.2.0 255.255.255.0 192.168.2.2

                (3)在R3上設置

rack03(config)#ip route 1.1.1.0 255.255.255.0 192.168.2.1

rack03(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1

               3.查看結果(沒有設置負載的狀況下)

                 rack01#show ip route

Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route

 

Gateway of last resort is not set

 

     1.0.0.0/24 is subnetted, 1 subnets

C       1.1.1.0 is directly connected, Loopback0

     2.0.0.0/24 is subnetted, 1 subnets

S       2.2.2.0 [1/0] via 192.168.1.2

C    192.168.1.0/24 is directly connected, Serial1/0

S    192.168.2.0/24 [1/0] via 192.168.1.2

C    192.168.3.0/24 is directly connected, Serial1/2

4.設置負載均衡

 (1)在R1上設置

     rack01(config)#ip route 2.2.2.0 255.255.255.0 192.168.3.2

 (2)在R3上設置

     rack03(config)#ip route 1.1.1.0 255.255.255.0 192.168.3.1

 如今看一下路由表的狀況

rack01#show ip route

Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route

 

Gateway of last resort is not set

 

     1.0.0.0/24 is subnetted, 1 subnets

C       1.1.1.0 is directly connected, Loopback0

     2.0.0.0/24 is subnetted, 1 subnets

S       2.2.2.0 [1/0] via 192.168.1.2  !此時到達2.2.2.0網絡時出現了負載均衡的狀況

                [1/0] via 192.168.3.2

C    192.168.1.0/24 is directly connected, Serial1/0

S    192.168.2.0/24 [1/0] via 192.168.1.2

C    192.168.3.0/24 is directly connected, Serial1/2

 

查看數據包的走向

rack01#ping

Protocol [ip]:

Target IP address: 2.2.2.2

Repeat count [5]:

Datagram size [100]:

Timeout in seconds [2]:

Extended commands [n]: y

Source address or interface: 1.1.1.1

Type of service [0]:

Set DF bit in IP header? [no]:

Validate reply data? [no]:

Data pattern [0xABCD]:

Loose, Strict, Record, Timestamp, Verbose[none]: record

Number of hops [ 9 ]:

Loose, Strict, Record, Timestamp, Verbose[RV]:

Sweep range of sizes [n]:

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

Packet sent with a source address of 1.1.1.1

Packet has IP options:  Total option bytes= 39, padded length=40

 Record route: <*>

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

 

Reply to request 0 (120 ms).  Received packet has options

 Total option bytes= 40, padded length=40

 Record route:

   (192.168.1.1)

   (192.168.2.1)

   (2.2.2.2)

   (192.168.3.2)

   (1.1.1.1) <*>

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

 End of list

 

Reply to request 1 (136 ms).  Received packet has options

 Total option bytes= 40, padded length=40

 Record route:

   (192.168.1.1)

   (192.168.2.1)

   (2.2.2.2)

   (192.168.2.2)

   (192.168.1.2)

   (1.1.1.1) <*>

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

 End of list

 

Reply to request 2 (112 ms).  Received packet has options

 Total option bytes= 40, padded length=40

 Record route:

   (192.168.1.1)

   (192.168.2.1)

   (2.2.2.2)

   (192.168.3.2)

   (1.1.1.1) <*>

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

 End of list

 

Reply to request 3 (112 ms).  Received packet has options

 Total option bytes= 40, padded length=40

 Record route:

   (192.168.1.1)

   (192.168.2.1)

   (2.2.2.2)

   (192.168.2.2)

   (192.168.1.2)

   (1.1.1.1) <*>

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

 End of list

 

Reply to request 4 (64 ms).  Received packet has options

 Total option bytes= 40, padded length=40

 Record route:

   (192.168.1.1)

   (192.168.2.1)

   (2.2.2.2)

   (192.168.3.2)

   (1.1.1.1) <*>

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

 End of list

Success rate is 100 percent (5/5), round-trip min/avg/max = 64/108/136 ms

 

手動的指定數據包的走向

如:從R1到達R3時走的是上面的路由,等從R3返回到R1時直接接走s1/2

從新在R3上設置下靜態路由

  rack03(config)#ip route 1.1.1.0 255.255.255.0 192.168.3.1

rack03(config)#ip route 192.168.1.0 255.255.255.0 192.168.3.1

 !到達R1的回包只設置S1/2這條路徑

如今看一下數據包的走向

rack01#ping

Protocol [ip]:

Target IP address: 2.2.2.2

Repeat count [5]:

Datagram size [100]:

Timeout in seconds [2]:

Extended commands [n]: y

Source address or interface: 1.1.1.1

Type of service [0]:

Set DF bit in IP header? [no]:

Validate reply data? [no]:

Data pattern [0xABCD]:

Loose, Strict, Record, Timestamp, Verbose[none]: r

Number of hops [ 9 ]:

Loose, Strict, Record, Timestamp, Verbose[RV]:

Sweep range of sizes [n]:

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

Packet sent with a source address of 1.1.1.1

Packet has IP options:  Total option bytes= 39, padded length=40

 Record route: <*>

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

 

Reply to request 0 (164 ms).  Received packet has options

 Total option bytes= 40, padded length=40

 Record route:

   (192.168.1.1)

   (192.168.2.1)

   (2.2.2.2)

   (192.168.3.2)

   (1.1.1.1) <*>    !能夠看出從R3返回R1時走的都是S1/2這條路徑

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

 End of list

 

Reply to request 1 (124 ms).  Received packet has options

 Total option bytes= 40, padded length=40

 Record route:

   (192.168.3.1)

   (2.2.2.2)

   (192.168.3.2)

   (1.1.1.1) <*>   !能夠看出從R3返回R1時走的都是S1/2這條路徑

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

 End of list

 

Reply to request 2 (132 ms).  Received packet has options

 Total option bytes= 40, padded length=40

 Record route:

   (192.168.1.1)

   (192.168.2.1)

   (2.2.2.2)

   (192.168.3.2)

   (1.1.1.1) <*>    !能夠看出從R3返回R1時走的都是S1/2這條路徑

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

 End of list

 

Reply to request 3 (128 ms).  Received packet has options

 Total option bytes= 40, padded length=40

 Record route:

   (192.168.3.1)

   (2.2.2.2)

   (192.168.3.2)

   (1.1.1.1) <*>    !能夠看出從R3返回R1時走的都是S1/2這條路徑

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

 End of list

 

Reply to request 4 (224 ms).  Received packet has options

 Total option bytes= 40, padded length=40

 Record route:

   (192.168.1.1)

   (192.168.2.1)

   (2.2.2.2)

   (192.168.3.2)

   (1.1.1.1) <*>     !能夠看出從R3返回R1時走的都是S1/2這條路徑

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

   (0.0.0.0)

 End of list

 

Success rate is 100 percent (5/5), round-trip min/avg/max = 124/154/224 ms

從上面數據包的走向能夠看出從R1到達R3時,由於沒有手動指定路徑,所以它是隨機的一條路徑;但當R3到達R1(回包)時走的永遠都是S1/2(192.168.3.2)這條路徑,由於手動指定了。

如今能夠考慮下R2到達R3時,R3的回包是一個什麼樣的走向??

(192.168.2.1)

   (2.2.2.2)

   (192.168.3.2)

   (192.168.1.1)

   (192.168.1.2) <*>

 

設置浮動靜態路由

4.更改R1的管理距離,觀察路由表的狀況

rack01(config)#ip route 2.2.2.0 255.255.255.0 192.168.3.2 10(管理距離)

rack01#show ip route

Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route

 

Gateway of last resort is not set

 

     1.0.0.0/24 is subnetted, 1 subnets

C       1.1.1.0 is directly connected, Loopback0

     2.0.0.0/24 is subnetted, 1 subnets

S  2.2.2.0 [1/0] via 192.168.1.2  !此時到2.2.2.0網絡時走的是s1/0,由於它的管理距離小

C    192.168.1.0/24 is directly connected, Serial1/0

C    192.168.2.0/24 is directly connected, Serial1/1

5.查看浮動靜態路由的狀況

rack01(config)#int s1/0  

rack01(config-if)#shu    !此時將s1/0  Down掉後查看路由表的狀況

 

rack01#show ip route

Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP

       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

       E1 - OSPF external type 1, E2 - OSPF external type 2

       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2

       ia - IS-IS inter area, * - candidate default, U - per-user static route

       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set

 

     1.0.0.0/24 is subnetted, 1 subnets

C       1.1.1.0 is directly connected, Loopback0

     2.0.0.0/24 is subnetted, 1 subnets

S       2.2.2.0 [10/0] via 192.168.3.2   !此時到2.2.2.0網絡時走的是s1/2

C    192.168.2.0/24 is directly connected, Serial1/1

 

【實驗總結】

在通常的網絡中通常狀況下都要提供負載均衡,所謂負載均衡就是指從一個網絡到達另外一個網絡,有多條鏈路均可以到達,並且能夠指定數據的走向,如本實驗中從R1到達R3時走的是S1/0當

返回時(R3到達R1)走的是S1/2;所謂浮動路由就是指當主路由Down掉時,另外一條路由(備份路由)自動起來,在這裏起到備份鏈路的做用。

 

6、【實驗名稱】默認網關實驗

  【實驗目的】                                

 

 

 

經過實驗體會靜態路由的靈活應用,以及如何將路由器定義爲 LNIX 主機,如何爲路由器定義默認

網關;在沒有配置任何路由協議的狀況下,怎樣將網絡配通。

   【實驗分析】

      在沒有設置任何路由時,經過設置默認網關的功能,使網絡可以互相通訊,在這裏R2充當默認

網關的角色,即s1/0做爲R1的網關,s1/1做爲R2的網關。

【實驗拓撲】

 
   

 

 

 

 

   【實驗步驟】

      1. 在R1設置

rack01(config)#int s1/0

rack01(config-if)#ip add 192.168.1.1 255.255.255.0

rack01(config-if)#no shut

rack01(config)#no ip routing

rack01(config)#ip de

rack01(config)#ip default-g

rack01(config)#ip default-gateway 192.168.1.2

2.R2上設置

rack02(config)#int s1/0

rack02(config-if)#ip add 192.168.1.2 255.255.255.0

rack02(config-if)#no shut

rack02(config-if)#int s1/1

rack02(config-if)#ip add 192.168.2.1 255.255.255.0

rack02(config-if)#no shu

3.R3上設置

rack03(config)#no ip routing

rack03(config)#ip default-gateway 192.168.2.1

 

測試

rack01#ping 192.168.2.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 144/192/264 ms

 

第四天課

1、IGRP(Interior Gateway Routing Protocol):內部網關路由協議

1.使用的度量值:帶寬(bandwidth),延遲(delay),可靠性(reliability),負載(load)

                最大傳輸單元(Mtu)

2.配置IGRP:

  Router(config)#router igrp autonomous-system(自治系統號)

                          !制定IGRP爲IP路由協議

  Router(config-router)#network network-number(要宣告的網段)

                          !宣告網段

  Router(config)#show ip igrp          !查看IGRP信息

3.自治系統號範圍:1——65535     其中64512——65535爲私有自治系統號

4.IGRP的跳數:默認爲100,它的最大擴充跳數爲255

5.IGRP的管理距離:100(此值能夠手動更改)

6.IGRP計時器:每90秒發送一次更新

              失效時間:270秒

              Hold-Down時間:280秒

              刷新時間:900秒

7.IGRP使用的廣播:255.255.255.255  

2、EIGRP(Enhanced Interior Gateway Routing Protocol):

加強的內部網關路由協議

1.幾個知識點:Hold-Down time:240秒

              Maximum Path:4     最大支持的負載均衡鏈路爲4條

              Hop(跳數):100(默認)   最大爲255

              發送組播的地址:224.0.0.10

2.管理距離(Distance):內(一個自治系統內):90

                       外(兩個自治系統之間):170

更改管理距離的方法:

Router(config-router)#diatance eigrp 100(自治系統號) 90(此值能夠隨意修改,但最大值爲255)

3.評定參數:帶寬和延遲

4.配置EIGRP:

Router(config)#router eigrp autonomous-system(自治系統號) !制定EIGRP爲IP路由協議

            Router(config-router)#network network-number(要宣告的網段)

                          !宣告網段

            Router(config)#show ip eigrp          !查看EIGRP信息

                Router(config-if)#ip summary-address eigrp 100 1.1.1.0 255.255.248.0

  !將某個端口的幾個網段的地址自動彙總成一個大的網段,其中1.1.1.0 和255.255.248.0這兩個值是計算出來的值。

   5.幾個show命令

(1)show ip eigrp neighbors    (2)show ip eigrp interface 端口

(3)show ip eigrp topology 查看拓撲

(4)show cdp neighbors 

     關閉CDP:router(config)#no cdp neighbors

     單個端口關閉CDP:rotuer(config-if)no cdp enable

3、  關於距離矢量協議的幾個知識點

  1. 當使用距離矢量協議的互聯網絡的拓撲發生變化時,必須更新路由選擇表。
  2. 距離矢量路由選擇表中包含每一個已知網絡的路徑總成本(度量值)和下一跳的邏輯地址

4、實驗

(一)  【實驗名稱】EIGRP協議的配置

        【實驗設備】兩臺Cisco 7200系列路由器+兩個LOOP0接口

        【實驗目標】最後1.1.1.1能夠Ping通2.2.2.2

【實驗拓撲】

 

 

 

 

 

【實驗步驟】(一)配置R1和R2各端口的IP地址

          1.R1上

            rack01(config)#int loop 0

            rack01(config-if)#ip add 1.1.1.1 255.255.255.0

            rack01(config)#int s1/0

            rack01(config-if)#ip add 199.99.1.1 255.255.255.0

            rack01(config-if)#no shut

          2.R2上

            rack02(config)#int loop 0

            rack02(config-if)#ip add 2.2.2.2  255.255.255.0

            rack02(config)#int s1/0

            rack02(config-if)#ip add 199.99.1.2 255.255.255.0

         

(二)設置R1和R2上的EIGRP協議

           1.R1上

            rack01(config)#router eigrp  100         !起EIGRP協議

            rack01(config-router)#network 1.1.1.0    !宣告網段

            rack01(config-router)#network 199.99.1.0

            rack01(config-router)#no auto-summary    !關閉自動彙總功能

           2.R2上

            rack02(config)#router eigrp  100

            rack02(config-router)#network 2.2.2.0

            rack02(config-router)#no auto-summary    !關閉自動彙總功能

          (三)幾個實用命令

            1.router#show ip eigrp topology       !查看EIGRP的拓撲

            2.router#show ip eigrp neighbors    !查看某個設備的鄰居信息

(二)【實驗名稱】將幾個網段自動彙總成一個大的網段

     【實驗拓撲】

       
     
   
 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

    實驗原理】

現有一部分IP從R1到達R2,爲了節省網絡資源,用自動彙總功能,將全部IP彙總成一個

大的網段(就像幾個小的網絡彙總成一個大的網絡同樣)

   

 【分析】

彙總成172.1.4.0/24

(1)將172.1.4.0/25

                   172.1.4.128/24

(2)將172.1.4.0/24

彙總成172.1.4.0/22

        172.1.5.0/24

        172.1.6.0/24

        172.1.7.0/24

  (3)配置命令:Router(config)#interface s1/0    !配置時的端口號

                 Router(config-if)#ip summary-address eigrp 100 172.1.4.0 255.255.255.0

              !開始自動彙總,假如172.1.4.0是彙總完的網段,255.255.255.0是其子網掩碼

 

(三)【實驗名稱】EIGRP路由+靜態路由

      【實驗設備】四臺Cisco 7200系列路由器+兩個LOOP0測試接口

實驗原理:在R1,R2,R3三臺路由器上設置EIGRP路由,即將這三臺路由器看做爲一個網絡。

          在R3和R4上設置靜態路由,使之最終R1——R4之間能夠互相Ping通。

【實驗拓撲】

 

LOOP0

1.1.1.1

LOOP0

2.2.2.2

S1/1

S1/2

192.168.1.2

192.168.2.1

R1

192.168.2.2

192.168.3.1

           192.168.1.1 S1/0

R2

R3

R4

192.168.3.2

【實驗步驟】(一)給R1,R2,R3,R4各端口設置IP地址

          1.設置R1的IP

           rack01(config)#interface loop 0

           rack01(config-if)#ip address 1.1.1.1 255.255.255.0

           rack01(config)#interface s1/0

           rack01(config-if)#ip address 192.168.1.1 255.255.255.0

           rack01(config-if)#no shut

          2.設置R2的IP

           rack02(config)#interface s1/0

           rack02(config-if)#ip address 192.168.1.2 255.255.255.0

           rack02(config-if)#no shut

           rack02(config)#interface s1/1

           rack02(config-if)#ip address 192.168.2.1 255.255.255.0

           rack02(configif)#no shut

          3.設置R3的IP

           rack03(config)#interface s1/1

           rack03(config-if)#ip address 192.168.3.1 255.255.255.0

           rack03(config-if)#no shut

           rack03(config)#interface s1/2

           rack03(config-if)#ip address 192.168.3.2 255.255.255.0

           rack03(configif)#no shut

          4.設置R4的IP

           rack04(config)#interface loop 0

           rack04(config-if)#ip address 2.2.2.2 255.255.255.0

           rack04(config)#interface s1/2

           rack04(config)#ip address 192.168.3.2 255.255.255.0

           rack04(config)#no shut

(二)給R1,R2,R3上設置EIGRP

1.在R1上設置

 rack01(config)#router eigrp 100

rack01(config-rack)#no auto-summary         !關閉自動彙總

rack01(config-rack)#network 1.1.1.0         !宣告1.1.1.0網段

rack01(config-rack)#network 192.168.1.0

          2.在R2上設置

 rack02(config)#router eigrp 100

rack02(config-rack)#no auto-summary         !關閉自動彙總

rack02(config-rack)#network 192.168.1.0         !宣告1.1.1.0網段

 rack02(config-rack)#network 192.168.2.0

3.在R3上設置

 rack03(config)#router eigrp 100

rack03(config-rack)#no auto-summary         !關閉自動彙總

rack03(config-rack)#network 192.168.2.0         !宣告1.1.1.0網段

rack03(config)#ip route 0.0.0.0 0.0.0.0 192.168.3.2  !在設置R3設置靜態路由

注:通常狀況下還要宣告162.168.3.0網段,可是在這裏R3和R4之間設置靜態路由,所以不用宣告162.168.3.0網段。

4.在R4上設置靜態路由

rack04(config)#ip route 0.0.0.0 0.0.0.0 192.168.3.1

注:由於R3與R4在不一樣的網絡內,所以R3與R4之間不知道準確的地址,因此設置爲缺省路由。

(三)路由再發布:(只有在R3上再設置一條命令,R4才能Ping通R1,R2,R3,即路由的再發布)

           rack03(config)#router eigrp 100

           rack03(config-router)#redistribute static   

!在EIGRP 100中再發布一條靜態路由信息,讓R1和R2知道R4使用的是靜態路由

實驗結果:在R1和R2中show ip route 會出現D*EX這表示從外部學來的路由

Rack01#show ip route

1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

C       1.1.1.0/24 is directly connected, Loopback0

D       1.0.0.0/8 is a summary, 00:06:49, Null0

C    192.168.1.0/24 is directly connected, Serial1/0

D    192.168.2.0/24 [90/2681856] via 192.168.1.2, 00:06:20, Serial1/0

D*EX 0.0.0.0/0 [170/3193856] via 192.168.1.2, 00:04:06, Serial1/0

 

   表示從外部學來的路由在這裏經過R3知道了R4走的是靜態路由)

注:加劇字體標記的數值表示各自的默認管理距離

 

第五天課

1、  OSPF協議(Open Shortest Path First):開放式最短路徑優先

1.特色:以本身爲根找到目標地址的最短路徑

2.管理距離:默認爲110

  更改管理距離的方法:Router(config-router)#distance 100(設定的值)

3.度量值(metric):cost(開銷)   默認cost值:64

4. 鄰居創建過程:(1)在它的接口向對方發送Hello信息

           (2)與對方創建鏈接關係

           (3)發送LSA(鏈路狀態通告)

           (4)進行LSA  的泛洪,而後創建本身的LSDB(鏈路狀態數據庫)

           (5)路由器以本身爲源,計算SPF算法

           (6)加載以上全部信息到達路由表

5.發送Hello的目的:(1)找到它的鄰居,創建鄰接關係

                   (2)互相交換參數

                   (3)造成two-way狀態

                   (4)keeplive 激活(每隔多少秒發送一次信息)

                 (5)在廣播或NBMA(非廣播多路訪問環境下),選舉DR(指定路由器)和BDR(備份指定路由器)

6.Hello信息包括:(1)路由ID:標示本身的網絡位置

                 (2)區域ID

                 (3)Hello的時間間隔:1.在P-P(點到點)環境下,默認爲10秒

                                        2.在NBMA環境下,默認爲30秒

                  (4)死亡時間間隔:1.在P-P(點到點)環境下,默認爲40秒

                                   2.在NBMA環境下,默認爲120秒

                    show ip ospf 100 interface s1/01  !能夠查看死亡時間和Hello時間

                    (5)傳遞DR,BDR的信息(在廣播/NBMA環境下)

                    (6)優先級

                    (7)宣告的子網掩碼(反子網掩碼)

                    (8)認證信息

                    (9)互相傳遞鄰居表

   7. Hello信息具體介紹

     (1)路由ID的選舉規則:1.當路由器在LOOP口時,它會自動選舉LOOP口中最大的IP地址

                             2.當不存在LOOP口時,它會選舉其它IP地址中最大的

                             3.手工自行指定

     (2)DR的選舉規則:1.看優先級,若是優先級相同,選舉LOOP口中IP最大的。

                         2.若是沒有LOOP口,選舉IP中最大的

                         3.每一個網段都有一個DR

   8.命令基本配置:

                Router(config)#router ospf 100    !開啓OSPF協議,其中100指自動系統號

                Router(config-router)#network 1.1.1.0 0.0.0.255 area 0

                    !宣告網段1.1.1.0,其中0.0.0.255爲它的反子網掩碼,0指骨幹區域

   9.幾個show命令:

                Router#show ip ospf 100 database         !查看OSPF的數據庫

                Router#show ip ospf 100 interface s1/0   !查看OSPF某個端口信息

              

10.更改命令:

  (1)手動設置router-id(指定路由ID)     

Router(config-router#router-id network-number(此IP任意指定)

     (2)更改默認管理距離    Router(config-router)#distance 100(更改的值)

     (3)更改接口的優先級

        Router(config)#int s1/0     !進入S1/0端口

        Router(config-if)#ip ospf priority 0—255  !修改S1/0接口優先級,範圍爲0—255,其中值越大就越優先,但如選擇0後,則表示不參加選舉。

11.清除OSPF進程(從新學習路由表)

      Router#clear ip ospf process

12.設置雙工

   Router(config-if)#full-duplex   !設置爲雙工模式,還有half-duplex 半雙工

   13.路由彙總

      Router(config-if)#ip summary-address ospf 100 1.1.1.0 255.255.248.0

!將某個端口的幾個網段的地址自動彙總成一個大的網段,其中1.1.1.0 和255.255.248.0這兩個值是計算出來的值。

 

 

路由彙總:

   Cisco路由器以兩種方式管理路由彙總:

(1)發送路由彙總:RIP,IGRP,EIGRP等路由協議在網絡邊界自動進行路由彙總。具體的說,將通告發送給接口時,若是通告中路由的分類網絡地址與接口的主網絡地址不一樣,則自動彙總這些路由。對於OSPF,IS-IS必須配置手工彙總,對於EIGRP和RIPv2能夠禁用自動彙總路由。

(2)從路由彙總中選擇路由

14.鏈路狀態協議總結:

  1.優勢:(1)根據成本選擇路徑  (2)採用觸發的,泛洪式更新,會聚時間短

            (3)每臺路由器都有完整的路徑,同步的網絡描述信息,所以不易產生路由環路

  2.缺點:(1)佔用大量的內存,由於它不只要維護路由表還要維護拓撲數據庫、鄰居關係數據

              庫和轉發數據庫。

         (2)佔用大量的CPU資源,由於SPF算法在計算最佳路徑時須要佔用CPU週期。

2、基於TCP/IP的互連網絡

1.網絡分層:(1)應用層:TFTP(文件傳輸協議,CISCO專有協議)端口:69

           (2)傳輸層:TCP,UDP

           (3)Internet層

           (4)數據鏈路協議

(5)物理層

  2.TCP三次握手

           
       
       
 

 

 

                    Host A                  Host B

 

1.發送SYN(請求)                    

(seq=100 ctl=SYN)                  接收SYN(請求)

                   2.發送SYN,ACK

                                        (seq=300 ack=101 ctl=SYN,ack)

 

                   接收SYN

 
   

 

 

       3.創建會話

       (seq=101 ack=301

         ctl=ack)

 

三次握手過程:1.Host A向Host B發送SYN 比特

              2.Host B接收到seq請求後,經過哈希算法將ack加1後,再發送seq請求給A

              3.Host A接收到Host B的迴應後,將seq的值與Host B的ack值相比較,若是相同,會話創建成功,若是不一樣,則會話創建失敗。

 

3、實驗:

(一)【實驗名稱】配置OSPF

【實驗設備】兩臺Cisco 7200系列路由器,兩個LOOP迴環測試接口

【實驗目標】網絡1.1.1.1能夠Ping通2.2.2.2

        【實驗拓撲】

LOOP0

2.2.2.2

                                   S1/0      

192.168.1.2 

        R2  

                                                                       

192.168.1.1  

                                                                 

LOOP0

1.1.1.1        R1      

                                                   

【實驗步驟】(一)給R1和R2個端口配置IP地址

1.R1

 rack01(config)#int loop 0

 rack01(config-if)#ip add 1.1.1.1 255.255.255.0

 rack01(config-if)#int s1/0

 rack01(config-if)#ip add 192.168.1.1 255.255.255.0

 rack01(config-if)#no shut

2.R2

 rack02(config)#int loop 0

 rack02(config-if)#ip add 2.2.2.2 255.255.255.0

 rack02(config-if)#int s1/0

 rack02(config-if)#ip add 192.168.1.2 255.255.255.0

 rack02(config-if)#no shut

(二)配置OSPF協議

 1.R1

  rack01(config)#router ospf 100

  rack01(config-router)#network 1.1.1.0 0.0.0.255 area 0   !宣告網段

  rack01(config-router)#network 192.168.1.0 0.0.3.255 area 0

 !宣告網段192.168.1.0但爲了節省資源,將其源子網掩碼255.255.255.0再劃分,劃分紅255.255.252.0,它的反子網掩碼爲0.0.3.255
       2.R2

           rack02(config)#router ospf 100

           rack02(config-router)#network 2.2.2.0 0.0.0.255 area 0

           rack02(config-router)#network 192.168.1.0 0.0.3.255 area 0

(二)【實驗名稱】DR(指定路由器)和EBR(備份指定路由器)的選舉

      【實驗設備】一臺二層CISCO3640系列交換機,四臺CISCO7200路由器

      【實驗拓撲】

               
     
   
           
 
 

 

 

 

 

 

 

 

 

 

 

 

      【實驗步驟】(一)給R1,R2,R3,R4各端口設置IP

                 1.R1

                   rack01(config)#int loop 0

                   rack01(config-if)#ip add 1.1.1.1 255.255.255.0

                   rack01(config)#int f0/0

                   rack01(config-if)#ip add 192.168.1.1 255.255.255.0

                   rack01(config-if)#no shut

                 2.R2

                   rack01(config)#int f0/0

                   rack01(config-if)#ip add 192.168.1.2 255.255.255.0

                   rack01(config-if)#no shut

                 3.R3

                   rack01(config)#int f0/0

                   rack01(config-if)#ip add 192.168.1.3 255.255.255.0

                   rack01(config-if)#no shut

                 4.R4

                   rack01(config)#int loop 0

                   rack01(config-if)#ip add 2.2.2.2 255.255.255.0

                   rack01(config)#int f0/0

                   rack01(config-if)#ip add 192.168.1.4 255.255.255.0

                   rack01(config-if)#no shut

                (二)給R1,R2,R3,R4各端口設置OSPF

                  1.R1

                   rack01(config)#router ospf 100

                   rack01(config-router)#network 1.1.1.0 0.0.0.255 area 0

                   rack01(config-router)#network 192.168.1.0 0.0.0.255 area 0

                  2.R2

                   rack01(config)#router ospf 100

                   rack01(config-router)#network 192.168.1.0 0.0.0.255 area 0

                  3.R3

                   rack01(config)#router ospf 100    

                   rack01(config-router)#network 192.168.1.0 0.0.0.255 area 0

                  4.R4

                   rack01(config)#router ospf 100

                   rack01(config-router)#network 2.2.2.0 0.0.0.255 area 0

                   rack01(config-router)#network 192.168.1.0 0.0.0.255 area 0

 

實驗總結:配置完OSPF後,IOS系統會在R1,R2,R3,R4四臺路由器中選舉DR(指定路由器)和BDR(備份路由器)

 

 

 

 

 

 

 

(三)【實驗名稱】不一樣AS(自治系統)之間的通訊

      【實驗設備】五臺CISCO 7200系列路由器

      【實驗拓撲】

                                                                                               
   
 
     
 
     
               
       
             
 
             
     
     
 
 
     
     
         
       
 
 
                 
                     
 
 
 

 

 

 

 

 

 

 

 

 

 

     【實驗分析】

在以上拓撲中表示的是R1,R2同在一個自治系統100中,而R4,R5同在一個自治系統200

中,而R3在涉及AS 100和AS 200兩個自治系統,也就是說一半爲AS 100另外一半爲AS 200。

關鍵就在R3的路由再發布,只有這樣兩個不一樣的自治系統纔會互相Ping通。

     【實驗步驟】(一)爲R1,R2,R3,R4,R5各端口設置IP

                1.R1

                 rack01(config)#int loop 0

                 rack01(config-if)#ip add 1.1.1.1 255.255.255.0

                 rack01(config)#int s1/0

                 rack01(config-if)#ip add 192.168.1.1 255.255.255.0

                 rack01(config-if)#no shut

                2.R2

                 rack02(config)#int s1/0

                 rack02(config-if)#ip add 192.168.1.2 255.255.255.0

                 rack02(config-if)#no shut

                 rack02(config)#int s1/1

                 rack02(config-if)#ip add 192.168.2.1 255.255.255.0

                 rack02(config-if)#no shut

                3.R3

                 rack03(config)#int s1/1

                 rack03(config-if)#ip add 192.168.2.2 255.255.255.0

                 rack03(config-if)#no shut

                 rack03(config-if)#int s1/2

                 rack03(config-if)#ip add 192.168.3.1 255.255.255.0

                 rack03(config-if)#no shut

4.R4

                 rack04(config)#int s1/2

                 rack04(config-if)#ip add 192.168.3.2 255.255.255.0

                 rack04(config-if)#no shut

                 rack04(config)#int s1/3

                 rack04(config-if)#ip add 192.168.4.1 255.255.255.0

                 rack04(config-if)#no shut

               5.R5

                 rack05(config)#int s1/3

                 rack05(config-if)#ip add 192.168.4.2 255.255.255.0

                 rack05(config-if)#no shut

                 rack05(config)#int loop 0

                 rack05(config-if)#ip add 2.2.2.2 255.255.255.0

              (三)爲R1,R2,R3,R4,R5各端口設置OSPF

               1.R1

                 rack01(config)#router ospf 100

                 rack01(config-router)#network 1.1.1.0 0.0.0.255 area 0

                 rack01(config-router)#network 192.168.1.0 0.0.0.255 area 0

               2.R2

                 rack02(config)#router ospf 100

                 rack02(config-router)#network 192.168.1.0 0.0.0.255 area 0

                 rack02(config-router)#network 192.168.2.0 0.0.0.255 area 0

               3.R3

                 rack03config)#router ospf 100

                 rack03(config-router)#network 192.168.2.0 0.0.0.255 area 0

                 rack03config)#router ospf 200

                 rack03(config-router)#network 192.168.3.0 0.0.0.255 area 0

               4.R4

                 rack04config)#router ospf 200

                 rack04(config-router)#network 192.168.3.0 0.0.0.255 area 0

                 rack04(config-router)#network 192.168.4.0 0.0.0.255 area 0

               5.R5

                 rack04config)#router ospf 200

                 rack04(config-router)#network 192.168.3.0 0.0.0.255 area 0

                 rack04(config-router)#network 2.2.2.0 0.0.0.255 area 0

              

(四)在R3上路由再發布

                 rack03config)#router ospf 100

                 rack03(config-router)#redistribute ospf 200   !在AS 100中發佈AS 200

                 rack03config)#router ospf 200

                 rack03(config-router)#redistribute ospf 100   !在AS 200中發佈AS 100

 

 

 

 

 

 

 

第六天課

1、訪問控制列表(ACLAccess List

   1.做用:控制IP流量

   2.使用ACL的緣由:(1)管理網絡中逐步增加的IP數據

                    (2)當數據經過路由器時進行過濾

   3.ACL的應用:(1)容許或拒絕數據包經過Router

                (2)容許或拒絕Telnet會話的創建

                (3)沒有設置ACL時,全部數據包都會在網絡上傳輸

   4.分類:

          (1)標準ACL:1.檢查源地址

                         2.一般容許(permit)或拒絕(deny)的是完整的協議

               ACL編號:1——99     1300——1999

          (2)擴展ACL:1.檢查源地址和目標地址

                         2.一般容許或拒絕的是某個特定的協議,如Telnet

               ACL編號:100——199  2000——2699

          (3)命名ACL

  5.ACL的配置指南:(1)ACL的編號指明瞭使用何種協議的訪問列表

                    (2)ACL的最後有一條隱含聲明:deny any—每一條正確的訪問列表都至少應該有一條容許語句

                    (3)每一個端口,每一個方向,每條協議只能對應一條訪問列表

                    (4)先建立訪問列表,而後應用到端口上

                    (5)訪問列表不能過濾路由器自身產生的數據

                    (6)具備嚴格限制語句應放在訪問列表全部語句的最上面

6.ACL配置原則:編寫標準ACL是通常要靠近目的;而編寫擴展ACL是通常要靠近源。

7.實驗配置:

1.標準ACL的設置

(1)設置訪問列表測試語句的參數

         Router(config)#access-list access-list-number {permit|deny}{test-conditions}

           access-list-numbe:表示ACL的編號

           permit:容許      deny:拒絕

           test conditions:條件

          (2)在端口上應用ACL

            Router(config)#int s1/0        !打開某個端口

            Router(config-if)#access-list-number{permit|deny{test-conditions}

           應用:Protocol          access-group

                 Access-list-number{in|out}

           2.擴展ACL的設置

(1)設置訪問列表測試語句的參數

             Router(config)#access-list access-list-number{permit-deny} protocol

source-address source-widcard [operator port] destination-add

destination-widcard [operator port] [established] [log]

   其中:operator能夠是lt(小於),gt(大於),eq(等於),neq(不等於)port爲協議端口號

         established只適用於入站TCP訪問表,它容許使用已創建的鏈接的TCP分組經過(如TCK

位爲1)

3.使用訪問類條目控制對vty的訪問

           (1)技術原理:標準和擴展訪問表禁止分組經過路由器,但不能禁止當前路由器發送

的分組經過,出站Telnet擴展訪問表不能組織當前路由器發起Telnet會話。

配置命令:router(config)#line vty {#/vty-range} !命令line將路由器切換到線路配置模式

         router(config-line)#access-class access-list-number {in|out}

                                   !命令access-class將訪問表應用於一條或一組終端線路

      其中:in:禁止訪問表中指定地址以Telnet方式訪問路由器

            out:禁止路由器的vty端口向訪問表指定的地址發起Telnet鏈接,注意,在這種情

況下,標準訪問表中指定的源地址用做目標地址。

        (2)配置實例:

                   【實驗名稱】容許特定網絡中的設備創建到路由器的Telnet會話

                   【實驗步驟】router(config)#access-list 2 permit 192.168.1.0 0.0.0.255

                             router(config)#line vty 0 4

                             router(config-line)#access-class 2 in

2、實驗:

 實驗一  【實驗名稱】利用標準ACL訪問控制列表,控制IP流量

         【實驗設備】三臺CISCO 7200路由器,其中一臺做爲Host(主機)利用

         【實驗目標】(1)在沒有設置ACL時,主機IP能夠Ping通R2

                  (2)當在R1的in(入端口)端口或out(出端口)端口設置ACL

後,讓主機IP沒法Ping通R2即沒法給R2發送IP流量,從而阻止了主機發送的IP流量。在網絡中的目的就是阻止某些IP發送來的流量。好比阻止某些惡意IP的攻擊。

         【實驗拓撲】

 

       
     
 
   

 

 

 

 

 

 

         【實驗步驟】(一)給Host,R1,R2各個端口設置IP

1.Host上

 Router(config)#no ip routing   !關閉路由功能,即把Router設置成主機

 Router(config)#hostname host   !重命名爲host

 host(config)#ip default-gateway 199.99.1.1 !設置主機的默認網關

host(config)#int s1/0

host(config-if)#ip add 199.99.1.2 255.255.255.0

host(config-if)#no shut

2.R1

  rack01(config)#int s1/0

  rack01(config-if)#ip add 199.99.1.1 255.255.255.0

  rack01(config-if)#no shut

  rack01(config)#int s1/1

  rack01(config-if)#ip add 192.168.1.1 255.255.255.0

  rack01(config-if)#no shut

3.R2

  rack02(config)#int s1/1

  rack02(config-if)#ip add 192.168.1.2 255.255.255.0

  rack02(config-if)#no shut

注:到這裏爲止各鏈路鏈接成功。

              (二)在R1和R2上設置路由功能,在這裏設置EIGRP協議.

                    設置路由目的:讓Host、R一、R2之間能夠互相Ping通

                1.R1

                  rack01(config)#router eigrp 100

                  rack01(config-router)#network 199.1.1.0   !宣告網段

                  rack01(config-router)#network 192.168.1.0

                2.R2

                  rack02(config)#router eigrp  100

                  rack02(config-router)#network 192.168.1.0

                 注:到這裏爲止Host、R一、R2之間能夠互相Ping通。

                host#ping 192.168.1.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 96/148/188 ms

(三)在R1上設置ACL

    目的:讓199.99.1.1 Ping不通192.168.1.2

    rack01(config)#access-list 10 deny host 199.99.1.2

 !在R1上設置ACL 其中10指ACL的編號 deny:拒絕 host+ip表示一個特定的IP地址

上條命令還等於rack01(config)#access-list 10 deny 199.99.1.1 0.0.0.0

                                                     !0.0.0.0表明一臺特定的主機

        rack01(config)#access-list 10 permit any

          !容許除199.99.1.1外的IP訪問,若是不設置此條命令,則表示拒絕全部

        rack01(config)#int s1/1  !進入S1/1 端口

        rack01(config-if)#ip access-group 10 out  !將ACL應用到R1的出端口上

                                 

        以上兩條命令還等於如下兩條命令:

        rack01(config)#int s1/0

        rack01(config-if)#ip access-group 10 in   !將ACL應用到R1的入端口上

測試結果:在Host Ping192.168.1.2

 host#ping 192.168.1.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:

U.U.U          表示線路不通

     (四)如今給Host設置第二個IP:199.99.1.3 用此IP是能夠Ping通192.168.1.2

        host(config)#int s1/0

        host(config-if)#ip add 199.99.1.3 255.255.255.0 secondary

                     !爲S1/0端口設置第二個IP地址,其中secondary表示第二個

        host(config-if)#no shut

測試結果:用擴展Ping來Ping192.168.1.2

host#ping       擴展Ping

Protocol [ip]:

Target IP address: 192.168.1.2           目標地址

Repeat count [5]:

Datagram size [100]: 

Timeout in seconds [2]:

Extended commands [n]: y

Source address or interface: 199.99.1.3           源地址

Type of service [0]:

Set DF bit in IP header? [no]:

Validate reply data? [no]:

Data pattern [0xABCD]:

Loose, Strict, Record, Timestamp, Verbose[none]:

Sweep range of sizes [n]:

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:

Packet sent with a source address of 199.99.1.3

!!!!!         此時表示199.99.1.3能夠Ping通192.168.1.2

Success rate is 100 percent (5/5), round-trip min/avg/max = 120/150/176 ms

(五)在R1上關閉ACL,此時199.99.1.1依然能夠Ping通192.168.1.2

rack01(config)#no access-list 10  

!關閉ACL,可是關閉後會將全部設置ACL設置所有擦除,不能NO掉單個ACL設置

 

實驗2、【實驗名稱】利用擴展ACL訪問控制列表,控制IP流量

        【實驗設備】三臺CISCO 7200路由器,其中一臺做爲Host(主機)利用

        【實驗目標】設置ACL,Host能夠Ping通R2,但不能夠Telnet R2。

        【實驗拓撲】

 
   

 

 

 

 

 

【實驗步驟】(一)給Host,R1,R2各個端口設置IP

1.Host上

 Router(config)#no ip routing   !關閉路由功能,即把Router設置成主機

 Router(config)#hostname host   !重命名爲host

host(config)#ip default-gateway 199.99.1.1 !設置主機的默認網關

 host(config)#int s1/0

host(config-if)#ip add 199.99.1.2 255.255.255.0

host(config-if)#no shut

2.R1

  rack01(config)#int s1/0

  rack01(config-if)#ip add 199.99.1.1 255.255.255.0

  rack01(config-if)#no shut

  rack01(config)#int s1/1

  rack01(config-if)#ip add 199.99.2.1 255.255.255.0

  rack01(config-if)#no shut

3.R2

  rack02(config)#int s1/1

  rack02(config-if)#ip add 199.99.2.2 255.255.255.0

  rack02(config-if)#no shut

注:到這裏爲止各鏈路鏈接成功。

(二)在R1和R2上設置路由功能,在這裏設置EIGRP協議.

            設置路由目的:讓Host、R一、R2之間能夠互相Ping通

                1.R1

                  rack01(config)#router eigrp 100

                  rack01(config-router)#network 199.1.1.0   !宣告網段

                  rack01(config-router)#network 192.168.1.0

                2.R2

                  rack02(config)#router eigrp  100

                  rack02(config-router)#network 192.168.1.0

      注:到這裏爲止Host、R一、R2之間能夠互相Ping通,並且Host能夠Telnet R2

測試結果:

host#ping 199.99.2.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 199.99.2.1, timeout is 2 seconds:

!!!!!         表示可以Ping通

 

host#telnet 199.99.2.2

Trying 199.99.2.2 ... Open

User Access Verification

Password:

rack02>en

Password:

rack02#           表示可以Telnet到R2,已進入了R2的配置

 

 

 

 

(三)在R1上設置擴展ACL,讓Host能夠Ping通R2但不能Telnet R2

    1.在R1上設置擴展ACL

      rack01(config)#access-list 110 permit icmp host 199.99.1.2 host 199.99.2.2

!110表示擴展ACL的編號,host 199.99.1.2表示源IP,host 199.99.2.2表示目的IP

rack01(config)#access-list 110 deny tcp host 199.99.1.2 host 199.99.2.2 eq 23

 !拒絕來自199.99.1.2的Telnet,其中tcp表示telnet是tcp協議,23是Telnet協議的端口號

          rack01(config)#access-list 110 permint ip any any

        2.應用到端口上

          rack01(config)#int s1/1

          rack01(config-if)#ip access-group 110 out

測試結果:

host#telnet 199.99.2.2

Trying 199.99.2.2 ...

% Destination unreachable; gateway or host down         表示目標鏈路不可達

實驗3、【實驗名稱】利用命名ACL訪問控制列表,控制IP流量

        【實驗設備】三臺CISCO 7200路由器,其中一臺做爲Host(主機)利用

        【實驗目標】設置ACL,Host能夠Telnet R2,但不能夠Ping通R2。

 【實驗拓撲】

                   
     
       
 
 
     
       
   
 
 

 

 

 

 

 

 

        【實驗步驟】(一)給Host,R1,R2各個端口設置IP

1.Host上

 Router(config)#no ip routing   !關閉路由功能,即把Router設置成主機

 Router(config)#hostname host   !重命名爲host

 host(config)#ip default-gateway 199.99.1.1    !設置主機的默認網關

host(config)#int s1/0

host(config-if)#ip add 199.99.1.2 255.255.255.0

host(config-if)#no shut

2.R1

  rack01(config)#int s1/0

  rack01(config-if)#ip add 199.99.1.1 255.255.255.0

  rack01(config-if)#no shut

  rack01(config)#int s1/1

  rack01(config-if)#ip add 199.99.2.1 255.255.255.0

  rack01(config-if)#no shut

3.R2

  rack02(config)#int s1/1

  rack02(config-if)#ip add 199.99.2.2 255.255.255.0

  rack02(config-if)#no shut

注:到這裏爲止各鏈路鏈接成功。

 

(二)在R1和R2上設置路由功能,在這裏設置EIGRP協議.

            設置路由目的:讓Host、R一、R2之間能夠互相Ping通

                1.R1

                  rack01(config)#router eigrp 100

                  rack01(config-router)#network 199.1.1.0   !宣告網段

                  rack01(config-router)#network 192.168.1.0

                2.R2

                  rack02(config)#router eigrp  100

                  rack02(config-router)#network 192.168.1.0

      注:到這裏爲止Host、R一、R2之間能夠互相Ping通,並且Host能夠Telnet R2

       (三)在R1上設置命名ACL,讓Host能夠Telnet R2,但Ping不通R2

rack01(config)#ip access-list extended cisco

!設置命名ACL,其中extended表示命名,cisco則是隨意起的命令

rack01(config-ext-nacl)#deny icmp host 199.99.1.2 host 199.99.2.2

!拒絕來自主機199.99.1.2發送的icmp數據包,即Ping不通,其中host 199.99.2.2表示目標地址

rack01(config-ext-nacl)#permit tcp host 199.99.1.2 host 199.99.2.2 eq 23

!容許來自主機199.99.1.2的Telnet訪問199.99.2.2,其中eq 23表示Telnet的端口號

rack01(config-ext-nacl)#permit ip any any

       

(四)應用到端口上

            rack01(config)#int s1/0

            rack01(config-if)#ip access-group cisco in       !cisco是命的名稱

測試結果:

         host#ping 199.99.2.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 199.99.2.2, timeout is 2 seconds:

U.U.U           表示鏈路不通

Success rate is 0 percent (0/5)

 

host#telnet 199.99.2.2

Trying 199.99.2.2 ... Open

 

User Access Verification

 

Password:

rack02>en

Password:

rack02#           表示已成功Telnet到R2

(四)綜合實驗

       【實驗設備】四臺CISCO 7200路由器,其中一臺做爲Host(主機)利用

       【實驗目標】設置Host S1/0端口的IP地址爲192.168.1.一、192.168.1.二、192.168.1.7

              (1)不容許host的192.168.1.一、192.168.1.2 Ping R3

              (2)不容許host的192.168.1.7 Telnet到R4

              (3)不容許R2 Ping R3

       【實驗拓撲】

 

 

 

 

 

 

 

 

 

 

 

 

【實驗步驟】(一)設置Host,R1,R2,R3各端口的IP

                    1.Host

                      host(config)#no ip routing     !關閉路由功能

                      host(config)#ip default-gateway 192.168.1.1   !設置默認網關

                      host(config)#int s1/0

                      host(config-if)#ip add 192.168.1.7 255.255.255.0

                      host(config-if)#no shut

                      host(config-if)#ip add 192.168.1.2 255.255.255.0 secondary

                      host(config-if)#no shut

                      host(config-if)#ip add 192.168.1.1 255.255.255.0 secondary

                    2.R1

                      rack01(config)#int s1/0

                      rack01(config-if)#ip add 192.168.1.8 255.255.255.0

                      rack01(config-if)#no shut

                      rack01(config)#int s1/1

                      rack01(config-if)#ip add 192.168.2.1 255.255.255.0

                      rack01(config-if)#no shut

                      rack01(config)#int s1/2

                      rack01(config-if)#ip add 192.168.3.1 255.255.255.0

                      rack01(config-if)#no shut

                    3.R2

                      rack02(config)#int s1/1

                      rack02(config-if)#ip add 192.168.2.2 255.255.255.0

                      rack02(config-if)#no shut

                    4.R3

                      rack03(config)#int s1/2

                      rack03(config-if)#ip add 192.168.3.2 255.255.255.0

                      rack03(config-if)#no shut

  (二)給R1,R2,R3設置路由功能

        目的:讓Host,R1,R2,R3之間能夠互相Ping通

       1.R1

        rack01(config)#router eigrp 100

        rack01(config-router)#network 192.168.1.0

        rack01(config-router)#network 192.168.2.0

        rack01(config-router)#network 192.168.3.0

       2.R2

        rack02(config-router)#network 192.168.2.0

       3.R3

        rack03(config-router)#network 192.168.3.0  (三)配置ACL

      1.不容許host的192.168.1.一、192.168.1.2 Ping R3

        rack01(config)#access-list 110 deny icmp 192.168.1.0 0.0.0.3 host 192.168.2.2

      !配置擴展ACL,其中192.168.1.0表示一個網段表明1.1和1.2這兩太主機,0.0.0.3是它的反子網掩碼,子網掩碼爲255.255.255.252,它是路由彙總後的掩碼,這樣只能包括1.1和1.2兩個地址

        rack01(config)#int s1/0

rack01(config-if)#ip access-group 110 in    !將ACL應用到端口S1/1上

測試結果:

host#ping 192.168.3.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:

U.U.U

host#ping        擴展Ping

Protocol [ip]:

Target IP address: 192.168.3.2         目標地址

Extended commands [n]: y

Source address or interface: 192.168.1.2          源地址

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:

Packet sent with a source address of 192.168.1.2

U.U.U

      2.不容許Host的192.168.1.7 Telnet到R4

       rack01(config)# access-list 110 deny tcp host 192.168.1.7 host 192.168.3.2 eq 23

      3.不容許R2 Ping R3

        rack01(config)#access-list 111 deny icmp host 192.168.2.2 host 192.168.3.2

         !須要注意的是ACL的每一個編號只能應用一次,即只能用在一個端口上。

rack01(config)#int s1/1

rack01(config-if)#ip access-group 111 in

測試結果:

        rack02#ping 192.168.3.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:

.....   表示不能被Ping通

Success rate is 0 percent (0/5)

第七天課

1、幾個概念:

   1.內部全局:使具備網地址接入Internet的公網地址

2.內部本地:局域網內部的全部主機

3.外部全局:

4.外部本地:ISP與本地公網地址連接的對端的公網地址

         
   
 
     
 
     
 
     

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2、實驗

  (一)【實驗名稱】靜態NAT(一對一關係,即一個局域網地址對一個公網地址)

【實驗目標】一個局域網內有一臺主機,須要接入Internet,現有一個

公網IP地址,局域網內的主機經過這個公網IP地址,經

過靜態NAT技術,實現局域網內的這臺主機接入Internet。

        【實驗設備】兩臺CISCO 7200 路由器

        【實驗拓撲】

 

 

 

 
   

 

 

 

 

 

 

 

 

        【實驗步驟】

              (一)給R1和R2配置各端口的IP

                    1.R1

                     rack01(config)#int loop 0

rack01(config-if)#ip add 192.168.1.1 255.255.255.0

rack01(config)#int s1/0

rack01(config-if)#ip add 202.102.1.1 255.255.255.0

rack01(config-if)#no shut

                    2.R2

                     rack02(config-if)#int s1/0

rack02(config-if)#ip add 202.102.1.2 255.255.255.0

rack02(config-if)#no shut

                 (二)在R1和R2上開啓路由功能,讓各端口之間能夠互相Ping通

                    1.R1

                     rack01(config)#router eigrp 100

rack01(config-router)#network 192.168.1.0

rack01(config-router)#network 202.102.1.0

                    2.R2

                     rack02(config)#router eigrp 100

rack02(config-router)#network 202.102.1.0

                  (三)在R1上設置靜態NAT,使之可以接入Inetnet

             rack01(config)#ip nat inside source static 192.168.1.1 202.102.1.5

              !設置靜態NAT,其中inside:內部   source:源  static:靜態

                192.168.1.1爲局域網內部的IP,202.102.1.5爲公網IP

                   (四)應用到端口上

                     rack01(config)#int loop 0

                     rack01(config-if)#ip nat inside   !將NAT應用到內部接口

rack01(config-if)#int s1/0

                     rack01(config-if)#ip nat outside   !將NAT應用到外部接口

 

測試結果:

         rack01#debug ip nat            開啓debug功能查看更新狀況

IP NAT debugging is on

rack01#ping   擴展Ping

Protocol [ip]:

Target IP address: 202.102.1.2   目標地址

Repeat count [5]:

Extended commands [n]: y

Source address or interface: 192.168.1.1    源地址

Type of service [0]:

Sending 5, 100-byte ICMP Echos to 202.102.1.2, timeout is 2 seconds:

Packet sent with a source address of 192.168.1.1

!!!!!   說明鏈路是通的

                                                                    隨機的編號

看debug信息

*Jan 18 14:34:00.635: NAT: s=192.168.1.1->202.102.1.5, d=202.102.1.2 [15] 去信息

*Jan 18 14:34:00.683: NAT*: s=202.102.1.2, d=202.102.1.5->192.168.1.1 [15]回信息

總結:看以上debug信息能夠看出當192.168.1.1要接入Internet時,NAT將其轉換成了公網地址:202.102.1.5

 

(二)【實驗名稱】動態NAT(多對多的關係,即多個局域網地址對多個公網地址)

【實驗目標】一個局域網內有多臺主機,須要接入Internet,現有兩個公網IP地址,局域網內的主機經過這個兩個公網IP地址,通過動態NAT技術,實現局域網內的多臺主機接入Internet。

      【實驗設備】兩臺CISCO 7200 路由器

      【實驗拓撲】

 
   

 

 

 

 

 

 

 

 

 

 

 

 

 

【實驗步驟】

(一)給R1和R2配置各端口的IP

                    1.R1

                     rack01(config)#int loop 0

rack01(config-if)#ip add 192.168.1.1 255.255.255.0

rack01(config-if)#ip add 192.168.1.2 255.255.255.0 secondary

rack01(config-if)#ip add 192.168.1.3 255.255.255.0 secondary

rack01(config)#int s1/0

rack01(config-if)#ip add 202.102.1.1 255.255.255.0

rack01(config-if)#no shut

                    2.R2

                     rack02(config-if)#int s1/0

rack02(config-if)#ip add 202.102.1.2 255.255.255.0

rack02(config-if)#no shut

               (二)在R1和R2上開啓路由功能,讓各端口之間能夠互相Ping通

                    1.R1

                     rack01(config)#router eigrp 100

rack01(config-router)#network 192.168.1.0

rack01(config-router)#network 202.102.1.0

                    2.R2

                     rack02(config)#router eigrp 100

rack02(config-router)#network 202.102.1.0

                (三)在R1上設置動態NAT實現多臺主機,經過兩個公網IP接入Internet

                     rack01(config)#access-list 10 permit 192.168.1.0 0.0.0.7

                            !設置標準ACL,其中192.168.1.0是三個IP彙總後的網段,0.0.0.

是它的反子網掩碼

 rack01(config)#ip nat pool cisco 202.102.1.5 202.102.1.6 netmask 255.255.255.0  

 !設置動態NAT,其中pool是地址池,cisco是給地址池起的名字,202.102.1.5和

202.102.1.6是它們的公網IP,1.5是起,1.6是址,須要注意的是起IP地址必須小於

址IP地址。

rack01(config)#ip nat inside source list 10 pool cisco

 

(四)將動態NAT應用到接口上

rack01(config)#int loop 0   

rack01(config-if)#ip nat inside

rack01(config-if)#int s1/0

rack01(config-if)#ip nat outside

 

測試結果:

rack01#ping   擴展Ping

Target IP address: 202.102.1.2  目的地址

Extended commands [n]: y

Source address or interface: 192.168.1.1

Type of service [0]:

Loose, Strict, Record, Timestamp, Verbose[none]:

Sweep range of sizes [n]:

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 202.102.1.2, timeout is 2 seconds:

Packet sent with a source address of 192.168.1.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 48/68/96 ms

rack01#

*Jan 18 14:34:00.635: NAT: s=192.168.1.1->202.102.1.5, d=202.102.1.2  [15]

*Jan 18 14:34:00.683: NAT*: s=202.102.1.2, d=202.102.1.5->192.168.1.1 [15]

*Jan 18 14:34:00.683: NAT: s=192.168.1.1->202.102.1.5, d=202.102.1.2  [16]

(三) 【實驗名稱】PAT(一對多的關係,即一個公網地址對多個局域網地址)

【實驗目標】一個局域網內有多臺主機,須要接入Internet,現有一個公網IP地址,局域網內的主機經過這個公網IP地址,通過PAT技術,實現局域網內的多臺主機接入Internet。

      【實驗設備】兩臺CISCO 7200 路由器

      【實驗拓撲】

                                   
     
 
     
       
   
         
           
         
                   
 
 
 
 
 
 

 

 

 

 

 

 

 

 

 

 

 

 

【實驗步驟】

(一)給R1和R2配置各端口的IP

                    1.R1

                     rack01(config)#int loop 0

rack01(config-if)#ip add 192.168.1.1 255.255.255.0

rack01(config-if)#ip add 192.168.1.2 255.255.255.0 secondary

rack01(config-if)#ip add 192.168.1.3 255.255.255.0 secondary

rack01(config)#int s1/0

rack01(config-if)#ip add 202.102.1.1 255.255.255.0

rack01(config-if)#no shut

                    2.R2

                     rack02(config-if)#int s1/0

rack02(config-if)#ip add 202.102.1.2 255.255.255.0

rack02(config-if)#no shut

               (二)在R1和R2上開啓路由功能,讓各端口之間能夠互相Ping通

                    1.R1

                     rack01(config)#router eigrp 100

rack01(config-router)#network 192.168.1.0

rack01(config-router)#network 202.102.1.0

                    2.R2

                     rack02(config)#router eigrp 100

rack02(config-router)#network 202.102.1.0

 

(三)在R1上設置PAT實現多臺主機,經過一個公網IP接入Internet

                     rack01(config)#access-list 10 permit 192.168.1.0 0.0.0.7

   rack01(config)#ip nat pool cisco 202.102.1.5 202.102.1.5 netmask 255.255.255.0  

rack01(config)#ip nat inside source list 10 pool cisco overload

         !須要注意的是與上面動態NAT相比,只多了個overload 但卻能夠多臺主機地址經過一個公網IP接入Internet

(四)將PAT應用到接口上

rack01(config)#int loop 0   

rack01(config-if)#ip nat inside

rack01(config-if)#int s1/0

rack01(config-if)#ip nat outside

測試結果:

rack01#ping

Protocol [ip]:

Target IP address: 202.102.1.2

Repeat count [5]:

Datagram size [100]:

Extended commands [n]: y

Source address or interface: 192.168.1.1

Type of service [0]:

Sweep range of sizes [n]:

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 202.102.1.2, timeout is 2 seconds:

Packet sent with a source address of 192.168.1.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 72/100/144 ms

rack01#debug ip nat

IP NAT debugging is on

rack01#ping

Protocol [ip]:

Target IP address: 202.102.1.2

Repeat count [5]:

Extended commands [n]: y

Source address or interface: 192.168.1.1

Type of service [0]:

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 202.102.1.2, timeout is 2 seconds:

Packet sent with a source address of 192.168.1.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 68/95/120 ms

rack01#

*Jan 18 15:18:39.431: NAT: s=192.168.1.1->202.102.1.5, d=202.102.1.2 [35]

*Jan 18 15:18:39.495: NAT*: s=202.102.1.2, d=202.102.1.5->192.168.1.1 [35]

*Jan 18 15:18:39.495: NAT: s=192.168.1.1->202.102.1.5, d=202.102.1.2 [36]

*Jan 18 15:18:39.615: NAT*: s=202.102.1.2, d=202.102.1.5->192.168.1.1 [36]

總結:

     靜態NAT:只能是一個私有地址對一個公網地址,即一對一的關係

     動態NAT:多個私有地址對多個公網地址,即多對過的關係

     PAT:多個私有地址對一個公網地址,即多對一的關係

     Router#show ip nat translations     !查看NAT列表

     Router#clear ip nat translation *   !清除NAT轉換中全部的動態地址轉換條件

3、TFTP軟件的應用

TFTP:文件傳輸協議,爲CISCO專有協議

(一)copy命令(特權模式下)

1.copy running-config startup-running   !對路由器當前的配置複製到路由器的NVRAM中

  2.copy startup-running running-config   !接着上次保存的配置繼續配置

  3.copy running-config tftp  !將配置複製到TFTP軟件上,即備份

  4.copy tftp running-config  !將備份的設置從TFTP軟件上提取出來

  5.copy running-config startup-running   !對路由器當前的配置複製到路由器的NVRAM中,

此條命令能夠在作完全部配置後,在運用,即再保存

(二)升級IOS(操做系統)

 1.router(config)#config-register 0x2101  !將寄存器的值修改成0x2101,便可讀可寫寄存器

 2.router#write     !保存

 3.router(config)#copy tftp flash   !將TFTP中的IOS複製到flash中

 4.router(config)#config-register 0x2142   !將寄存器的值修改成0x2142,便可讀寄存器

                                     這一步是必須的,由於這樣纔不會隨便被別人修改寄存器

(三)TFTP軟件的應用實例

Router#conf t            

Enter configuration commands, one per line.  End with CNTL/Z.            

Router(config)#int e0                    

Router(config-if)#ip add 199.99.1.1 255.255.255.0                        

Router(config-if)#no shu                                       

changed sta

te to up

Router#copy  running-config tftp          !將配置複製到TFTP軟件上,即備份

Address or name of remote host []? 199.99.1.180

Destination filename [router-confg]?

!!

697 bytes copied in 5.580 secs (139 bytes/sec)

Router#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#host rack01

rack01(config)#^Z

rack01#cop

00:11:22: %SYS-5-CONFIG_I: Configured from console by console

rack01#copy tftp running-config      !將備份的設置從TFTP軟件上提取出來

Address or name of remote host [199.99.1.8]? 199.99.1.180

Source filename [router-confg]?

Destination filename [running-config]?

Accessing tftp://199.99.1.180/router-confg...

Loading router-confg from 199.99.1.180 (via Ethernet0): !

[OK - 697/1024 bytes]

697 bytes copied in 4.304 secs (174 bytes/sec)

Router#write   !保存

Router(config)#config-register 0x2101  升級Flash

Router#write  保存

Router#reload  重啓路由器

Proceed with reload? [confirm]

Router(boot)#copy tftp flash  !從TFTP中的IOS複製到路由器的FLASH

Partition   Size    Used      Free      Bank-Size  State          Copy

Mode

  1         8192K   7851K      340K     8192K      Read/Write     Direct

  2         8192K      0K     8192K     8192K      Read/Write     Direct

[Type ?<no> for partition directory; ? for full directory; q to abort]

Which partition? [default = 1]

System flash directory, partition 1:

File  Length   Name/status

  1   8039948  c2500-c-l.121-ospf-12.bin

[8040012 bytes used, 348596 available, 8388608 total]

Address or name of remote host [255.255.255.255]?

Source file name? c2500-c-l.121-ospf-12.bin     要升級,用的IOS文件

Destination file name [c2500-c-l.121-ospf-12.bin]?

Accessing file 'c2500-c-l.121-ospf-12.bin' on 255.255.255.255...

Loading c2500-c-l.121-ospf-12.bin from 199.99.1.180 (via Ethernet0): !

[OK]

Erase flash device before writing? [confirm]

Flash contains files. Are you sure you want to erase? [confirm]

Copy 'c2500-c-l.121-ospf-12.bin' from server

  as 'c2500-c-l.121-ospf-12.bin' into Flash WITH erase? [yes/no]y

Erasing device... eeeeeeeeeeeeeeeeee...erased  正在清除Flash中原有的IOS文件                                                         

Loading c2500-c-l.121-ospf-12.bin from 199.99.1.180 (via Ethernet0): !!!!!!!!!!!                                                                               

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!  成功                                                                              

Router(boot)(config)#config-register 0x2142   !設置寄存器的值爲只讀,這一步是必須的,由於這樣纔不會隨便被別人修改寄存器

Router(boot)#write   保存

 

第八天課

1、經常使用專業名詞解釋

1.DCE:數據通訊設備(即ISP提供商端)運營商的網絡互聯設備,用於在網絡中提供計時和交換服務,它們在WAN中傳輸數據,一般是幀中繼交換機。

 DTE:數據終端設備(即用戶端)在客戶場點中端接幀中繼鏈接的設備,一般是路由器,網橋

  2.dlci:數據鏈路鏈接標識符(範圍:16—1007)

  3.虛電路(VC):創建用於確保兩臺網絡設備(DTE)可以進行雙向通訊的邏輯電路

  4.永久性創建的虛電路(PVC):當須要不斷地在設備間傳輸數據時,這種電路頗有用

  5.SVC:根據須要動態地創建並在數據傳輸完畢後拆除的虛電路,當數據傳輸爲間歇性的時使用它

  6.Lmi:本地管理接口:一種用於路由器(DTE)和幀中繼交換機(DCE)之間的信令標準,負責管

理設備之間的鏈接和維護它們的狀態。

2、實驗

  1、【實驗名稱】動態Fram-relay(幀中繼)

         【實驗設備】三臺CISCO 7200系列路由器,其中R2代替幀中繼交換機

【實驗目標】R1和R3經過R2(幀中繼交換機)進行互相通訊

【名詞解釋】dlci:數據鏈路鏈接標識符(範圍:16—1007)

fram-relay swith:幀中繼交換機

            Lmi:本地管理接口 

   DCE:數據通訊設備(即ISP提供商端)

           DTE:數據終端設備(即用戶端)

【實驗拓撲】

               
   
     
       
       
 
 
 

 

 

 

 

 

 

 

(一)在R2上模擬幀中繼交換機

 1.在S1/0上設置

   router(config)#host fr-sw

   fr-sw(config)#frame-relay switching     !開啓幀中繼交換機功能

   fr-sw(config)#int s1/0

   fr-sw(config-if)#clock rate 64000      !設置時鐘頻率爲6400

fr-sw(config-if)#no shut

fr-sw(config-if)#encapsulation frame-relay  !設置幀封裝格式

fr-sw(config-if)#frame-relay lmi-type cisco  !選擇lmi(本地管理接口)類型爲cisco

   fr-sw(config-if)#frame-relay intf-type dce      !將S1/0幀中繼類型設置爲DCE端

   fr-sw(config-if)#frame-relay route 200 interface s1/1 300   !映射dlci

   fr-sw(config-if)#no shut

 2.在S1/1上設置

   fr-sw(config)#int s1/1

   fr-sw(config-if)#clock rate 64000      !設置時鐘頻率爲6400

fr-sw(config-if)#encapsulation frame-relay       !設置幀封裝格式fr-sw(config-if)#frame-relay lmi-type cisco      !將lmi類型設置爲CISCO類型

   fr-sw(config-if)#frame-relay intf-type dce       !將S1/0設置爲DCE端

   fr-sw(config-if)#frame-relay route 300 interface s1/0 200   !映射dlci

   fr-sw(config-if)#no shut

    

(二)設置動態的frame-relay

  1.R1上設置

   rack01(config)#int s1/0

   rack01(config-if)#encapsulation fram-relay        !定義幀中繼交換機

   rack01(config-if)#ip add 199.99.1.1 255.255.255.0

   rack01(config-if)#fram-relay lmi-type cisco            !選擇lmi類型爲CISCO類型

   rack01(config-if)#no shut

  2.在R3上設置

   rack03(config)#int s1/1

   rack03(config-if)#ip add 199.99.1.2 255.255.255.0

rack03(config-if)#encapsulation fram-relay 

rack03(config-if)#fram-relay lmi-type cisco

   rack03(config-if)#no shut

 

3、【實驗名稱】幀中繼

    【實驗設備】四臺CISCO 7200路由器,一臺以配置好的幀中繼交換機

    【實驗目標】如今R1, R2,R3,R4分別屬於一個局域網,現要實現的是:

1.在R1到R2,R3,R4分別設置幀中繼,將R1與R2,R1與R2以及R1與R3互相Ping通

         2.在R1,R2,R3之間設置路由功能,將R1,R2,R3,R4之間可以相互可以Ping通

         3.但設置距離矢量路由協議後,由於可以產生路由環路,所以默認狀態下利用水平分割的

方法,避免了路由環路的產生,但在這裏須要關閉水平分割。由於水平分割禁止將路由

選擇更新從收到它的接口轉發出去,所以,若是遠程路由器總部的路由器(即R1)發

送更新,然後者(R2,R3,R4)經過一個物理接口鏈接多條VC(虛電路),則它不能通

過該接口將更新發送給其餘遠程路由器(R2,R3,R4),雖然這些路由器是用不一樣的VC

若是不關閉,將會致使R1與R2,R1與R3,R1與R4之間不可以互相學習,所以要用這

條命令關閉:

                Router(config)#int s1/0    !進入某個端口關閉

                Router(config-if)#no ip splist-horizon    !關閉水平分割

               水平分割:RIP默認:關閉       EIGRP:打開

 

【實驗拓撲】

 

                                                                                                           
     
       
       
           
     
             
               
                         
                   
 
           
 
 
 
     
 
 
 
 
           
           
             
             
 
               
 
 
         
         
 
 
         
 
 
       
       
   
 
 
     
 
 
     
 
       
 

 

 

 

 

 

 

 

 

 

 

 

實驗步驟(方法一):

(一)在R1R2R3R4各端口設置IP

1. R1上設置

  rack01(config)#int loop  0

rack01(config-if)#ip add 1.1.1.1 255.255.255.0

rack01(config-if)#int s1/0

rack01(config-if)#ip add 199.99.1.1 255.255.255.0

rack01(config-if)#no shut

2.R2上設置

 rack02(config)#int loop 0

rack02(config-if)#ip add 2.2.2.2 255.255.255.0

rack02(config-if)#int s1/0

rack02(config-if)#ip add 199.99.1.2 255.255.255.0

rack02(config-if)#no shut

 3.在R3上設置

  rack03(config)#int loop 0

rack03(config-if)#ip add 3.3.3.3 255.255.255.0

rack03(config-if)#int s1/0

rack03(config-if)#ip add 199.99.1.3 255.255.255.0

rack03(config-if)#no shut

 4.在R4上設置

  rack04(config)#int loop 0

rack04(config-if)#ip add 4.4.4.4 255.255.255.0

rack04(config-if)#int s1/0

rack04(config-if)#ip add 199.99.1.4 255.255.255.0

rack04(config-if)#no shu

(二)R1R2R3R4設置Fram-relay

 1.在R1上設置

 rack01(config)#int s1/0

 rack01(config-if)#encapsulation frame-relay

  rack01(config-if)#frame-relay map ip 199.99.1.1 102 broadcast

rack01(config-if)#frame-relay map ip 199.99.1.2 102 broadcast

rack01(config-if)#frame-relay map ip 199.99.1.3 103 broadcast

rack01(config-if)#frame-relay map ip 199.99.1.4 104 broadcast

rack01(config-if)#no frame-relay inverse-arp   !關閉RARP

2.在R2上設置

 rack02(config-if)#int s1/0

 rack02(config-if)#encapsulation frame-relay

 rack02(config-if)#frame-relay map ip 199.99.1.1 211 broadcast

 rack02(config-if)#frame-relay map ip 199.99.1.2 211 broadcast

rack02(config-if)#frame-relay map ip 199.99.1.3 211 broadcast

rack02(config-if)#frame-relay map ip 199.99.1.4 211 broadcast

rack02(config-if)#no frame-relay inverse-arp

 3.在R3上設置

  rack03(config-if)#int s1/0

rack03(config-if)#encapsulation frame-relay

rack03(config-if)#frame-relay map ip 199.99.1.1 311 broadcast

rack03(config-if)#frame-relay map ip 199.99.1.2 311 broadcast

rack03(config-if)#frame-relay map ip 199.99.1.3 311 broadcast

rack03(config-if)#frame-relay map ip 199.99.1.4 311 broadcast

4.在R4上設置

  ack04(config-if)#int s1/0

rack04(config-if)#encapsulation frame-relay

rack04(config-if)#frame-relay map ip 199.99.1.1 411 broadcast

rack04(config-if)#frame-relay map ip 199.99.1.2 411 broadcast

rack04(config-if)#frame-relay map ip 199.99.1.3 411 broadcast

rack04(config-if)#frame-relay map ip 199.99.1.4 411 broadcast

 

(三)配置路由功能,配置RIP(使各局域網中IP都能Ping通)

1.R1上

  rack01(config)#router rip

rack01(config-router)#no auto-summary         !關閉自動彙總

rack01(config-router)#version 2               !選擇版本爲V2

rack01(config-router)#network 199.99.1.0     

  rack01(config-router)#network 1.1.1.0

2.R2上

  rack02(config)#router rip

rack02(config-router)#no auto-summary         !關閉自動彙總

rack02(config-router)#version 2               !選擇版本爲V2

rack02(config-router)#network 199.99.1.0     

  rack02(config-router)#network 2.2.2.0

3.R3上

  rack03(config)#router rip

rack03(config-router)#no auto-summary         !關閉自動彙總

rack03(config-router)#version 2               !選擇版本爲V2

rack03(config-router)#network 199.99.1.0     

  rack03(config-router)#network 3.3.3.0

4.R4上

  rack04(config)#router rip

rack04(config-router)#no auto-summary         !關閉自動彙總

rack04(config-router)#version 2               !選擇版本爲V2

rack04(config-router)#network 199.99.1.0

rack04(config-router)#network 4.4.4.0

 

看一下它們的PVC虛鏈路

rack01#show frame-relay pvc int s1/0

 

PVC Statistics for interface Serial1/0 (Frame Relay DTE)

 

              Active     Inactive      Deleted       Static

  Local          3            0            0            0

  Switched       0            0            0            0

  Unused         0            0            0            0

DLCI = 102, DLCI USAGE = LOCAL, PVC STATUS = ACTIVE, INTERFACE = Serial1/0

.

.

DLCI = 103, DLCI USAGE = LOCAL, PVC STATUS = ACTIVE, INTERFACE = Serial1/0

.

.

DLCI = 104, DLCI USAGE = LOCAL, PVC STATUS = ACTIVE, INTERFACE = Serial1/0

rack02#show frame-relay pvc int s1/0

 

PVC Statistics for interface Serial1/0 (Frame Relay DTE)

 

              Active     Inactive      Deleted       Static

  Local          1            0            0            0

  Switched       0            0            0            0

  Unused         0            0            0            0

DLCI = 211, DLCI USAGE = LOCAL, PVC STATUS = ACTIVE, INTERFACE = Serial1/0

注:由於要關閉水平分割功能,但RIP默認的關閉的。所以不用設置次命令。要用EIGRP必須關閉水平分割功能,第(四)個設置若要將RIP改成EIGRP,只須在配置完EIGRP後加一條命令:

  例:rack01(config)#int s1/0  !進入接口

      rack01(config-if)#no ip splist-horizon  eigrp 100!關閉水平分割

 

實驗步驟(方法二):

       方法說明:上面方法是利用關閉水平分割的方法,纔可使用EIGRP,而下面方法是將S1/0

接口劃分紅多個子接口,從而解決水平分割的問題。

 (一)給R1,R2,R3,R4各接口設置IP

       1.R1上

         rack01(config)#int loop 0

         rack01(config-if)#ip add 1.1.1.1 255.255.255.0

         rack01(config)#int s1/0.1 multipoint  !進入子接口

         rack01(config-if)#ip add 199.99.1.1 255.255.255.0

         rack01(config-if)#no shut

         rack01(config)#int s1/0.2 multipoint

         rack01(config-if)#ip add 199.99.2.1 255.255.255.0

         rack01(config-if)#no shut

         rack01(config)#int s1/0.3 multipoint

         rack01(config-if)#ip add 199.99.3.1 255.255.255.0

         rack01(config-if)#no shut

        2.R2上

         rack02(config)#int loop 0

         rack02(config-if)#ip add 2.2.2.2 255.255.255.0

         rack02(config)#int s1/0

         rack02(config-if)#ip add 199.99.1.2 255.255.255.0

         rack02(config-if)#no shut

        3.R3上

         rack03(config)#int loop 0

         rack03(config-if)#ip add 3.3.3.3 255.255.255.0

rack03(config)#int s1/0

         rack03(config-if)#ip add 199.99.2.2 255.255.255.0

         rack03(config-if)#no shut

        4.R4上

         rack04(config)#int loop 0

         rack04(config-if)#ip add 4.4.4.4 255.255.255.0

rack04(config)#int s1/0

         rack04(config-if)#ip add 199.99.3.2 255.255.255.0

         rack04(config-if)#no shut

(二)R1R2R3R4設置Fram-relay

 1.在R1上設置

  rack01(config)#int s1/0

 rack01(config-if)#encapsulation frame-relay

 rack01(config)#int s1/0.1 multipoint      (多點)

  rack01(config-if)#frame-relay map ip 199.99.1.1 102 broadcast

 rack01(config-if)#no frame-relay inverse-arp   !關閉RARP

  rack01(config)#int s1/0.2 multipoint

rack01(config-if)#frame-relay map ip 199.99.2.1 102 broadcast

rack01(config-if)#no frame-relay inverse-arp   !關閉RARP

rack01(config)#int s1/0.3 multipoint

rack01(config-if)#frame-relay map ip 199.99.3.1 103 broadcast

rack01(config-if)#no frame-relay inverse-arp   !關閉RARP

2.在R2上設置

 rack02(config-if)#int s1/0

 rack02(config-if)#encapsulation frame-relay

 rack02(config-if)#frame-relay map ip 199.99.1.1 211 broadcast

 rack02(config-if)#frame-relay map ip 199.99.1.2 211 broadcast

 rack02(config-if)#frame-relay map ip 199.99.2.2 211 broadcast

rack02(config-if)#frame-relay map ip 199.99.3.2 211 broadcast

rack02(config-if)#no frame-relay inverse-arp

 3.在R3上設置

  rack03(config-if)#int s1/0

rack03(config-if)#encapsulation frame-relay

rack02(config-if)#frame-relay map ip 199.99.1.1 311 broadcast

 rack02(config-if)#frame-relay map ip 199.99.1.2 311 broadcast

rack02(config-if)#frame-relay map ip 199.99.2.2 311 broadcast

rack02(config-if)#frame-relay map ip 199.99.3.2 311 broadcast

rack02(config-if)#no frame-relay inverse-arp

4.在R4上設置

  ack04(config-if)#int s1/0

rack04(config-if)#encapsulation frame-relay

rack02(config-if)#frame-relay map ip 199.99.1.1 411 broadcast

 rack02(config-if)#frame-relay map ip 199.99.1.2 411 broadcast

rack02(config-if)#frame-relay map ip 199.99.2.2 411 broadcast

rack02(config-if)#frame-relay map ip 199.99.3.2 411 broadcast

rack02(config-if)#no frame-relay inverse-arp

(三)配置路由功能,配置EIGRP(使各局域網中IP都能Ping通)

1.R1上

  rack01(config)#router eigrp 100

rack01(config-router)#no auto-summary         !關閉自動彙總

rack01(config-router)#network 199.99.1.0     

  rack01(config-router)#network 1.1.1.0

2.R2上

  rack02(config)#router eigrp 100

rack02(config-router)#no auto-summary         !關閉自動彙總

rack02(config-router)#network 199.99.1.0     

  rack02(config-router)#network 2.2.2.0

  rack02(config-router)#network 199.99.1.0 

3.R3上

  rack03(config)#router eigrp 100

rack03(config-router)#no auto-summary         !關閉自動彙總

rack03(config-router)#network 199.99.1.0     

  rack03(config-router)#network 3.3.3.0

  rack03(config-router)#network 199.99.2.0 

4.R4上

  rack04(config)#router eigrp 100

rack04(config-router)#no auto-summary         !關閉自動彙總

rack04(config-router)#network 199.99.1.0

rack04(config-router)#network 4.4.4.0

rack04(config-router)#network 199.99.3.0 

 

3、幾個經常使用命令

   1.Router#show frame-relay lmi   !查看本地管理接口

   2.Router#show frame-relay map   !查看映射地址 

 

第九天課

1、基本概念

   (一)交換機

         1.交換機的三個功能:(1)具備地址學習的功能(每300秒刷新一次),學的是MAC地址

                            (2)轉發和過濾幀

                            (3)防止環路:其中SPT(spanning tree)自動開啓

         2.標準:IEEE802.1d   IEEE802.1w

         3.狀態:有阻塞、偵聽、學習、轉發四種狀態

         4.幀轉發的方式:(1)存儲轉發  (2)直接轉發  (3)無碎片轉發

5.交換機的端口安全包括:

         (1)端口與MAC地址綁定

          Switch(config)# mac-address-table static 0010.7a60.1884  int f0/5 vlan1

              Switch#show mac-address-table   !查看MAC地址表

         (2)端口與MAC地址學習的個數

          Switch(config-if)#port  security  max-mac-count 3

!設置只容許3個端口(端口的安全設置)

         (3)用戶名和密碼的驗證(802.1X)

(二)VLAN

     1.一個VLAN就是一個廣播域,是一個邏輯的網段

     2.劃分VLAN的目的:隔離網段中的通訊

     3.增長廣播域的目的:減輕switch工做量

     4.VLAN的範圍:0——4095,其中0和4095是不可用的,VLAN1是默認的

                   2——1001:能夠建立和刪除

                   1002——1005:表明令牌環網、FDDI等(通常不用)

                   1006——1023:不能使用

                   1024——4094:支持VTP3

     5.只有domain(域名),mod(模式),password相同時VLAN才能互相學習。

     6.幾個命令:

       (1)建立一個VLAN   

sw#vlan database

sw(vlan)#vlan 10 name cisco(名字)

           (2)將接口劃入VLAN

sw(config)#int f0/1

sw(config-if)#swithport mode access  !mode有兩種模式:access 和trunk

sw(config-if)#swithport access vlan 10

           (3)設置Trunk

sw(config)#int f0/1

sw(config-if)#swithport trunk encapsulation dot1q!設置封裝格式爲:dot1q

sw(config-if)#swithport mode trunk

(三)VTP(VLAN傳輸協議)

     1.Trunk模式:能夠傳遞VLAN信息,所以只要在一臺交換機上建立VLAN,另外一端接口會自動學習到這個VLAN

     2.Trunk的封裝方式:ISL(CISCO專有)、802.1q(dot1.q)

     3.VTP的三種模式:(1)服務器模式(server):能夠建立VLAN、修改VLAN、刪除VLAN,

發送/轉發VLAN、信息宣告、同步、存儲於NVRAM中

                      (2)客戶端模式(client):發送/轉發VLAN、信息宣告、同步,不會存儲於NVRAM中

                      (3)透明模式(transpair):建立VLAN,修改VLAN,轉發,信息宣告,但不一樣步,存儲於NVRAM中

     4.幾個設置命令

                    vlan database下邊進行操做

                   (1)sw(vlan)#vtp server   !將VTP設置爲Server模式

                   (2)sw(vlan)#vtp domain aa    !將VTP域設置名爲aa

                   (3)sw(vlan)#vtp password ******   !設置VTP的密碼

                   (4)sw#show vtp counters   !查看VTP信息

(四)SPT(Spanning Tree)——生成樹

     1.做用:防止環路、廣播風暴

     2.選取根橋(boot bridge)規則:如下參數都是越小越優先

網橋ID     路徑開銷(cost)     發送的網橋ID     端口優先級     端口ID

         3.路徑代價

                    鏈接速率                 代價

                     10Gbps                    2

                     1Gbps                     4

                    100Mbps                    19

                     10Mbps                   100

          4.Vlan Trunk端口的算中有效模式(多鏈路捆綁):   on     auto     desirable

          5.幾個設置命令

(1)設置根交換機:sw(config)#spanning-tree vlan-number priority <0-61440>

                   !優先級數必須是0或4096的倍數,優先級的設置值有16個,0,

4096,8192,12288,16384,20480,24576,28672,32798(默認),40960,45056,49152

     恢復默認值:sw(config)#no spanning-tree vlan-number priority

 

(2)設置端口優先級:sw(config-if)#spanning-tree port-priority <0-240>

       !port-priority:端口優先級數,默認爲128,優先級數必須是16的倍數,其中

有:0,16,32,48,96,112,144,160,176,192等

       恢復默認值:sw(config-if)#no spanning-tree port-priority

(3)刪除VLAN的數據庫文件:switch#delete flash:vlan.dat

                                                          !vlan.dat存儲在NVRAM中      

    注意   不要手工刪除vlan.dat文件,可能形成VLAN的不完整。 如要刪除vlan須要用有關的命令來進行。

2、實驗

【實驗名稱】單臂路由實驗

【實驗設備】三臺Cisco 7200系列路由器,其中兩臺做爲主機(Host)使用。

一臺Cisco 3550系列交換機

          【實驗目標】

          【實驗拓撲】

 
   

 

 

 

 

 

 

 

 

 

 

 

 

 

         

 【實驗步驟】

1.在rack1上設置

rack01(config)#int f0/0

rack01(config-if)#no shut

rack01(config-if)#int f0/0.1        !進入子接口

rack01(config-subif)#encapsulation dot1Q 2      !封裝dot1Q

rack01(config-subif)#ip add 192.168.2.254 255.255.255.0!設置host1的默認網關

rack01(config-subif)#no shut

rack01(config-subif)#int f0/0.3

rack01(config-subif)#encapsulation dot1Q 3

rack01(config-subif)#ip add 192.168.3.254 255.255.255.0!設置host2的默認網關

rack01(config-subif)#no shut

2.進入host1設置

host1(config)#no ip routing         !關閉路由功能

host1(config)#ip default-gateway 192.168.2.254          !設置默認網關

host1(config)#int f0/0

host1(config-if)#ip add 192.168.2.1 255.255.255.0 

host1(config-if)#no shut

3.進入host2設置

host2(config)#no ip routing   !關閉路由功能

host2(config)#ip default-gateway 192.168.3.254          !設置默認網關

host2(config)#int f0/0

host2(config-if)#ip add 192.168.3.1 255.255.255.0  !

host2(config-if)#no shut

4.在sw-1設置

sw-1(config)#int f0/2

sw-1(config-if)#switchport mode access

sw-1(config-if)#switchport access vlan 2

sw-1(config-if)#no shut

sw-1(config-if)#int f0/3

sw-1(config-if)#switchport mode access

sw-1(config-if)#switchport access vlan 3

sw-1(config-if)#no shut

sw-1(config-if)#int f0/1

sw-1(config-if)#switchport mo trun

sw-1(config-if)#no shut

5.在host1上ping host2

測試結果:

host1#ping 192.168.3.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:

!!!!

第十天課

1、認證

   1.分類:CHAP認證、PAP認證

2.認證條件:(1)雙方的封裝類型必須一致,封裝類型必須爲:PPP

           (2)雙方的Password必須相同

3.認證優勢:安全

4.認證方式:point to point(點到點)

2、實驗

   (一)【實驗名稱】CHAP認證

          【實驗設備】兩臺CISCO 7200 路由器

          【實驗目標】將兩臺CISCO 7200 路由器設置CHAP認證,只有雙方設置同樣的密碼,一

                     樣的封裝方式,纔可以Ping。

         【實驗拓撲】

 
   

 

 

 

 

 

 

 

          【實驗步驟】(一)給R1,R2各端口設置IP

1.R1

rack01(config)#int s1/0  

rack01(config-if)#ip add 199.99.1.1 255.255.255.0

rack01(config-if)#no shut

rack01(config)#int loop 0 

rack01(config-if)#ip add 1.1.1.1 255.255.255.0

2.R2

rack02(config)#int s1/0

rack02(config-if)#ip add 199.99.1.2 255.255.255.0

rack02(config-if)#no shu

rack01(config)#int loop 0 

rack01(config-if)#ip add 2.2.2.2 255.255.255.0

                    (二)設置路由,讓R1,R2各端口都能互相通訊

                     1.R1

                     rack01(config-if)#router eigrp 100

rack01(config-router)#network 199.99.1.0

2.R2

rack02(config-if)#router eigrp 100

rack02(config-router)#network 199.99.1.0

(三)設置CHAP認證

     1.R1

     rack01(config)#username rack2 password cisco   !設置password爲cisco

     rack01(config)#int s1/0

     rack01(config-if)#encapsulation ppp     !設置封裝方式爲PPP

     rack01(config-if)#ppp authentication chap     !設置CHAP認證

注:此時在R2沒有設置CHAP認證,所以如今就不能Ping通R2了

測試結果:

rack01#ping 199.99.1.2

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 199.99.1.2, timeout is 2 seconds:

.....   表示沒有Ping通

如今下面給R2設置CHAP認證,查看結果

2.R2

rack02(config)#username rack01 password cisco

rack02(config)#int s1/0

rack02(config-if)#encapsulation ppp

rack02(config-if)#ppp authentication chap

測試結果:

    rack01#ping 199.99.1.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 199.99.1.2, timeout is 2 seconds:

!!!!!   此時就可以Ping通R2了

 

(二)【實驗名稱】RIP認證+RIP彙總

      【實驗設備】兩臺CISCO 7200 系列路由器

      【實驗目標】(1)在R1和R2上設置RIP認證

               (2)在R1和R2上設置RIP彙總,以節省路由表資源

               (3)利用ACL功能禁止某些IP訪問

      【實驗拓撲】

 

               
     
       
       
   
 
 
 

 

 

 

 

 

 

 

 

    【實驗步驟】(一)給R1和R2各端口設置IP

               1.R1

    rack01(config)#int loop 0

rack01(config-if)#ip add 1.1.1.1 255.255.255.0

rack01(config)#int loop 1

rack01(config-if)#ip add 1.1.2.1 255.255.255.0

rack01(config-if)#int loop 2

rack01(config-if)#ip ad 3.3.1.1 255.255.255.0

    rack01(config)#int s1/0

rack01(config-if)#ip add 199.99.1.1 255.255.255.0

               rack01(config-if)#no shut

2.R2

   rack02(config-if)#int loop 0

rack02(config-if)#ip add 2.2.1.1 255.255.255.0

rack02(config-if)#int loop 1

rack02(config-if)#ip add 2.2.2.1 255.255.255.0

rack02(config-if)#int loop 2

rack02(config-if)#ip add 2.2.3.1 255.255.255.0

rack02(config-if)#int loop 3

rack02(config-if)#ip add 2.2.4.1 255.255.255.0

 rack02(config-if)#int s1/0

rack02(config-if)#ip add 199.99.1.2 255.255.255.0

   rack02(config-if)#no shut

(二)在R1和R2上設置RIP路由

1.R1

 rack01(config)#router rip

 rack01(config-router)#no auto-summary

rack01(config-router)#ver 2

  rack01(config-router)#network 199.99.1.0

rack01(config-router)#network 1.1.1.0

rack01(config-router)#network 1.1.2.0

rack01(config-router)#network 3.3.1.0

  2.R2

   rack02(config)#router rip

rack02(config-router)#no auto-summary

rack02(config-router)#ver 2

rack02(config-router)#network 199.99.1.0

rack02(config-router)#network 2.2.1.0  

rack02(config-router)#network 2.2.2.0

rack02(config-router)#network 2.2.3.0

rack02(config-router)#network 2.2.4.0

測試結果:

  rack01#show ip route   !查看rack01的路由表

     1.0.0.0/24 is subnetted, 2 subnets

C(直連路由) 1.1.1.0 is directly connected, Loopback0

C       1.1.2.0 is directly connected, Loopback2

     2.0.0.0/24 is subnetted, 4 subnets

R       2.2.1.0 [120/1] via 199.99.1.2, 00:00:03, Serial1/0

學到了rack02的四條RIP路由

R       2.2.2.0 [120/1] via 199.99.1.2, 00:00:03, Serial1/0

R       2.2.3.0 [120/1] via 199.99.1.2, 00:00:03, Serial1/0

R       2.2.4.0 [120/1] via 199.99.1.2, 00:00:03, Serial1/0

     3.0.0.0/24 is subnetted, 1 subnets

C       3.3.1.0 is directly connected, Loopback1

C    199.99.1.0/24 is directly connected, Serial1/0

查看rack02的路由表

rack02#show ip route    !學到了rack01的三條RIP路由

    1.0.0.0/24 is subnetted, 2 subnets

R       1.1.1.0 [120/1] via 199.99.1.1, 00:00:02, Serial1/0

     1.1.2.0 [120/1] via 199.99.1.1, 00:00:02, Serial1/0

     2.0.0.0/24 is subnetted, 4 subnets

C       2.2.1.0 is directly connected, Loopback0

C       2.2.2.0 is directly connected, Loopback1

C       2.2.3.0 is directly connected, Loopback2

C       2.2.4.0 is directly connected, Loopback3

     3.0.0.0/24 is subnetted, 1 subnets

R       3.3.1.0 [120/1] via 199.99.1.1, 00:00:02, Serial1/0

C    199.99.1.0/24 is directly connected, Serial1/0

(三)在R1和R2上設置RIP認證

  1.R1

 rack01(config)#key chain cisco      !設置名稱爲cisco

rack01(config-keychain)#key 1

rack01(config-keychain-key)#key-string 1234    !設置密碼爲1234

rack01(config-keychain-key)#int s1/0

rack01(config-if)#ip rip authentication mode text   !設置加密方式爲text(明文加密)

rack01(config-if)#ip rip authentication key cisco

注:此時只在R1設置了RIP認證,所以如今是不能Ping通R2的

查看測試結果:

rack01#ping

Target IP address: 2.2.2.1    目標地址

Extended commands [n]: y

Source address or interface: 1.1.1.1     源地址

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.1, timeout is 2 seconds:

Packet sent with a source address of 1.1.1.1

.....   表示Ping不通

下面在R2上設置RIP認證

  2.R2

 rack02(config)#key chain cisco      !設置名稱爲cisco

rack02(config-keychain)#key 1

rack02(config-keychain-key)#key-string 1234    !設置密碼爲1234

rack02(config-keychain-key)#int s1/0

rack02(config-if)#ip rip authentication mode text   !設置加密方式爲text(明文加密)

rack02(config-if)#ip rip authentication key cisco

查看測試結果:

rack02#ping

Target IP address: 1.1.1.1   目標地址

Extended commands [n]: y

Source address or interface: 2.2.2.1   源地址

Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:

!!!!!  已經能夠Ping通了

(四)RIP彙總

    1.R1

      rack01(config)#int s1/0

      rack01(config-if)#ip summary-address rip 1.1.0.0 255.255.252.0  

       !將LOOP口的全部IP彙總成1.1.0.0這個網段,它表示LOOP口裏全部IP

     2.R2

      rack02(config)#int s1/0

rack02(config-if)#ip summary-address rip 2.2.0.0 255.255.248.0

!將LOOP口的全部IP彙總成2.2.0.0這個網段,它表示LOOP口裏全部IP

查看彙總後的R1和R2的路由表有什麼變化:

rack01#show ip route

        1.0.0.0/24 is subnetted, 2 subnets

C       1.1.1.0 is directly connected, Loopback0

C       1.1.2.0 is directly connected, Loopback2

     2.0.0.0/21 is subnetted, 1 subnets

R       2.2.0.0 [120/1] via 199.99.1.2, 00:00:12, Serial1/0

     3.0.0.0/24 is subnetted, 1 subnets

C       3.3.1.0 is directly connected, Loopback1

C    199.99.1.0/24 is directly connected, Serial1/0

rack02#sho ip route

    1.0.0.0/22 is subnetted, 1 subnets

R       1.1.0.0 [120/1] via 199.99.1.1, 00:00:15, Serial1/0

     2.0.0.0/24 is subnetted, 4 subnets

C       2.2.1.0 is directly connected, Loopback0

C       2.2.2.0 is directly connected, Loopback1

C       2.2.3.0 is directly connected, Loopback2

C       2.2.4.0 is directly connected, Loopback3

     3.0.0.0/24 is subnetted, 1 subnets

R       3.3.1.0 [120/1] via 199.99.1.1, 00:00:15, Serial1/0

C    199.99.1.0/24 is directly connected, Serial1/0

(五)利用標準ACL阻止rack01上的3.3.0.1訪問rack02

      1.在R2上設置標準ACL

        rack02(config)#access-list 10 deny 3.3.1.0 0.0.0.255

        rack02(config)#access-list 10 permit any

如今在rack01上的3.3.1.1  Ping仍是能夠Ping通rack02裏的地址,由於rack02有一個刷新路由表的時間,這個時間是30秒,當超過180秒(RIP的Holdown時間)的時候,路由表就視爲3.3.1.0網段不可達了,在過了這180秒之後,3.3.1.1就不可以Ping通rack02上的地址了。

如今看一下測試結果(180秒之後):

rack01#ping

Target IP address: 2.2.2.1    目標地址

Source address or interface: 3.3.1.1    源地址

Sending 5, 100-byte ICMP Echos to 2.2.2.1, timeout is 2 seconds:

Packet sent with a source address of 3.3.1.1

.....

Success rate is 0 percent (0/5)

如今能夠看一下rack02上的路由表:

rack02#show ip route

   

     1.0.0.0/22 is subnetted, 1 subnets

R       1.1.0.0 [120/1] via 199.99.1.1, 00:00:14, Serial1/0    !R1的網段

     2.0.0.0/24 is subnetted, 4 subnets

C       2.2.1.0 is directly connected, Loopback0

C       2.2.2.0 is directly connected, Loopback1

C       2.2.3.0 is directly connected, Loopback2

C       2.2.4.0 is directly connected, Loopback3

C    199.99.1.0/24 is directly connected, Serial1/0

 

總結:從上面路由表中能夠看出rack02路由表中已通過濾掉了3.3.1.0網段的信息

 

以上是RIP的認證,下面爲OSPF骨幹區域的認證。

 

(六)OSPF的認證

      只將RIP認證的步驟(三)改爲OSPF的三條命令就能夠了

1.Text(明文加密)

  router(config)#router osfp 100

router(config)#area 0 authentication

  router(config)#int s1/0        !進入某個端口

 router(config-if)#ip ospf authentication-key ******(密碼)

2.MD5(密文加密)

  router(config)#router osfp 100

          router(config)#area 0 authentication message-digest

          router(config)#int s1/0

          router(config-if)#ip ospf authentication message-digest

          router(config-if)#ip ospf message-digest-key + 號碼 md5 + ***(密碼) 

                          !號碼:能夠任意

 

結課總結

  1、網絡的類型:(1)point to point 點到點  

 

              

 

 

(2)NBMA  幀中繼非廣播多路訪問

               

                                               
     
     
   
       
                             
 
 
 
       
 
     
       
 

 

 

 

 

(3)廣播

(4)虛電路

 

2、路由協議

  1.分類:靜態路由協議、動態路由協議(RIP,IGRP,EIGRP,OSPF,IS-IS)

  2.各路由協議之間的區別

    (1)管理距離(distance)(默認)

RIP: 120    IGRP:100      EIGRP:內  90   外  170  

 OSPF:110    IS—IS:115    靜態路由:1     直連路由:0

        (2)Hold-down時間

             RIP:180秒   IGRP:280秒   EIGRP:240秒 

        (3)更新時間

             RIP:30秒    IGRP:90       EIGRP:

        (4)無效時間

             RIP:180秒   IGRP:270秒

        (5)度量值(metric)

             RIP:是以跳數做爲度量值,它的最大跳數15

IGRP:帶寬(bandwidth),延遲(delay),可靠性(reliability),負載(load)

              最大傳輸單元(Mtu),而它的默認跳數爲:100,

EIGRP:以帶寬和延遲做爲度量值,它的跳數爲100  

  注:IGRP,EIGRP的最大跳數可擴充到255

OSPF是以開銷(cost)爲度量值,cost默認爲64

     (6)OSPF(1)Hello的時間間隔:1.在P-P(點到點)環境下,默認爲10秒

                                        2.在NBMA環境下,默認爲30秒

              (2)死亡時間間隔:1.在P-P(點到點)環境下,默認爲40秒

                                   2.在NBMA環境下,默認爲120秒

  3.AS 自治系統號(只有IGRP,EIGRP,OSPF有)

     範圍:1——65535     其中64512——65535爲私有自治系統號

 

4.幾個實用命令

(1)將端口裏的全部信息,還原成默認狀態

    Router(config)#default int s1/0  

(2)將全部設置的密碼轉換成密文加密

    Router(config)#service password-encryption

(3)查看當前相鄰設備的信息

    Router#show cdp neighbor

(4)查看相鄰設備的詳細信息

    Router#show cdp neighbor detail

(5)設置帶寬

    Router(config)#int s1/0

    Router(config-if)#bandwidth 

(6)Router#show ip packet

     5.幾個路由協議符號的表示

    (1)S – static 靜態路由   R – RIP   D – EIGRP    O - OSPF

         S*  表示缺省路由    

         O E2 表示OSPF在外部學來的路由

         O*RA 表示OSPF在不一樣區域學來的路由

         D*EX  表示EIGRP從外部學來的路由

相關文章
相關標籤/搜索