实验拓扑图

c51fb20985572813c092d261b83c75b8.png

R1路由器的配置

R1#    

R1#conf t

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

R1(config)#int e0/0

R1(config-if)#ip address 192.168.20.1 255.255.255.0

R1(config-if)#no sh 

R1(config-if)#int e0/1

R1(config-if)#ip address 192.168.10.1 255.255.255.0

R1(config-if)#no sh 

R1(config-if)#int loopback 0

R1(config-if)#ip address 1.1.1.1 255.255.255.255

R1(config-if)#no sh

R1(config-if)#exit 

R1(config)#router ospf 1

R1(config-router)#network 192.168.10.0 0.0.0.255 area 0 

R1(config-router)#network 192.168.20.0 0.0.0.255 area 0

R1(config-router)#exit  

R1(config)#do sh ip int br

Interface                  IP-Address      OK? Method Status                Protocol

Ethernet0/0                192.168.20.1       YES manual up                    up      

Ethernet0/1                192.168.10.1       YES manual up                    up      

Ethernet0/2                unassigned        YES unset  administratively down     down    

Ethernet0/3                unassigned        YES unset  administratively down     down    

Loopback0                  1.1.1.1          YES manual up                  up  

R1#sh 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/32 is subnetted, 1 subnets

C       1.1.1.1 is directly connected, Loopback0

O    192.168.30.0/24 [110/20] via 192.168.20.2, 00:00:08, Ethernet0/0

C    192.168.10.0/24 is directly connected, Ethernet0/1

O    192.168.40.0/24 [110/30] via 192.168.20.2, 00:00:08, Ethernet0/0

C    192.168.20.0/24 is directly connected, Ethernet0/0


R2路由器的配置

R2#

R2#conf t

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

R2(config)#int e0/0

R2(config-if)#ip address 192.168.20.2 255.255.255.0

R2(config-if)#no sh 

R2(config-if)#int e0/1

R2(config-if)#ip address 192.168.30.1 255.255.255.0

R2(config-if)#no sh

R2(config-if)#int loopback 0

R2(config-if)#ip address 2.2.2.2 255.255.255.255

R2(config-if)#no sh 

R2(config-if)#exit

R2(config)# router ospf 1

R2(config-router)#network 192.168.20.0 0.0.0.255 area 0

R2(config-router)#network 192.168.30.0 0.0.0.255 area 0

R2(config-router)#exit

R2(config)#do sh ip int br

Interface                  IP-Address      OK? Method Status                Protocol

Ethernet0/0                192.168.20.2    YES manual up                    up      

Ethernet0/1                192.168.30.1    YES manual up                    up      

Ethernet0/2                unassigned      YES unset  administratively down     down    

Ethernet0/3                unassigned      YES unset  administratively down     down    

Loopback0                  2.2.2.2        YES manual up                  up      

R2(config)#do sh 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, Ethernet0/1

O    192.168.10.0/24 [110/20] via 192.168.20.1, 00:04:51, Ethernet0/0

O    192.168.40.0/24 [110/20] via 192.168.30.2, 00:04:51, Ethernet0/1

C    192.168.20.0/24 is directly connected, Ethernet0/0


R3路由器的配置

R3#

R3#conf t

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

R3(config)#int e0/0

R3(config-if)#ip address 192.168.30.2 255.255.255.0

R3(config-if)#no sh 

R3(config-if)#int e0/1

R3(config-if)#ip address 192.168.40.1 255.255.255.0

R3(config-if)#no sh  

R3(config-if)#int loopback 0 

R3(config-if)#ip address 3.3.3.3 255.255.255.255

R3(config-if)#no sh 

R3(config-if)#exit

R3(config)#router ospf 1

R3(config-router)#network 192.168.30.0 0.0.0.255 area 0

R3(config-router)#network 192.168.40.0 0.0.0.255 area 0

R3(config)#do sh 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, Ethernet0/0

O    192.168.10.0/24 [110/30] via 192.168.30.1, 00:08:32, Ethernet0/0

C    192.168.40.0/24 is directly connected, Ethernet0/1

O    192.168.20.0/24 [110/20] via 192.168.30.1, 00:08:32, Ethernet0/0

R3(config)#

验证PC机互相访问

36c38bbe2d4c4694d0e41875c70db41d.png

a519cc9f0fe988d2492082cacd57a059.png


最后验证成功