配置OSPF动态路由

配置OSPF动态路由实验;设备互连网段地址自行规划。(实现四台路由设备全网通,OSPF进程号为1,区域号为0)

地址信息表:
R1:192.168.1.1/24:g0/0
R2:192.168.1.2/24:g0/0 | 192.168.2.1/24:g0/1
R3:192.168.2.2/24:g0/0 | 192.168.3.1/24:g0/2
R4:192.168.3.2/24:g0/2

R1配置:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int g0/0
Router(config-if)#ip add 192.168.1.1 255.255.255.0
Router(config-if)#no sh

Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up

R2配置:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int g0/0
Router(config-if)#ip add 192.168.1.2 255.255.255.0
Router(config-if)#no sh

Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up

Router(config-if)#int g0/1
Router(config-if)#ip add 192.168.2.1 255.255.255.0
Router(config-if)#no sh

Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up

R3配置:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int g0/0
Router(config-if)#ip add 192.168.2.2 255.255.255.0
Router(config-if)#no sh

Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up

Router(config-if)#int g0/2
Router(config-if)#ip add 192.168.3.1 255.255.255.0
Router(config-if)#no sh

Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up

R4配置:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int g0/2
Router(config-if)#ip add 192.168.3.2 255.255.255.0
Router(config-if)#no sh

Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/2, changed state to up

R1与R4连通性测试:
Router#ping 192.168.3.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

# 这里我们可以看到R1无法ping通R4,接下来我们配置OSPF使它们互通

R1配置OSPF:
Router(config)#rou ospf 1
Router(config-router)#net 192.168.1.0 255.255.255.0 area 0

R2配置OSPF:
Router(config)#rou ospf 1
Router(config-router)#net 192.168.1.0 255.255.255.0 area 0
Router(config-router)#net 192.168.2.0 255.255.255.0 area 0

R3配置OSPF:
Router(config)#rou ospf 1
Router(config-router)#net 192.168.2.0 255.255.255.0 area 0
Router(config-router)#net 192.168.3.0 255.255.255.0 area 0

R4配置OSPF:
Router(config)#rou ospf 1
Router(config-router)#net 192.168.3.0 255.255.255.0 area 0

R1与R4连通性测试:
Router#ping 192.168.3.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms

# R1成功ping通R4

到这里我们就完成OSPF动态路由的配置了。