OSPF虚链路(四)

拓扑图:

OSPF虚链路(四)_第1张图片

具体操作:

一、给路由器不同端口配置相应的IP地址,在路由器回环网卡上配置route ID,启动OSPF路由协议并宣告路由ID以及所属网段

1.路由器R1

R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#int f0/0
R1(config-if)#ip add 192.168.10.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#
*Mar  1 00:01:00.703: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:01:01.703: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#int f0/1
R1(config-if)#ip add 192.168.20.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#ex
R1(config)#
*Mar  1 00:01:21.663: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:01:22.663: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R1(config)#int lo 0
R1(config-if)#
*Mar  1 00:02:12.611: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
R1(config-if)#ip add 1.1.1.1 255.255.255.255
R1(config-if)#no shut
R1(config-if)#ex
R1(config)#router ospf 1
R1(config-router)#router-id 1.1.1.1
R1(config-router)#network 192.168.10.0 0.0.0.255 area 2
R1(config-router)#network 192.168.20.0 0.0.0.255 area 2
R1(config-router)#

2.路由器R2

R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#int f0/0
R2(config-if)#ip add 192.168.20.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#
*Mar  1 00:09:39.395: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:09:40.395: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2(config-if)#int f0/1
R2(config-if)#ip add 192.168.30.1 255.255.255.0
R2(config-if)#no shut
R2(config-if)#ex
R2(config)#
*Mar  1 00:10:08.487: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:10:09.487: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R2(config)#in lo 0
R2(config-if)#
*Mar  1 00:10:26.959: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
R2(config-if)#ip add 2.2.2.2 255.255.255.255
R2(config-if)#no shut
R2(config-if)#ex
R2(config)#router ospf 1
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 192.168.20.0 0.0.0.255 area 2
R2(config-router)#
*Mar  1 00:12:05.447: %OSPF-5-ADJCHG: Process 1, Nbr 1.1.1.1 on FastEthernet0/0 from LOADING to FULL, Loading Done
R2(config-router)#network 192.168.30.0 0.0.0.255 area 1
R2(config-router)#

3.路由器R3

R3#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#int f0/0
R3(config-if)#ip add 192.168.30.2 255.255.255.0
R3(config-if)#no shut
R3(config-if)#
*Mar  1 00:11:56.379: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:11:57.379: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R3(config-if)#int f0/1
R3(config-if)#ip add 192.168.40.1 255.255.255.0
R3(config-if)#no shut
R3(config-if)#ex
R3(config)#
*Mar  1 00:12:26.959: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:12:27.959: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R3(config)#int lo 0
R3(config-if)#
*Mar  1 00:12:57.659: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
R3(config-if)#ip add 3.3.3.3 255.255.255.255
R3(config-if)#no shut
R3(config-if)#ex
R3(config)#router ospf 1
R3(config-router)#router-id 3.3.3.3
R3(config-router)#network 192.168.30.0 0.0.0.255 area 1
R3(config-router)#
*Mar  1 00:14:38.027: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on FastEthernet0/0 from LOADING to FULL, Loading Done
R3(config-router)#network 192.168.40.0 0.0.0.255 area 0
R3(config-router)#

4.路由器R4

R4#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R4(config)#int f0/0
R4(config-if)#ip add 192.168.40.2 255.255.255.0
R4(config-if)#no shut
R4(config-if)#
*Mar  1 00:14:08.519: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:14:09.519: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R4(config-if)#int f0/1
R4(config-if)#ip add 192.168.50.1 255.255.255.0
R4(config-if)#no shut
R4(config-if)#ex
R4(config)#
*Mar  1 00:14:34.759: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:14:35.759: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R4(config)#int lo 0
R4(config-if)#
*Mar  1 00:14:45.343: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
R4(config-if)#ip add 4.4.4.4 255.255.255.255
R4(config-if)#no shut
R4(config-if)#ex
R4(config)#router ospf 1
R4(config-router)#router-id 4.4.4.4
R4(config-router)#network 192.168.40.0 0.0.0.255 area 0
R4(config-router)#
*Mar  1 00:16:04.599: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on FastEthernet0/0 from LOADING to FULL, Loading Done
R4(config-router)#network 192.168.50.0 0.0.0.255 area 0
R4(config-router)#

二、查看各个路由器路由表

1.路由器R1

R1(config-router)#ex
R1(config)#do show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, 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
C       1.1.1.1 is directly connected, Loopback0
C    192.168.10.0/24 is directly connected, FastEthernet0/0
C    192.168.20.0/24 is directly connected, FastEthernet0/1
R1(config)#

