OSPF 直连接与虚连接配置实例 (Cisco Packer Tracer 模拟器)
OSPF直连接
【拓扑图】
【注意】
ospf netwark 后面是子网掩码的反码!!!
【路由器1】
Router>en Router#conf Router(config)#int loopback 0 Router(config-if)# ip add 1.1.1.1 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#int f0/0 Router(config-if)#ip address 192.168.1.1 255.255.255.0 Router(config-if)#no shut Router(config)#router ospf 110 Router(config-router)#network 1.1.1.1 0.0.0.255 area 1 Router(config-router)#network 192.168.1.1 0.0.0.255 area 1 Router(config-router)#end【路由器2】
Router>en Router#conf Router(config)#int f0/1 Router(config-if)#ip address 192.168.1.2 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#int f0/0 Router(config-if)#ip address 192.168.2.2 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#int loopback 0 Router(config-if)#ip address 2.2.2.2 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#router ospf 110 Router(config-router)#network 2.2.2.2 0.0.0.255 area 0 Router(config-router)#network 192.168.1.2 0.0.0.255 area 1 Router(config-router)#network 192.168.2.2 0.0.0.255 area 0
【路由器3】
Router>en Router#conf Router(config)#int loopback 0 Router(config-if)#ip address 3.3.3.3 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#int f0/1 Router(config-if)#ip address 192.168.2.3 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#int f0/0 Router(config-if)#ip address 192.168.3.3 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#router ospf 110 Router(config-router)#network 3.3.3.3 0.0.0.255 area 0 Router(config-router)#network 192.168.3.3 0.0.0.255 area 2 Router(config-router)#network 192.168.2.3 0.0.0.255 area 0
【路由器4】
Router>en Router#conf Router(config)#int loopback 0 Router(config-if)#ip address 4.4.4.4 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#int f0/1 Router(config-if)#ip address 192.168.3.4 255.255.255.0 Router(config-if)#no shut Router(config)#router ospf 110 Router(config-router)#network 4.4.4.0 0.0.0.255 area 2 Router(config-router)#network 192.168.3.0 0.0.0.255 area 2 Router(config-router)#end
OSPF 虚连接 主干区域0 不直接连接, 通过虚链接连接
【拓扑图】
【注意!】
连线网段一样但ip不一样 掩码反码
【路由器1】
Router>en Router#conf Router(config)#int loopback 0 Router(config-if)# ip add 1.1.1.1 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#int f0/0 Router(config-if)#ip address 192.168.1.1 255.255.255.0 Router(config-if)#no shut Router(config)#router ospf 110 Router(config-router)#network 1.1.1.1 0.0.0.255 area 0 Router(config-router)#network 192.168.1.1 0.0.0.255 area 0 Router(config-router)#end Router>show ip route Codes: C - connected, S - static, I - IGRP, 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, E - EGP i - IS-IS, 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/24 is subnetted, 1 subnets C 1.1.1.0 is directly connected, Loopback0 2.0.0.0/32 is subnetted, 1 subnets O 2.2.2.2 [110/2] via 192.168.1.2, 00:11:35, FastEthernet0/0 3.0.0.0/32 is subnetted, 1 subnets O IA 3.3.3.3 [110/3] via 192.168.1.2, 00:04:10, FastEthernet0/0 4.0.0.0/32 is subnetted, 1 subnets O IA 4.4.4.4 [110/4] via 192.168.1.2, 00:02:21, FastEthernet0/0 C 192.168.1.0/24 is directly connected, FastEthernet0/0 O IA 192.168.2.0/24 [110/2] via 192.168.1.2, 00:08:55, FastEthernet0/0 O IA 192.168.3.0/24 [110/3] via 192.168.1.2, 00:03:01, FastEthernet0/0 Router>ping 4.4.4.4 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms
【路由器2】
Router>en Router#conf Router(config)#int f0/1 Router(config-if)#ip address 192.168.1.2 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#int f0/0 Router(config-if)#ip address 192.168.2.2 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#int loopback 0 Router(config-if)#ip address 2.2.2.2 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#router ospf 110 Router(config-router)#network 2.2.2.2 0.0.0.255 are Router(config-router)#network 2.2.2.2 0.0.0.255 area 0 Router(config-router)#network 192.168.1.2 0.0.0.255 area 0 Router(config-router)#network 192.168.2.2 0.0.0.255 area 1 Router(config-router)#area 1 virtual-link 3.3.3.3 // 配置虚连接 Router#show ip route Codes: C - connected, S - static, I - IGRP, 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, E - EGP i - IS-IS, 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 O 1.1.1.1 [110/2] via 192.168.1.1, 00:11:07, FastEthernet0/1 2.0.0.0/24 is subnetted, 1 subnets C 2.2.2.0 is directly connected, Loopback0 3.0.0.0/32 is subnetted, 1 subnets O 3.3.3.3 [110/2] via 192.168.2.3, 00:03:50, FastEthernet0/0 4.0.0.0/32 is subnetted, 1 subnets O IA 4.4.4.4 [110/3] via 192.168.2.3, 00:01:46, FastEthernet0/0 C 192.168.1.0/24 is directly connected, FastEthernet0/1 C 192.168.2.0/24 is directly connected, FastEthernet0/0 O IA 192.168.3.0/24 [110/2] via 192.168.2.3, 00:02:31, FastEthernet0/0 Router#
【路由器3】
Router>en Router#conf Router(config)#int loopback 0 Router(config-if)#ip address 3.3.3.3 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#int f0/1 Router(config-if)#ip address 192.168.2.3 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#int f0/0 Router(config-if)#ip address 192.168.3.3 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#router ospf 110 Router(config-router)#network 3.3.3.3 0.0.0.255 area 1 Router(config-router)#network 192.168.3.3 0.0.0.255 area 2 Router(config-router)#network 192.168.2.3 0.0.0.255 area 1 Router(config-router)#area 1 virtual-link 2.2.2.2 // 配置虚连接 Router(config-router)#no shut ^
【路由器4】
Router>en Router#conf Router(config)#int loopback 0 Router(config-if)#ip address 4.4.4.4 255.255.255.0 Router(config-if)#no shut Router(config-if)#exit Router(config)#int f0/1 Router(config-if)#ip address 192.168.3.4 255.255.255.0 Router(config-if)#no shut Router(config)#router ospf 110 Router(config-router)#network 4.4.4.0 0.0.0.255 area 2 Router(config-router)#network 192.168.3.0 0.0.0.255 area 2 Router(config-router)#end Router#show ip route Codes: C - connected, S - static, I - IGRP, 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, E - EGP i - IS-IS, 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 O IA 1.1.1.1 [110/4] via 192.168.3.3, 00:30:52, FastEthernet0/1 2.0.0.0/32 is subnetted, 1 subnets O IA 2.2.2.2 [110/3] via 192.168.3.3, 00:30:52, FastEthernet0/1 4.0.0.0/24 is subnetted, 1 subnets C 4.4.4.0 is directly connected, Loopback0 O IA 192.168.1.0/24 [110/3] via 192.168.3.3, 00:30:52, FastEthernet0/1 C 192.168.3.0/24 is directly connected, FastEthernet0/1 【测试】 Router#ping 1.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms Router#ping 2.2.2.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms
岂曰无衣?与子同袍。王于兴师,修我戈矛。与子同仇!
岂曰无衣?与子同泽。王于兴师,修我矛戟。与子偕作!
岂曰无衣?与子同裳。王于兴师,修我甲兵。与子偕行!