在GNS 3
中搭建實驗環境ide
在GNS 3
軟件中添加4
個路由設別,與兩臺PC
機,在交換機R1
、R3
中添加業務單板,用於鏈接兩臺PC
機,而後用鏈接線分別將4
路由設別與兩臺PC
機鏈接起來,並在拓撲圖中開啓接口信息,標註劃分的IP地址信息,最後在用工具在拓撲圖中標註劃分的不一樣區域(area0
與area1
)如圖所示:
oop
192.168.10.0/24
192.168.20.0/24
192.168.30.0/24
192.168.40.0/24
192.168.50.0/24
192.168.60.0/24
R1
:1.1.1.1
R2
:2.2.2.2
R3
:3.3.3.3
R4
:4.4.4.4
一、開啓所有設別,並打開R1
路由設備,進入配置接口網段信息。學習
R1#conf t //進入全局模式 Enter configuration commands, one per line. End with CNTL/Z. R1(config)#int f0/0 //進入f0/0接口 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:56.163: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up *Mar 1 00:01:57.163: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up R1(config-if)#int f0/1 //進入f0/1接口 R1(config-if)#ip add 192.168.50.2 255.255.255.0 //添加IP地址 R1(config-if)#no shut //開啓接口 R1(config-if)# *Mar 1 00:02:31.639: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up *Mar 1 00:02:32.639: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up R1(config-if)#int f1/0 //進入f1/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:03:16.431: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up *Mar 1 00:03:17.431: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up R1(config-if)#do show ip int b //查看IP地址是否配置成功 Interface IP-Address OK? Method Status Protocol FastEthernet0/0 192.168.20.1 YES manual up up FastEthernet0/1 192.168.50.2 YES manual up up FastEthernet1/0 192.168.10.1 YES manual up up
二、打開R2
路由設備,進入配置接口網段信息。測試
R2#conf t //進入全局模式 Enter configuration commands, one per line. End with CNTL/Z. R2(config)#int f0/0 //進入f0/0接口 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:07:46.395: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up *Mar 1 00:07:47.395: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up R2(config-if)#int f0/1 //進入f0/1接口 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:08:20.979: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up *Mar 1 00:08:21.979: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up R2(config-if)#do show ip int b //查看IP地址是否配置成功 Interface IP-Address OK? Method Status Protocol FastEthernet0/0 192.168.20.2 YES manual up up FastEthernet0/1 192.168.30.1 YES manual up up
三、打開R3
由設備,進入配置接口網段信息。3d
R3#conf t //進入全局模式 Enter configuration commands, one per line. End with CNTL/Z. R3(config)#int f0/0 //進入f0/0接口 R3(config-if)#ip add 192.168.30.2 255.255.255.0 //添加IP地址 R3(config-if)#no shut //開啓接口 R3(config-if)# *Mar 1 00:12:29.019: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up *Mar 1 00:12:30.019: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up R3(config-if)#int f0/1 //進入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:13:05.091: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up *Mar 1 00:13:06.091: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up R3(config-if)#int f1/0 //進入f1/0接口 R3(config-if)#ip add 192.168.60.1 255.255.255.0 //添加IP地址 R3(config-if)#no shutt //開啓接口 R3(config-if)# *Mar 1 00:13:50.719: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up *Mar 1 00:13:51.719: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up R3(config-if)#do show ip int b //查看IP地址是否配置成功 Interface IP-Address OK? Method Status Protocol FastEthernet0/0 192.168.30.2 YES manual up up FastEthernet0/1 192.168.40.1 YES manual up up FastEthernet1/0 192.168.60.1 YES manual up up
四、打開R4
由設備,進入配置接口網段信息。code
R4#conf t //進入全局模式 Enter configuration commands, one per line. End with CNTL/Z. R4(config)#int f0/0 //進入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:17:23.547: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up *Mar 1 00:17:24.547: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up R4(config-if)#int f0/1 //進入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:18:02.799: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up *Mar 1 00:18:03.799: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up R4(config-if)#do show ip int b //查看IP地址是否配置成功 Interface IP-Address OK? Method Status Protocol FastEthernet0/0 192.168.40.2 YES manual up up FastEthernet0/1 192.168.50.1 YES manual up up
五、回到R1
路由設備中,配置迴環網卡,添加Router ID
,R2
、R3
、R4
路由設備中一樣操做。router
R1(config)#int loopback 0 //進入迴環網卡接口 R1(config-if)# *Mar 1 00:23:09.519: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up R1(config-if)#ip add 1.1.1.1 255.255.255.255 //配置Router ID R1(config-if)#no shut R1(config-if)#do show ip int b //查看回環網卡地址是否配置成功 Interface IP-Address OK? Method Status Protocol FastEthernet0/0 192.168.20.1 YES manual up up FastEthernet0/1 192.168.50.2 YES manual up up FastEthernet1/0 192.168.10.1 YES manual up up Loopback0 1.1.1.1 YES manual up up
R2(config)#int loopback 0 R2(config-if)# *Mar 1 00:25:49.879: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up R2(config-if)#ip add 2.2.2.2 255.255.255.255 R2(config-if)#no shut R2(config-if)#do show ip int b Interface IP-Address OK? Method Status Protocol FastEthernet0/0 192.168.20.2 YES manual up up FastEthernet0/1 192.168.30.1 YES manual up up Loopback0 2.2.2.2 YES manual up up
R3(config)#int loopback 0 R3(config-if)# *Mar 1 00:29:09.423: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up R3(config-if)#ip add 3.3.3.3 255.255.255.255 R3(config-if)#no shut R3(config-if)#do show ip int b Interface IP-Address OK? Method Status Protocol FastEthernet0/0 192.168.30.2 YES manual up up FastEthernet0/1 192.168.40.1 YES manual up up FastEthernet1/0 192.168.60.1 YES manual up up Loopback0 3.3.3.3 YES manual up up
R4(config)#int loopback 0 R4(config-if)#i *Mar 1 00:30:26.755: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up R4(config-if)#ip add 4.4.4.4 255.255.255.255 R4(config-if)#no shut R4(config-if)#do show ip int b Interface IP-Address OK? Method Status Protocol FastEthernet0/0 192.168.40.2 YES manual up up FastEthernet0/1 192.168.50.1 YES manual up up Loopback0 4.4.4.4 YES manual up up
六、在路由設備中啓動OSPF
協議,並區域中宣告Router ID
信息與網段信息。blog
R1(config)#router ospf 1 //啓動OSPF協議,進程號爲1 R1(config-router)#router-id 1.1.1.1 //宣告Router ID R1(config-router)#network 192.168.20.0 0.0.0.255 area 0 //R1設備在area 0區域中宣告網段信息,注意子網掩碼要寫反碼 R1(config-router)#network 192.168.50.0 0.0.0.255 area 0 R1(config-router)#network 192.168.10.0 0.0.0.255 area 0
R2(config)#router ospf 1 //在R2路由設備中啓動OSPF協議,進程號爲1 R2(config-router)#router-id 2.2.2.2 //宣告Router ID R2(config-router)#network 192.168.20.0 0.0.0.255 area 0 //此網段在area 0區域中宣告網段信息,注意子網掩碼要寫反碼 R2(config-router)# *Mar 1 00:46:07.555: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on FastEthernet0/0 from LOADING to FULL, Loading Done R2(config-router)#network 192.168.30.0 0.0.0.255 area 1 //此網段在area 1區域中宣告網段信息,注意子網掩碼要寫反碼 R2(config-router)#do 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 2.0.0.0/32 is subnetted, 1 subnets C 2.2.2.2 is directly connected, Loopback0 C 192.168.30.0/24 is directly connected, FastEthernet0/1 C 192.168.20.0/24 is directly connected, FastEthernet0/0 O 192.168.10.0/24 [110/11] via 192.168.20.1, 00:00:45, FastEthernet0/0 O 192.168.50.0/24 [110/20] via 192.168.20.1, 00:00:33, FastEthernet0/0 //成功學習到R1設備中網段信息
R3(config)#router ospf 1 //在R3路由設備中啓動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 //此網段在area 1區域中宣告網段信息,注意子網掩碼要寫反碼 R3(config-router)# *Mar 1 00:53:09.751: %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 1 //此網段在area 1區域中宣告網段信息,注意子網掩碼要寫反碼 R3(config-router)#network 192.168.60.0 0.0.0.255 area 1 R3(config-router)# *Mar 1 01:04:49.075: %SYS-5-CONFIG_I: Configured from console by console R3(config-router)#do 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 3.0.0.0/32 is subnetted, 1 subnets C 3.3.3.3 is directly connected, Loopback0 C 192.168.30.0/24 is directly connected, FastEthernet0/0 C 192.168.60.0/24 is directly connected, FastEthernet1/0 O IA 192.168.10.0/24 [110/21] via 192.168.40.2, 00:01:33, FastEthernet0/1 [110/21] via 192.168.30.1, 00:01:33, FastEthernet0/0 C 192.168.40.0/24 is directly connected, FastEthernet0/1 O IA 192.168.20.0/24 [110/20] via 192.168.30.1, 00:01:14, FastEthernet0/0 O IA 192.168.50.0/24 [110/30] via 192.168.30.1, 00:01:14, FastEthernet0/0 //成功學習網段信息
R4(config)#router ospf 1 //在R4路由設備中啓動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 1 //此網段在area 1區域中宣告網段信息,注意子網掩碼要寫反碼 R4(config-router)# *Mar 1 01:01:18.223: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on FastEthernet0/0 from LOADING to FULL, Loading Done R4(config-router)#network 192.168.50.0 0.0.0.255 area 0 //此網段在area 0區域中宣告網段信息,注意子網掩碼要寫反碼 R4(config-router)# *Mar 1 01:01:44.507: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on FastEthernet0/1 from LOADING to FULL, Loading Done R4(config-router)#do 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 O 192.168.30.0/24 [110/20] via 192.168.40.1, 00:09:36, FastEthernet0/0 O 192.168.60.0/24 [110/11] via 192.168.40.1, 00:06:40, FastEthernet0/0 4.0.0.0/32 is subnetted, 1 subnets C (1)4.4.4.4 is directly connected, Loopback0 //添加(1)是違禁詞彙處理 O 192.168.10.0/24 [110/11] via 192.168.50.2, 00:03:12, FastEthernet0/1 C 192.168.40.0/24 is directly connected, FastEthernet0/0 O 192.168.20.0/24 [110/20] via 192.168.50.2, 00:09:21, FastEthernet0/1 C 192.168.50.0/24 is directly connected, FastEthernet0/1 //成功學習全部網段信息
七、分別給兩臺PC
機添加IP地址,並用ping
命令測試兩臺PC機是否成功通訊。接口
PC1> ip 192.168.10.2 192.168.10.1 //在PC1中添加IP地址 Checking for duplicate address... PC1 : 192.168.10.2 255.255.255.0 gateway 192.168.10.1 //添加成功
PC2> ip 192.168.60.2 192.168.60.1 //在PC2中添加IP地址 Checking for duplicate address... PC1 : 192.168.60.2 255.255.255.0 gateway 192.168.60.1 //添加成功
PC1> ping 192.168.60.2 //使用ping命令與PC2通訊 192.168.60.2 icmp_seq=1 timeout 84 bytes from 192.168.60.2 icmp_seq=2 ttl=61 time=54.935 ms 84 bytes from 192.168.60.2 icmp_seq=3 ttl=61 time=63.006 ms 84 bytes from 192.168.60.2 icmp_seq=4 ttl=61 time=47.872 ms 84 bytes from 192.168.60.2 icmp_seq=5 ttl=61 time=45.075 ms //成功與PC2通訊