GNS3路由配置綜合實驗(OSPF協議、RIP協議、靜態路由、默認路由)

實驗環境:

理論之前的博客已經寫過,這次直接實驗。
具體拓撲圖如下,注意R3接口不夠,需要添加兩個NM-1FE-TX單板。

GNS3路由配置綜合實驗(OSPF協議、RIP協議、靜態路由、默認路由)

實際操作:

1.配置R1。

R1#conf t                                          //進入全局模式
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#int f0/0                          //進入接口模式
R1(config-if)#ip add 192.168.10.1 255.255.255.0                         //設置IP地址與子網掩碼
R1(config-if)#no shut                     //開啓接口
R1(config-if)#
*Mar  1 00:01:35.883: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:01:36.883: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#int f0/1                          //進入接口模式
R1(config-if)#ip add 192.168.20.1 255.255.255.0                         //設置IP地址與子網掩碼
R1(config-if)#no shut                     //開啓接口
R1(config-if)#
*Mar  1 00:01:59.307: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:02:00.307: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R1(config-if)#exit                            //退出
R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.20.2                         //添加默認路由
R1(config)#

2.配置R2。

R2#conf t                                          //進入全局模式
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#int f0/0                          //進入接口模式
R2(config-if)#ip add 192.168.30.1 255.255.255.0                         //設置IP地址與子網掩碼
R2(config-if)#no shut                     //開啓接口
R2(config-if)#
*Mar  1 00:04:47.727: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:04:48.727: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2(config-if)#int f0/1                          //進入接口模式
R2(config-if)#ip add 192.168.20.2 255.255.255.0                         //設置IP地址與子網掩碼
R2(config-if)#no shut                     //開啓接口
R2(config-if)#
*Mar  1 00:05:11.091: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:05:12.091: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R2(config-if)#exit                            //退出
R2(config)#router ospf 1               //啓用ospf協議,進程號爲1
R2(config-router)#router-id 2.2.2.2               //設置router-id
R2(config-router)#network 192.168.30.0 0.0.0.255 area 1                      //宣告網段
R2(config-router)#exit                            //退出
R2(config)#ip route 192.168.10.0 255.255.255.0 192.168.20.1             //添加靜態路由
R2(config)#router ospf 1                        //進入ospf 協議
R2(config-router)#redistribute connected subnets                                  //OSPF引入直連網段
R2(config-router)#redistribute static subnets                                           //OSPF引入靜態路由
R2(config-router)#exit                            //退出
R2(config)#
*Mar  1 00:16:38.251: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on FastEthernet0/0 from LOADING to FULL, Loading Done
R2(config)#

3.配置R3。

R3#conf t                                          //進入全局模式
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#int f0/0                          //進入接口模式
R3(config-if)#ip add 192.168.30.2 255.255.255.0                         //設置IP地址與子網掩碼
R3(config-if)#no shut                     //開啓接口
*Mar  1 00:11:13.671: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:11:14.671: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R3(config-if)#int f0/1                          //進入接口模式
R3(config-if)#ip add 192.168.40.1 255.255.255.0                         //設置IP地址與子網掩碼
R3(config-if)#no shut                     //開啓接口
R3(config-if)#
*Mar  1 00:11:33.875: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:11:34.875: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R3(config-if)#int f1/0                          //進入接口模式
R3(config-if)#ip add 12.0.0.1 255.255.255.0                         //設置IP地址與子網掩碼
R3(config-if)#no shut                     //開啓接口
R3(config-if)#
*Mar  1 00:11:57.195: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up
*Mar  1 00:11:58.195: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up
R3(config-if)#int f2/0                          //進入接口模式
R3(config-if)#ip add 192.168.70.1 255.255.255.0                         //設置IP地址與子網掩碼
R3(config-if)#no shut                     //開啓接口
R3(config-if)#
*Mar  1 00:12:21.339: %LINK-3-UPDOWN: Interface FastEthernet2/0, changed state to up
*Mar  1 00:12:22.339: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet2/0, changed state to up
R3(config-if)#exit                            //退出
R3(config)#ip route 0.0.0.0 0.0.0.0 12.0.0.2                         //添加默認路由
R3(config)#router ospf 1               //啓用ospf協議,進程號爲1
R3(config-router)#router-id 3.3.3.3               //設置router-id
R3(config-router)#network 192.168.30.0 0.0.0.255 area 1                      //宣告網段
R3(config-router)#
*Mar  1 00:15:28.199: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/0 from LOADING to FULL, Loading Done
R3(config-router)#network 192.168.40.0 0.0.0.255 area 0                      //宣告網段
R3(config-router)#network 192.168.70.0 0.0.0.255 area 0                      //宣告網段
R3(config-router)#default-information originate                                        //OSPF引入默認路由
R3(config-router)#exit                            //退出
R3(config)#
*Mar  1 00:34:42.595: %OSPF-5-ADJCHG: Process 1, Nbr 4.4.4.4 on FastEthernet0/1 from LOADING to FULL, Loading Done
R3(config)#

4.配置R4。

