OSPF单区域配置几个实验
实验1
配置路由接口省略
在R1上启动OSPF进程,并配置Router ID 及运行OSPF的接口
R1(config)# router ospf 1
R1(config-router)# router-id 192.168.2.1
R1(config-router)#network 10.0.0.0 0.0.0.3 area 0
R1(config-router)#network 20.0.0.0 0.0.0.3 area 0
在R2上启动OSPF进程,并配置Router ID 及运行OSPF的接口
R1(config)# router ospf 1
R1(config-router)# router-id 192.168.1.1
R1(config-router)#network 192.168.1.1 0.0.0.0 area 0
R1(config-router)#network 10.0.0.0 0.0.0.3 area 0
在R3上启动OSPF进程,并配置Router ID 及运行OSPF的接口
R1(config)# router ospf 1
R1(config-router)# router-id 192.168.3.1
R1(config-router)#network 192.168.3.1 0.0.0.0 area 0
R1(config-router)#network 20.0.0.0 0.0.0.3 area 0
在R1上,没有将loopback 192.168.2.1宣告进ospf网络中,而在R2的配置中将loopback 192.168.1.1宣告进了ospf网络中,因此,loopback接口是否需要启用ospf,可以视需求而定,不过无论loopback接口是否启用ospf,loopback接口的IP地址都可以成为Router ID。
验证
R1
20.0.0.0/30 is subnetted, 1 subnets
C 20.0.0.0 is directly connected, FastEthernet0/0
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, FastEthernet1/0
192.168.1.0/32 is subnetted, 1 subnets
O 192.168.1.1 [110/2] via 10.0.0.1, 00:00:03, FastEthernet1/0
192.168.2.0/32 is subnetted, 1 subnets
C 192.168.2.1 is directly connected, Loopback0
192.168.3.0/32 is subnetted, 1 subnets
O 192.168.3.1 [110/2] via 20.0.0.2, 00:00:03, FastEthernet0/0
R2
20.0.0.0/30 is subnetted, 1 subnets
O 20.0.0.0 [110/2] via 10.0.0.2, 00:00:31, FastEthernet0/0
10.0.0.0/30 is subnetted, 1 subnets
C 10.0.0.0 is directly connected, FastEthernet0/0
192.168.1.0/32 is subnetted, 1 subnets
C 192.168.1.1 is directly connected, Loopback0
192.168.3.0/32 is subnetted, 1 subnets
O 192.168.3.1 [110/3] via 10.0.0.2, 00:00:31, FastEthernet0/0
R3
20.0.0.0/30 is subnetted, 1 subnets
C 20.0.0.0 is directly connected, FastEthernet0/0
10.0.0.0/30 is subnetted, 1 subnets
O 10.0.0.0 [110/2] via 20.0.0.1, 00:01:00, FastEthernet0/0
192.168.1.0/32 is subnetted, 1 subnets
O 192.168.1.1 [110/3] via 20.0.0.1, 00:01:00, FastEthernet0/0
192.168.3.0/32 is subnetted, 1 subnets
C 192.168.3.1 is directly connected, Loopback0
实验2
lo 0 做Router ID lo 1 模拟路由器下所带计算机
接口配置省略
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 192.168.1.0 0.0.0.255 area 0
R1(config-router)#network 10.1.1.0 0.0.0.3 area 0 也可写成network 10.0.0.0 0.255.255.255 area 0
R1(config-router)#network 40.4.4.0 0.0.0.3 area 0
R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 2.2.2.2 0.0.0.0 area 0
R2(config-router)#network 192.168.2.0 0.0.0.255 area 0
R2(config-router)#network 10.1.1.0 0.0.0.3 area 0
R2(config-router)#network 20.2.2.0 0.0.0.3 area 0
R2路由标记的可以写成network 0.0.0.0 255.255.255.255 area 0
R3(config)#router ospf 1
R3(config-router)#router ospf 1
R3(config-router)#network 3.3.3.3 0.0.0.0 area 0
R3(config-router)#network 192.168.3.0 0.0.0.255 area 0
R3(config-router)#network 20.2.2.0 0.0.0.3 area 0
R3(config-router)#network 30.3.3.0 0.0.0.3 area 0
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 0
R4(config-router)#network 192.168.4.0 0.0.0.255 area 0
R4(config-router)#network 40.4.4.0 0.0.0.3 area 0
R4(config-router)#network 30.3.3.0 0.0.0.3 area 0
结束