实验环境:
公司有三家分公司,总公司和分公司使用专线连接,公司要求配置路由器实现网络互通
如上图是使用拓扑图,通过配置路由器实现公司内部的全网互通,具体规划如下表:
互联地址 | R1和R2 | 10.0.2.0/24 | 路由器loop back 0地址 router-ID 以及任务 | R1 | 1.1.1.1/32 | 总公司 | loopback 1地址 | R1 | 192.168.1.1/24 |
R1和R3 | 10.0.1.4/24 | R2 | 2.2.2.2/32 | 分公司A | |||||
R1和R4 | 10.0.0.8/24 | R3 | 3.3.3.3/32 | 分公司B | |||||
R4 | 4.4.4.4/32 | 分公司C |
需求描述:
公司要求使用OSPF实现总公司和各分公司互通,并且避免由于网段变更导致的重复配置
1.配置路由器的接口地址,Loopback地址
R1的配置
R1(config)#interface loopback 0
R1(config-if)#ip address 1.1.1.1 255.255.255.255
R1(config-if)#no shutdown
R1(config-if)#ex
R1(config)#interface loopback 1
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#ex
R1(config)#interface ethernet 0/0
R1(config-if)#ip address 10.0.0.7 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#ex
R1(config)#interface ethernet 0/1
R1(config-if)#ip address 10.0.1.3 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#ex
R1(config)#interface ethernet 0/2
R1(config-if)#ip address 10.0.2.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#ex
R2的配置
R2(config)#interface loopback 0
R2(config-if)#ip address 2.2.2.2 255.255.255.255
R2(config-if)#no shutdown
R2(config-if)#ex
R2(config)#interface ethernet 0/0
R2(config-if)#ip address 10.0.2.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#ex
R3的配置
R3(config)#interface ethernet 0/0
R3(config-if)#ip address 10.0.1.4 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#ex
R3(config)#interface loopback 0
R3(config-if)#ip address 3.3.3.3 255.255.255.255
R3(config-if)#no shutdown
R3(config-if)#ex
R4的配置
R4(config)#interface ethernet 0/0
R4(config-if)#ip address 10.0.0.8 255.255.255.0
R4(config-if)#no shutdown
R4(config-if)#ex
R4(config)#interface loopback 0
R4(config-if)#ip address 4.4.4.4 255.255.255.255
R4(config-if)#no shutdown
R4(config-if)#ex
然后使用show ip interface brief命令查看接口信息检查接口是否配置正确
R1
R2
R3
R4
2.配置OSPF协议,实现内部网络互通
R1的配置
R1(config)#router ospf 1
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 1.1.1.1 0.0.0.0 area 0
R1(config-router)#network 10.0.1.0 0.0.0.255 area 0
R1(config-router)#network 10.0.2.0 0.0.0.255 area 1
R1(config-router)#network 10.0.0.0 0.0.0.255 area 2
R1(config-router)#ex
R2的配置
R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 10.0.2.0 0.0.0.255 area 1
R2(config-router)#network 2.2.2.2 0.0.0.0 area 1
R2(config-router)#ex
R3的配置
R3(config)#router ospf 1
R3(config-router)#router-id 3.3.3.3
R3(config-router)#network 3.3.3.3 0.0.0.0 area 0
R3(config-router)#network 10.0.1.0 0.0.0.255 area 0
R3(config-router)#ex
R4的配置
R4(config)#router ospf 1
R4(config-router)#router-id 4.4.4.4
R4(config-router)#network 4.4.4.4 0.0.0.0 area 2
R4(config-router)#network 10.0.0.0 0.0.0.255 area 2
R4(config-router)#ex
然后使用show ip route来查看路由表检查OSPF是否配置正确
R1
R2
R3
R4
3.验证网络访问是否正常