配置OSPF路由协议基本功能示例
组网需求
企业用户要求不需要花费大量人力去维护网络性能,当网络中出现网络拓扑变动时,可以通过路由更新,计算出新的路由。因此需要使用OSPF动态路由协议保证网络的稳定,实现互连互通。
1、拓扑图
2、配置思路
1、接口及PC地址配置
2、OSPF路由协议配置
1、接口及PC地址配置
(PC机采用DHCP地址,路由器配置DHCP服务,为PC分配地址)
AR1路由器
<Huawei>undo terminal monitor <Huawei>sys [Huawei]sysname AR1 [AR1]int g0/0/0 [AR1-GigabitEthernet0/0/0]ip add 192.168.0.1 24 [AR1-GigabitEthernet0/0/0]quit [AR1]int g0/0/2 [AR1-GigabitEthernet0/0/2]ip add 192.168.1.254 24 [AR1-GigabitEthernet0/0/2]quit [AR1]dhcp enable [AR1]dhcp server group 10 [AR1-dhcp-server-group-10]dhcp-server 192.168.1.0 [AR1-dhcp-server-group-10]quit [AR1]int g0/0/2 [AR1-GigabitEthernet0/0/2]dhcp select interface [AR1-GigabitEthernet0/0/2]quit [AR1]
AR2省略
2、OSPF路由协议配置
AR1
[AR1]interface LoopBack 0 [AR1-LoopBack0]ip add 1.1.1.1 32 [AR1-LoopBack0]quit [AR1]router id 1.1.1.1 [AR1]ospf [AR1-ospf-1]area 0 [AR1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255 [AR1-ospf-1-area-0.0.0.0]network 192.168.0.0 0.0.0.255 [AR1-ospf-1-area-0.0.0.0]quit [AR1-ospf-1]quit
AR2
[AR2]interface LoopBack 0 [AR2-LoopBack0]ip add 2.2.2.2 32 [AR2-LoopBack0]quit [AR2]router id 2.2.2.2 [AR2]ospf [AR2-ospf-1]area 0 [AR2-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255 [AR2-ospf-1-area-0.0.0.0]network 192.168.0.0 0.0.0.255 [AR2-ospf-1-area-0.0.0.0]quit [AR2-ospf-1]quit
3、查看AR1路由表
(去往192.168.2.0/24网段的路由存在了,协议为OSPF)
[AR1]dis ip routing-table protocol ospf Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Public routing table : OSPF Destinations : 1 Routes : 1 OSPF routing table status : <Active> Destinations : 1 Routes : 1 Destination/Mask Proto Pre Cost Flags NextHop Interface 192.168.2.0/24 OSPF 10 2 D 192.168.0.2 GigabitEthernet 0/0/0 OSPF routing table status : <Inactive> Destinations : 0 Routes : 0 [AR1]
测试PC1和PC2的联通性
PC>ipconfig Link local IPv6 address...........: fe80::5689:98ff:fe24:5fd9 IPv6 address......................: :: / 128 IPv6 gateway......................: :: IPv4 address......................: 192.168.1.253 Subnet mask.......................: 255.255.255.0 Gateway...........................: 192.168.1.254 Physical address..................: 54-89-98-24-5F-D9 DNS server........................: PC>ping 192.168.2.253 Ping 192.168.2.253: 32 data bytes, Press Ctrl_C to break Request timeout! From 192.168.2.253: bytes=32 seq=2 ttl=126 time=63 ms From 192.168.2.253: bytes=32 seq=3 ttl=126 time=62 ms From 192.168.2.253: bytes=32 seq=4 ttl=126 time=63 ms From 192.168.2.253: bytes=32 seq=5 ttl=126 time=62 ms --- 192.168.2.253 ping statistics --- 5 packet(s) transmitted 4 packet(s) received 20.00% packet loss round-trip min/avg/max = 0/62/63 ms PC>
读书和健身总有一个在路上