2.路由器R2

R2(config-router)#ex
R2(config)#do show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, 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

     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
C    192.168.30.0/24 is directly connected, FastEthernet0/1
O    192.168.10.0/24 [110/20] via 192.168.20.1, 00:13:56, FastEthernet0/0
O IA 192.168.40.0/24 [110/20] via 192.168.30.2, 00:08:59, FastEthernet0/1
C    192.168.20.0/24 is directly connected, FastEthernet0/0
O IA 192.168.50.0/24 [110/30] via 192.168.30.2, 00:05:32, FastEthernet0/1
R2(config)#

3.路由器R3

R3(config-router)#ex
R3(config)#do show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, 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

     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
C    192.168.30.0/24 is directly connected, FastEthernet0/0
C    192.168.40.0/24 is directly connected, FastEthernet0/1
O    192.168.50.0/24 [110/20] via 192.168.40.2, 00:06:46, FastEthernet0/1
R3(config)#

4.路由器R4

R4(config-router)#ex 
R4(config)#do show ip route
Codes: C - connected, S - static, 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
       i - IS-IS, su - IS-IS summary, 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

O IA 192.168.30.0/24 [110/20] via 192.168.40.1, 00:07:22, FastEthernet0/0
     4.0.0.0/32 is subnetted, 1 subnets
C       4.4.4.4 is directly connected, Loopback0
C    192.168.40.0/24 is directly connected, FastEthernet0/0
C    192.168.50.0/24 is directly connected, FastEthernet0/1
R4(config)#

通过查看后可以看出:

路由表获取的IP地址,都并不全面

三、给客户机配IP地址,并进行验证,查看结果

1.PC1

PC1> 
PC1> ip 192.168.10.2 192.168.10.1
Checking for duplicate address...
PC1 : 192.168.10.2 255.255.255.0 gateway 192.168.10.1

2.PC2


PC2> 
PC2> ip 192.168.50.2 192.168.50.1
Checking for duplicate address...
PC1 : 192.168.50.2 255.255.255.0 gateway 192.168.50.1

3.验证

PC1> ping 192.168.50.2 -t
*192.168.10.1 icmp_seq=1 ttl=255 time=9.240 ms (ICMP type:3, code:1, Destination host unreachable)
*192.168.10.1 icmp_seq=2 ttl=255 time=1.743 ms (ICMP type:3, code:1, Destination host unreachable)
*192.168.10.1 icmp_seq=3 ttl=255 time=2.129 ms (ICMP type:3, code:1, Destination host unreachable)
*192.168.10.1 icmp_seq=4 ttl=255 time=3.987 ms (ICMP type:3, code:1, Destination host unreachable)

验证结果表明:客户机之间并不互通

四、解决方法:做一条虚链路,在R2和R3上配置虚链路

1.路由器R2

R2(config)#router ospf 1
R2(config-router)#area 1 virtual-link 3.3.3.3
R2(config-router)#
*Mar  1 00:37:57.935: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on OSPF_VL0 from LOADING to FULL, Loading Done
R2(config-router)#

2.路由器R3

R3(config)#router ospf 1
R3(config-router)#
*Mar  1 00:35:21.715: %OSPF-4-ERRRCV: Received invalid packet: mismatch area ID, from backbone area must be virtual-link but not found from 192.168.30.1, FastEthernet0/0
R3(config-router)#area 1 vir
R3(config-router)#area 1 virtual-link 2.
*Mar  1 00:35:31.691: %OSPF-4-ERRRCV: Received invalid packet: mismatch area ID, from backbone area must be virtual-link but not found from 192.168.30.1, FastEthernet0/0
R3(config-router)#area 1 virtual-link 2.2.2.2
R3(config-router)#
*Mar  1 00:35:37.899: %OSPF-5-ADJCHG: Process 1, Nbr 2.2.2.2 on OSPF_VL0 from LOADING to FULL, Loading Done
R3(config-router)#

五、再次验证


PC1> ping 192.168.50.2 -t
192.168.50.2 icmp_seq=1 timeout
192.168.50.2 icmp_seq=2 timeout
84 bytes from 192.168.50.2 icmp_seq=3 ttl=60 time=83.775 ms
84 bytes from 192.168.50.2 icmp_seq=4 ttl=60 time=75.772 ms
84 bytes from 192.168.50.2 icmp_seq=5 ttl=60 time=82.045 ms
84 bytes from 192.168.50.2 icmp_seq=6 ttl=60 time=81.782 ms

查看结果表明:配置了虚拟链路后,客户机之间便可以互通

你可能感兴趣的:(OSPF)