R4#conf t                                          //進入全局模式
Enter configuration commands, one per line.  End with CNTL/Z.
R4(config)#int f0/0                          //進入接口模式
R4(config-if)#ip add 192.168.40.2 255.255.255.0                         //設置IP地址與子網掩碼
R4(config-if)#no shut                     //開啓接口
R4(config-if)#
*Mar  1 00:28:15.879: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:28:16.879: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R4(config-if)#int f0/1                          //進入接口模式
R4(config-if)#ip add 192.168.50.1 255.255.255.0                         //設置IP地址與子網掩碼
R4(config-if)#no shut                     //開啓接口
R4(config-if)#
*Mar  1 00:29:21.695: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:29:22.695: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R4(config-if)#exit                            //退出
R4(config)#router rip                     //啓用RIP協議
R4(config-router)#version 2        //使用RIP版本2
R4(config-router)#no auto-summary                         //關閉自動彙總
R4(config-router)#network 192.168.50.0                 //宣告網段
R4(config-router)#redistribute ospf 1 metric 5        //RIP引入OSPF路由
R4(config-router)#exit                            //退出
R4(config)#router ospf 1               //啓用ospf協議,進程號爲1
R4(config-router)#router-id 4.4.4.4               //設置router-id
R4(config-router)#network 192.168.40.0 0.0.0.255 area 0                 //宣告網段
*Mar  1 00:33:22.651: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on FastEthernet0/0 from LOADING to FULL, Loading Done
R4(config-router)#redistribute rip subnets                                         //OSPF引入RIP路由
R4(config-router)#exit                            //退出
R4(config)#

5.配置R5。

R5#conf t                                          //進入全局模式
Enter configuration commands, one per line.  End with CNTL/Z.
R5(config)#int f0/0                          //進入接口模式
R5(config-if)#ip add 192.168.50.2 255.255.255.0                         //設置IP地址與子網掩碼
R5(config-if)#no shut                     //開啓接口
R5(config-if)#int f0/1                          //進入接口模式
R5(config-if)#
*Mar  1 00:36:28.747: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:36:29.815: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R5(config-if)#ip add 192.168.60.1 255.255.255.0                         //設置IP地址與子網掩碼
R5(config-if)#no shut                     //開啓接口
R5(config-if)#
*Mar  1 00:36:57.275: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:36:58.275: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R5(config-if)#exit                            //退出
R5(config)#router rip                     //啓用RIP協議
R5(config-router)#version 2        //使用RIP版本2
R5(config-router)#no auto-summary                          //關閉自動彙總
R5(config-router)#network 192.168.50.0                 //宣告網段
R5(config-router)#network 192.168.60.0                 //宣告網段
R5(config-router)#exit                            //退出
R5(config)#

6.配置R6。

R6#conf t                                          //進入全局模式
Enter configuration commands, one per line.  End with CNTL/Z.
R6(config)#int f0/0                          //進入接口模式
R6(config-if)#ip add 12.0.0.2 255.255.255.0                         //設置IP地址與子網掩碼
R6(config-if)#no shut                     //開啓接口
R6(config-if)#int f0/1                          //進入接口模式
R6(config-if)#
*Mar  1 00:19:13.363: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:19:14.363: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R6(config-if)#ip add 13.0.0.1 255.255.255.0                         //設置IP地址與子網掩碼
R6(config-if)#no shut                     //開啓接口
R6(config-if)#exit                            //退出
R6(config)#
*Mar  1 00:19:37.803: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:19:38.803: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R6(config)#ip route 192.168.0.0 255.255.0.0 12.0.0.1      //設置默認路由
R6(config)#

7.分別給PC1、PC2、PC3、PC四(防違禁)設置IP地址

(1)給PC1設置IP地址

PC1> ip 192.168.10.2 192.168.10.1           //設置IP和網關
Checking for duplicate address...
PC1 : 192.168.10.2 255.255.255.0 gateway 192.168.10.1

(2)給PC2設置IP地址

PC2> 
PC2> ip 192.168.70.2 192.168.70.1           //設置IP和網關
Checking for duplicate address...
PC1 : 192.168.70.2 255.255.255.0 gateway 192.168.70.1

(3)給PC3設置IP地址

PC3> 
PC3> ip 13.0.0.13 13.0.0.1           //設置IP和網關
Checking for duplicate address...
PC1 : 13.0.0.13 255.255.255.0 gateway 13.0.0.1

(4)給PC四設置IP地址

PC四> ip 192.168.60.2 192.168.60.1           //設置IP和網關
Checking for duplicate address...
PC1 : 192.168.60.2 255.255.255.0 gateway 192.168.60.1

8.驗證實驗結果

分別用PC1去ping其它所有PC機,都能互通,實驗成功。

PC1> ping 192.168.70.2
192.168.70.2 icmp_seq=1 timeout
192.168.70.2 icmp_seq=2 timeout
84 bytes from 192.168.70.2 icmp_seq=3 ttl=61 time=93.680 ms
84 bytes from 192.168.70.2 icmp_seq=4 ttl=61 time=93.717 ms
84 bytes from 192.168.70.2 icmp_seq=5 ttl=61 time=93.722 ms

PC1> ping 13.0.0.13
13.0.0.13 icmp_seq=1 timeout
13.0.0.13 icmp_seq=2 timeout
84 bytes from 13.0.0.13 icmp_seq=3 ttl=60 time=124.965 ms
84 bytes from 13.0.0.13 icmp_seq=4 ttl=60 time=124.858 ms
84 bytes from 13.0.0.13 icmp_seq=5 ttl=60 time=125.056 ms

PC1> ping 192.168.60.2
192.168.60.2 icmp_seq=1 timeout
84 bytes from 192.168.60.2 icmp_seq=2 ttl=59 time=156.210 ms
84 bytes from 192.168.60.2 icmp_seq=3 ttl=59 time=157.946 ms
84 bytes from 192.168.60.2 icmp_seq=4 ttl=59 time=166.144 ms
84 bytes from 192.168.60.2 icmp_seq=5 ttl=59 time=156.238 ms
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章