大家好,這裡是G-LAB IT實驗室。今天帶領大家學習思科路由器進階配置,可以點贊收藏!
- 路由基本配置
- 配置靜态路由
- RIP 動态路由
- OSPF 動态路由
- 實戰:配置RIP企業環境
路由器(Router),是連接配接網際網路中各區域網路、廣域網的裝置,它會根據信道的情況自動選擇和設定路由,以最佳路徑,按前後順序發送信号,路由器工作在網絡層,用來跨網段通信,路由器具有判斷網絡位址和選擇IP路徑的功能,它能在多網絡互聯環境中,建立靈活的連接配接,可用完全不同的資料分組和媒體通路方法連接配接各種子網,路由器隻接受源站或其他路由器的資訊,屬網絡層的一種互聯裝置,是以路由器是網際網路中必不可少的網絡裝置之一.
路由器,其最重要的功能就是路由,路由是指路由器接收到資料時選擇最佳路徑将資料穿過網絡傳輸到目标位址的行為,每個路由器負責自己的本地資料的路由或轉發,通過多個路由器依次接力将資料最終傳遞到目标主機,路由的工作流程包括路由選擇和路由轉發兩個方面.
路由基本配置
路由器與交換機不同,交換機不需要配置也可以正常工作,但是路由器必須經過配置後才可以正常使用,路由器的登陸方式基本和交換機保持一緻,下面将用一個執行個體實作路由器的基本配置,包括配置路由器的主機名稱,密碼,控制台端口,WAN接口和LAN接口等,來實作一個基本的路由結構.
首先我們準備兩台路由器(1841型号),需要注意的是裝置之間的連接配接所選用的線路類型,一般情況下路由器和PC之間使用交叉線,兩台路由器相連接配接使用串行線,配置成以下拓撲結構即可:
但在實際連接配接兩個路由器時,發現沒有Serial接口,這是因為該型号的路由器預設沒有提供序列槽,我們可以在思科模拟器上選擇WIC-2T子產品,并将其拖入空的插槽處,重新開機交換機即可完成配置.
接着來看一下網絡拓撲結構中,每個裝置的具體配置參數,包括類型,IP位址,預設網關等資訊.
[裝置名稱] [裝置接口] [IP位址] [預設網關]
PC1 --- 192.168.1.2/24 192.168.1.1
PC2 --- 192.168.2.2/24 192.168.2.1
Router0 Fa0/0 192.168.1.1/24 ---
Serial0/0/0 10.10.10.10/24 ---
Router1 Fa0/0 192.168.2.1/24 ---
Serial0/0/0 10.10.10.20/24 ---
開啟路由遠端登陸: 這裡我們将啟用Router1路由器的遠端登陸功能,并設定一個登陸密碼為lyshark.
Router# enable
Router# configure terminal
Router(config)# hostname Router0 // 配置主機名為Router0
Router0(config)# enable secret lyshark // 配置特權模式密碼為lyshark
Router0(config)# line console 0 // 啟用控制台
Router0(config-line)# password lyshark // 設定控制台登入密碼
Router0(config-line)# login // 允許使用者登入
Router0(config-line)# exit
Router0(config)# line vty 0 2 // 配置序号為0-2的3個虛拟登陸終端
Router0(config-line)# password lyshark // 配置終端登入密碼
Router0(config-line)# login // 啟用登陸終端
配置WAN接口: 路由器通過WAN接口接入到網際網路上,而常見的WAN接口都是串行接口用Serial表示,首先可以使用show controller指令判斷Serial0/0/0是否為DCE端,然後決定是否要配置.
Router0> show controller Serial0/0/0
Interface Serial0/0/0
Hardware is PowerQUICC MPC860
DCE V.35, clock rate 2000000 // 此處判斷是DEC端
根據上述标注顯示内容Srial0/0/0為DCE端口,下面需要對兩台路由分别配置時鐘頻率.
#----在Router0上操作-------------------------
Router0> enable
Router0# configure terminal
Router0(config)# interface Serial0/0/0 // 選擇串行接口Srial0/0/0
Router0(config-if)# ip address 10.10.10.10 255.255.255.0 // 配置外網IP位址
Router0(config-if)# clock rate 64000 // 配置始終頻率為6400
Router0(config-if)# no shutdown // 開啟端口
#----在Router1上操作-------------------------
Router1> enable
Router1# configure terminal
Router1(config)# interface Serial0/0/0
Router1(config-if)# ip address 10.10.10.20 255.255.255.0
Router1(config-if)# clock rate 64000
Router1(config-if)# no shutdown
配置LAN接口: LAN接口用來指定内網通訊的位址,接下來分别對兩台路由器做配置.
#----在Router0上操作-------------------------
Router0> enable
Router0# configure terminal
Router0(config)# interface fa0/0 // 選擇以太網接口fa0/0
Router0(config)# ip address 192.168.1.1 255.255.255.0
Router0(config)# no shutdown
#----在Router1上操作-------------------------
Router1> enable
Router1# configure terminal
Router1(config)# interface fa0/0
Router1(config)# ip address 192.168.2.1 255.255.255.0
Router1(config)# no shutdown
查配置資訊: 最後可以使用show ip route指令,檢視路由器的路由資訊,确定網絡是否正确連接配接.
Router0# show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
i - IS-IS, 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
10.0.0.0/24 is subnetted, 1 subnets
C 10.10.10.0 is directly connected, Serial0/0/0 // 外網位址
C 192.168.1.0/24 is directly connected, FastEthernet0/0 // 内網位址
查接口資訊: 也可以使用show ip interface brief指令,檢視路由器的接口資訊.
Router0# show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.1.1 YES manual up up
Serial0/0/0 10.10.10.10 YES manual up up
Serial0/0/1 unassigned YES unset administratively down down
Vlan1 unassigned YES unset administratively down down
最後測試通信: 在路由器Route0上可以ping通Route1,每個主機也可以ping通自己網段的路由器.
Router0# ping 10.10.10.20
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.20, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/6 ms
上述小實驗到這裡就算配置成功了,但是這裡留下了一個疑問,那就是PC0PingPC1無法通信,這就涉及到路由器沒有相應的路由條目的問題,這些問題将在後面小實驗中做解釋.
配置靜态路由
靜态路由需要管理者根據實際需求一條條自己手動配置,路由器不會自動生成所需的靜态路由,靜态路由中包括目标節點或目标網絡的IP位址,還可以包括下一跳IP位址,以及在本路由器上使用該靜态路由時的資料包出接口等,但是手動配置靜态路由需要管理者非常了解網絡的拓撲結構才能夠完成配置,在網絡規模較大時還需要耗費大量的經曆和時間去維護,是以并不是所有的網絡都适合配置靜态路由.
一般情況下以下幾種情況可以考慮使用靜态路由
1.網絡的拓撲結構相對較簡單,比如就一台路由器和交換機的情況,可使用靜态路由.
2.網絡保密性要求較高,網絡管理者需要控制鍊路或者控制路由表,則可使用靜态路由.
3.網絡僅通過單個ISP接入Internet,則該ISP就是網絡唯一的出口,是以不需要配置靜态路由.
4.路由資源有限,無法運作路由選擇協定,在這種情況下,需要手動配置路由條目來更新路由表資料.
接下來以一個執行個體具體介紹靜态路由的配置流程,在思科模拟器中選擇2台1841路由器,按照以下網絡拓撲結構建構網路,然後為每台路由器配置靜态路由,實作不同網絡間的資料互通.
配置客戶主機: 首先我們根據上圖的配置要求配置好IP位址網關等資料,下面的參數是具體的位址規劃.
[裝置名稱] [裝置接口] [IP位址] [預設網關]
PC0 --- 192.168.1.2/24 192.168.1.1
PC1 --- 192.168.1.3/24 192.168.1.1
PC2 --- 192.168.2.2/24 192.168.2.1
PC3 --- 192.168.2.3/24 192.168.2.1
Router0 Fa0/0 192.168.1.1/24 ---
Serial0/0/0 10.10.10.10/24 ---
Router1 Fa0/0 192.168.2.1/24 ---
Serial0/0/0 10.10.10.20/24 ---
配置路由器: 接着我們分别給路由器配置好位址參數,在這裡fa0/0端口是内網IP位址,serial0/0/0端口則是外網IP位址,配置是應注意次序,如果配反了則看不到效果.
#----在Router0上操作-------------------------
Router0> enable
Router0# configure terminal
Router0(config)# interface fa0/0 // 配置内網位址
Router0(config-if)# ip address 192.168.1.1 255.255.255.0
Router0(config-if)# no shutdown
Router0(config)# interface serial0/0/0 // 配置外網位址
Router0(config-if)# clock rate 64000
Router0(config-if)# ip address 10.10.10.10 255.255.255.0
Router0(config-if)# no shutdown
#----在Router1上操作-------------------------
Router0> enable
Router0# configure terminal
Router1(config)# interface fa0/0 // 配置内網位址
Router1(config-if)# ip address 192.168.2.1 255.255.255.0
Router1(config-if)# no shutdown
Router1(config)# interface serial0/0/0 // 配置外網位址
Router1(config-if)# clock rate 64000
Router1(config-if)# ip address 10.10.10.20 255.255.255.0
Router1(config-if)# no shutdown
檢測路由配置: 當配置好上面的步驟以後,PC0與PC1主機是可通信的,Route0與Route1也可通信,但PC0無法與PC3通信,原因就是因為路由器沒有配置靜态路由的關系,這一步我們隻需要確定同一個網段内能通信即可.
#----在PC0上操作-------------------------
PC0> ping 192.168.1.1
PC0> ping 192.168.1.2
PC0> ping 192.168.1.3
Pinging 192.168.1.3 with 32 bytes of data:
Reply from 192.168.1.3: bytes=32 time=0ms TTL=128
#----在Route0上操作----------------------
Router0#ping 10.10.10.20
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.20, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/7/12 ms
配置靜态路由: 接下來我們需要在兩台路由器上分别配置路由條目,使用ip route指令配置,如果想要删除路由可使用no ip route指令即可删除指定路由條目.
#----在Router0上操作-------------------------
Router0> enable
Router0# configure terminal
[目的網絡] [目的掩碼] [下一跳位址]
Router0(config)# ip route 192.168.2.0 255.255.255.0 10.10.10.20
#----在Router1上操作-------------------------
Router1> enable
Router1# configure terminal
Router1(config)# ip route 192.168.1.0 255.255.255.0 10.10.10.10 // 指定傳回時的路由
#----檢查配置參數情況-------------------------
Router0# show ip interface brief // 顯示端口ip
Router0# show ip route // 檢查路由參數
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
i - IS-IS, 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
10.0.0.0/24 is subnetted, 1 subnets
C 10.10.10.0 is directly connected, Serial0/0/0
C 192.168.1.0/24 is directly connected,FastEthernet0/0
S 192.168.2.0/24 [1/0] via 10.10.10.20
最後的測試: 當配置好路由條目以後,我們在PC0主機上Ping檢測PC3的連通性,會發現原來無法連通的兩個網段,現在可以正常通信了,也就說明我們的路由配置生效了.
PC0> ping 192.168.2.2
Pinging 192.168.2.2 with 32 bytes of data:
Reply from 192.168.2.2: bytes=32 time=12ms TTL=126
Ping statistics for 192.168.2.2:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 12ms, Maximum = 12ms, Average = 12ms
以上的路由配置方法,适用于小型網絡環境,在大型網絡環境中這種靜态路由的配置方式很不适合維護,一旦裝置過多,則可能自己都搞不清頭緒,是以在生産環境中,我們會使用動态路由的方式來實作路由器的配置,接下來繼續學習動态路由的配置方式吧.
RIP 動态路由
動态路由是基于某種協定實作的,常見的路由協定有内内部網關協定(IGP)和邊界網關協定(BGP),其中内部網關協定又分為路由資訊協定(RIP)和開放式最短路徑優先協定(OSPF)協定.
其中RIP(路由資訊協定)是最先被廣泛應用的内部網關路由協定,RIP使用跳數來衡量到達目标位址的距離,跳數是指資料從源位址到達目标位址之間經過的路由器個數.從路由器到直接連接配接的網絡的跳數定義為1,每經過一個路由器則數值會增加1,RIP允許的最大跳數是15跳,超過15跳的網絡将無法到達,是以RIP适合用于小型的網絡環境中.
RIP協定預設會每隔30秒就會與其他相連的網絡廣播自己的路由表,收到廣播的路由器會将收到的資訊與自己路由表進行比較,判斷是否将其中的路由條目加入到自己的路由表中,目前RIP共有3中版本,RIPv1,RIPv2,RIPng,其中RIPng應用于IPv6網絡環境中,RIPv1是有類路由協定,RIPv2則是無類路由協定.
配置參數簡介: 首先我們根據上圖的配置要求配置好路由器各種基本參數,下面的參數是具體的位址規劃.
[裝置名稱] [裝置接口] [IP位址] [預設網關]
Router1 Serial0/0/0 192.168.10.1/24 ---
Router2 Serial0/0/0 192.168.10.2/24 ---
Serial0/0/1 192.168.20.1/24 ---
Router3 Serial0/0/0 192.168.20.2/24 ---
Serial0/0/1 192.168.30.1/24 ---
Router4 Serial0/0/0 192.168.30.2/24 ---
配置路由器: 根據上表的結構配置好路由器的各種參數,主要配置路由器的接口IP位址.
Router>enable
Router#configure terminal
#----在Router1上操作-------------------------
Router1(config)# interface Serial0/0/0
Router1(config-if)# ip address 192.168.10.1 255.255.255.0
Router1(config-if)# no shutdown
#----在Router2上操作-------------------------
Router2(config)# interface Serial0/0/0
Router2(config-if)# ip address 192.168.10.2 255.255.255.0
Router1(config-if)# no shutdown
Router2(config)# interface Serial0/0/1
Router2(config-if)# ip address 192.168.20.1 255.255.255.0
Router1(config-if)# no shutdown
#----在Router3上操作-------------------------
Router3(config)# interface Serial0/0/0
Router3(config-if)# ip address 192.168.20.2 255.255.255.0
Router1(config-if)# no shutdown
Router3(config)# interface Serial0/0/1
Router3(config-if)# ip address 192.168.30.1 255.255.255.0
Router1(config-if)# no shutdown
#----在Router4上操作-------------------------
Router4(config)#interface Serial0/0/0
Router4(config-if)#ip address 192.168.30.2 255.255.255.0
Router1(config-if)# no shutdown
配置并啟用RIP路由: 在每台路由器上啟用并配置好RIP動态路由.
Router>enable
Router#configure terminal
#----在Router1上啟用RIP路由協定并配置-------------------
Router1(config)# router rip // 啟用RIP路由
Router1(config-router)# version 2 // 指定使用RIP版本為RIPv2
Router1(config-router)# network 192.168.10.0 // 聲明與Router1直連的網絡号
Router1(config-router)# exit
#----在Router2上啟用RIP路由協定并配置-------------------
Router2(config)# router rip
Router2(config-router)# version 2
Router2(config-router)# network 192.168.10.0 // 聲明與Router2直連的網絡号
Router2(config-router)# network 192.168.20.0 // 聲明與Router3直連的網絡号
Router2(config-router)# exit
#----在Router3上啟用RIP路由協定并配置-------------------
Router3(config)# router rip
Router3(config-router)# version 2
Router3(config-router)# network 192.168.20.0 // 聲明與Router3直連的網絡号
Router3(config-router)# network 192.168.30.0 // 聲明與Router4直連的網絡号
Router3(config-router)# exit
#----在Router4上啟用RIP路由協定并配置-------------------
Router4(config)# router rip
Router4(config-router)# version 2
Router4(config-router)# network 192.168.30.0 // 聲明與Router4直連的網絡号
Router4(config-router)# exit
檢查配置資訊: 配置完成後,在Router1上執行show ip route 指令檢視RIP配置結果,如下.
Router1#show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
i - IS-IS, 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
C 192.168.10.0/24 is directly connected, Serial0/0/0
R 192.168.20.0/24 [120/1] via 192.168.10.2, 00:00:01, Serial0/0/0 // R表示目前是RIP路由
R 192.168.30.0/24 [120/2] via 192.168.10.2, 00:00:01, Serial0/0/0 // 路由條目是RIP自動生成的
測試連通性: 此時我們在Router1路由器上Ping路由器Router4是可以通信的,說明配置成功了.
Router1#ping 192.168.30.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.30.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 3/15/27 ms
OSPF 動态路由
在上面的配置試驗中我們通過使用RIP協定完成了一個路由器之間的資料通信,但是RIP協定最大僅僅支援15個路由節點,雖然在中小型網絡中這些節點足夠使用了,但是在一些大型企業中往往需更多的跳數,就是因為這種需求我們的OSPF協定就由此誕生啦.
OSPF(開放式最短路徑優先),該協定是基于鍊路狀态的協定規範,是以也可以稱為鍊路狀态協定,和RIP協定相同,OSPF協定同樣使用跳數計量路徑開銷,但是與RIP不同的是,OSPF協定不受實體跳數的限制,其路徑開銷與網絡中的鍊路開銷等相關.
OSPF協定采用了FPS算法來計算最短路徑數,SPF算法将每一個路由作為根(ROOT),來計算其資料包到達每一個目标路由器之間的距離,每個路由器根據一個統一的資料庫LSDB計算出路由域的拓撲結構圖,該結構很像是一顆樹,是以就叫做最短路徑樹.
OSPF協定的優點
1.OSPF采用了SPF算法,進而可以很好的避免路由器環路的産生.
2.OSPF協定雖然也使用跳數作為計量機關,但不受實體跳數的限制.
3.當網絡鍊路狀态發生變化時,OSPF能夠迅速捕捉并應用,收斂快,路由資訊流量小.
4.OSPF路由協定支援路由認證體系,且還可以定義不同的認證方式,提高了網絡安全性.
5.OSPF協定提供了較好的負載均衡性,其資料更新比較智能,相應的減小了網絡流量的帶寬.
在配置OSPF路由之前還有一個小知識點需要補充,在下面的配置試驗中你會看到例如0.0.0.255這樣的網絡号,這種網絡号被稱作通配符掩碼,通常情況下通配符掩碼可由,255.255.255.255(廣播位址)減去目前的255.255.255.0(子網路遮罩),來獲得,此處小實驗的通配符掩碼為0.0.0.255 area 0.
接下來開始步入正題,我們還是使用RIP路由的拓撲結構以及IP位址的配置都相同,但是這裡在配置動态路由的時候,我們使用OSPF的方式來配置,過程如下:
配置路由器: 首先更具上表的結構配置好路由器的各種參數.
Router>enable
Router#configure terminal
#----在Router1上操作-------------------------
Router1(config)# interface Serial0/0/0
Router1(config-if)# ip address 192.168.10.1 255.255.255.0
Router1(config-if)# no shutdown
#----在Router2上操作-------------------------
Router2(config)# interface Serial0/0/0
Router2(config-if)# ip address 192.168.10.2 255.255.255.0
Router1(config-if)# no shutdown
Router2(config)# interface Serial0/0/1
Router2(config-if)# ip address 192.168.20.1 255.255.255.0
Router1(config-if)# no shutdown
#----在Router3上操作-------------------------
Router3(config)# interface Serial0/0/0
Router3(config-if)# ip address 192.168.20.2 255.255.255.0
Router1(config-if)# no shutdown
Router3(config)# interface Serial0/0/1
Router3(config-if)# ip address 192.168.30.1 255.255.255.0
Router1(config-if)# no shutdown
#----在Router4上操作-------------------------
Router4(config)# interface Serial0/0/0
Router4(config-if)# ip address 192.168.30.2 255.255.255.0
Router1(config-if)# no shutdown
配置并啟用OSPF路由: 在每台路由器上啟用并配置好OSPF動态路由.
Router>enable
Router#configure terminal
#----在Router1上啟用OSPF路由協定并配置-------------------
Router1(config)# router ospf 1 // 啟用OSPF路由,并設定程序号為1
Router1(config-router)# router-id 1.1.1.1 // 為Router1配置RID編号
Router1(config-router)# network 192.168.10.0 0.0.0.255 area 0 // 配置路由記錄
Router1(config-router)# exit
#----在Router2上啟用OSPF路由協定并配置-------------------
Router2(config)# router ospf 1 // 啟用OSPF路由,并設定程序号為1
Router2(config-router)# router-id 2.2.2.2 // 為Router2配置RID編号
Router2(config-router)# network 192.168.10.0 0.0.0.255 area 0 // 配置路由記錄
Router2(config-router)# network 192.168.20.0 0.0.0.255 area 0
Router2(config-router)# exit
#----在Router3上啟用OSPF路由協定并配置-------------------
Router3(config)# router ospf 1 // 啟用OSPF路由,并設定程序号為1
Router3(config-router)# router-id 3.3.3.3 // 為Router3配置RID編号
Router3(config-router)# network 192.168.20.0 0.0.0.255 area 0
Router3(config-router)# network 192.168.30.0 0.0.0.255 area 0
Router3(config-router)# exit
#----在Router4上啟用OSPF路由協定并配置-------------------
Router3(config)# router ospf 1 // 啟用OSPF路由,并設定程序号為1
Router3(config-router)# router-id 4.4.4.4 // 為Router4配置RID編号
Router3(config-router)# network 192.168.30.0 0.0.0.255 area 0
Router3(config-router)# exit
檢查配置資訊: 配置完成後,在Router1上執行show ip route 指令檢視OSPF配置結果,如下.
Router#show ip route
Codes: C - connected, S - static, I - IGRP, 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, E - EGP
i - IS-IS, 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
C 192.168.10.0/24 is directly connected, Serial0/0/0 // C表示是本機預設路由
O 192.168.20.0/24 [110/128] via 192.168.10.2, 00:02:25, Serial0/0/0 // O表示目前是OSPF路由
O 192.168.30.0/24 [110/192] via 192.168.10.2, 00:01:55, Serial0/0/0 // 路由條目是OSPF自動生成的
測試連通性: 此時我們在Router1路由器上Ping路由器Router4是可以通信的,說明配置成功了.
Router1#ping 192.168.30.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.30.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 3/15/27 ms
實戰:配置RIP企業環境
接下來,我們通過使用三層交換機配合路由器,來實作一個跨網段通信的案例,其配置流程是,首先配置三層交換機并劃分好VLAN的層次,接着在配置Router0這裡不需要配置VLAN,原因是三層交換機與Router0共享VLAN,最後在配置外網口的Router1路由器,其拓撲結構如下圖所示:
配置三層交換: 首先先來配置三層交換機,建立3個VLAN,并劃分成三個VLAN虛拟區域網路.
Switch> enable
Switch# configure terminal
#----配置三層交換的VLAN10并把端口fa0/1加入到VLAN-------------------
Switch(config)# vlan 10 // 建立VLAN10
Switch(config-vlan)# interface fa0/1 // 将Fa1倆端口加入到VLAN10
Switch(config-if-range)# switchport mode access
Switch(config-if-range)# switchport access vlan 10 // 把端口加入到VLAN10
Switch(config-if-range)# no shutdown // 啟用端口
Switch(config-if-range)# exit
#----配置三層交換的VLAN20并把端口fa0/2加入到VLAN-------------------
Switch(config)# vlan 20
Switch(config-vlan)# interface fa0/2
Switch(config-if-range)# switchport mode access
Switch(config-if-range)# switchport access vlan 20
Switch(config-if-range)# no shutdown
Switch(config-if-range)# exit
#----配置三層交換的VLAN30并把端口fa0/3加入到VLAN-------------------
Switch(config)# vlan 30
Switch(config-vlan)# interface fa0/3
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 30
Switch(config-if)# no shutdown
Switch(config-if)# exit
配置三層交換IP位址: 給上面配置設定好的三個VLAN虛拟區域網路一個IP位址,這裡指定為各自的網關位址就好.
Switch> enable
Switch# configure terminal
#----給三層交換的VLAN10内的主機添加網關-------------------
Switch(config)# interface vlan 10 // 選擇vlan10接口
Switch(config-if)# ip address 192.168.1.1 255.255.255.0 // 配置網關位址
Switch(config-if)# no shutdown // 開啟端口
Switch(config-if)# exit
#----給三層交換的VLAN20内的主機添加網關-------------------
Switch(config)# interface vlan 20 // 選擇vlan20接口
Switch(config-if)# ip address 192.168.2.1 255.255.255.0 // 配置網關位址
Switch(config-if)# no shutdown // 開啟端口
Switch(config-if)# exit
#----給三層交換的VLAN30内的主機添加網關-------------------
Switch(config)# interface vlan 30 // 選擇vlan30接口
Switch(config-if)# ip address 192.168.3.1 255.255.255.0 // 配置網關位址
Switch(config-if)# no shutdown // 開啟端口
Switch(config-if)# exit
配置路由器Router0: 配置好網關後,接着配置路由器Router0,配置接口IP位址,注意在DCE接口需要配置時鐘.
Router> enable
Router# configure terminal
#----配置路由fa0/0端口的IP位址-------------------
Router0(config)# interface fa0/0
Router0(config-if)# ip address 192.168.3.2 255.255.255.0
Router0(config-if)# no shutdown
Router0(config-if)# exit
#----配置路由fa0/1端口的IP位址-------------------
Router0(config)# interface fa0/1
Router0(config-if)# ip address 192.168.4.1 255.255.255.0
Router0(config-if)# no shutdown
Router0(config-if)# exit
#----配置路由se0/0/0連接配接外網端口IP----------------
Router0(config)# interface se0/0/0
Router0(config-if)# ip address 1.1.1.1 255.0.0.0
Router0(config-if)# no shutdown
Router0(config-if)# exit
配置路由器Router1: 最後配置外網與内網的銜接路由器Router1,配置好外網口IP位址以及内網口位址.
Router> enable
Router# configure terminal
#----配置路由器1的内網口位址-------------------
Router1(config)# interface se0/0/0
Router1(config-if)# ip address 1.1.1.2 255.0.0.0
Router1(config-if)# no shutdown
Router1(config-if)# exit
#----配置路由器1的外網口位址-------------------
Router1(config)# interface fa0/0
Router1(config-if)# ip address 10.10.10.10 255.0.0.0
Router1(config-if)# no shutdown
開啟三層交換機路由: 開啟三層交換機路由功能,并配置RIP動态路由,指明每個路由器的網段位址.
Switch(config)# ip routing
Switch(config)# router rip
Switch(config-router)# network 192.168.1.0
Switch(config-router)# network 192.168.2.0
Switch(config-router)# network 192.168.3.0
Switch(config-router)# network 192.168.4.0
配置二層路由器RIP: 最後還需要分别配置兩個路由器并開啟其路由功能
#----配置路由器Router0-------------------
Router0(config)# router rip
Router0(config-router)# network 192.168.3.0
Router0(config-router)# network 192.168.4.0
#----配置路由器Router1-------------------
Router1(config)# route rip
Router1(config-router)# network 192.168.3.0
Router1(config-router)# network 192.168.4.0
Router1(config-router)# network 192.168.4.0
Router1(config-router)# network 1.1.1.1
以上配置流程就是全部的實驗配置過程,在配置完成功能後,我們首先通過使用ping指令來測試内部主機是否能夠Ping通,最後的實驗結果是,内網主機均可以實作通信,外網主機無法和内網主機通信.
關注 工 仲 好:IT運維大學營,擷取60個G的《網工系統大禮包》+1000頁Linux學習筆記