实验拓扑
R1(config)#int lo 0
R1(config-if)#ip add 1.1.1.1 255.255.255.255
R1(config-if)#ex
R1(config)#int f0/0
R1(config-if)#ip add 192.168.12.1 255.255.255.0
R1(config-if)#no sh
R1(config-if)#
*Mar 1 00:15:25.539: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:15:26.539: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#do sh ip int b
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.12.1 YES manual up up
Loopback0 1.1.1.1 YES manual up up
R1(config-if)#
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int lo 0
R2(config-if)#ip add 2.2.2.2 255.255.255.255
R2(config-if)#int f0/0
R2(config-if)#ip add 192.168.12.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#
*Mar 1 00:17:28.315: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 00:17:29.315: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2(config-if)#int f1/0
R2(config-if)#ip add 192.168.23.1 255.255.255.0
R2(config-if)#no sh
R2(config-if)#
*Mar 1 00:17:53.699: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up
*Mar 1 00:17:54.699: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up
R2(config-if)#do sh ip int b
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.12.2 YES manual up up
FastEthernet1/0 192.168.23.1 YES manual up up
Loopback0 2.2.2.2 YES manual up up
R2(config-if)#
R3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#int lo 0
R3(config-if)#ip add 3.3.3.3 255.255.255.255
R3(config-if)#int f1/0
R3(config-if)#ip add 192.168.23.2 255.255.255.0
R3(config-if)#no sh
R3(config-if)#do sh p
*Mar 1 00:19:51.587: %LINK-3-UPDOWN: Interface FastEthernet1/0, changed state to up
*Mar 1 00:19:52.587: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up
R3(config-if)#do sh ip int b
Interface IP-Address OK? Method Status Protocol
FastEthernet1/0 192.168.23.2 YES manual up up
Loopback0 3.3.3.3 YES manual up up
R3(config-if)#
从R2上验证和R1 R3的连通性
R2#ping 192.168.12.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.12.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 20/32/56 ms
R2#ping 192.168.23.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 20/32/44 ms
R2#
但是lo 口是不通的
R1#ping 3.3.3.3 sour
R1#ping 3.3.3.3 source lo 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
.....
Success rate is 0 percent (0/5)
开始配置路由协议
R1#
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#router ospf 100
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.12.1 0.0.0.0 area 0
R1(config-router)#end
R1#
*Mar 1 01:01:21.491: %SYS-5-CONFIG_I: Configured from console by console
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#router ospf 100
R2(config-router)#router-id 2.2.2.2
R2(config-router)#network 192.168.12.2 0.0.0.0 area 0
R2(config-router)#network 2.2.2.2 0.0.0.0 a 0
R2(config-router)#network 192.168.23.1 0.0.0.0 a 1
R3(config)#router ospf 100
R3(config-router)#router-id 3.3.3.3
R3(config-router)#network 192.168.23.2 0.0.0.0 a 1
R3(config-router)#network
*Mar 1 01:07:21.891: %OSPF-5-ADJCHG: Process 100, Nbr 2.2.2.2 on FastEthernet1/0 from LOADING to FULL, Loading Done
R3(config-router)#network 3.3.3.3 0.0.0.0 a 1
已经可以看到进程为100的 邻居为2.2.2.2 状态已经起来了
看下R1
R1#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/BDR 00:00:37 192.168.12.2 FastEthernet0/0
R1#
邻居关系已经建立,状态是2.2.2.2是BDR备用选举路由器
在R2上看,R1是主选举主
R2#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
1.1.1.1 1 FULL/DR 00:00:37 192.168.12.1 FastEthernet0/0
3.3.3.3 1 FULL/BDR 00:00:37 192.168.23.2 FastEthernet1/0
R2#
从R1测试到R3的
R1#ping 192.168.23.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/34/44 ms
R1#ping 3.3.3.3 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 40/49/68 ms
R1#
都好了
从R2上看,R3是BDR,把直连R3的接口权限提高下,然后清空ospf 进程
R2(config)#int f1/0
R2(config-if)#ip ospf priority 2
R2(config)#end
R2#clear ip ospf process
Reset ALL OSPF processes? [no]: yes
R2#
*Mar 1 12:33:51.728: %OSPF-5-ADJCHG: Process 100, Nbr 1.1.1.1 on FastEthernet0/0 from FULL to DOWN, Neighbor Down: Interface down or detached
*Mar 1 12:33:51.764: %OSPF-5-ADJCHG: Process 100, Nbr 3.3.3.3 on FastEthernet1/0 from FULL to DOWN, Neighbor Down: Interface down or detached
R2#
*Mar 1 12:34:00.112: %OSPF-5-ADJCHG: Process 100, Nbr 1.1.1.1 on FastEthernet0/0 from LOADING to FULL, Loading Done
*Mar 1 12:34:00.836: %OSPF-5-ADJCHG: Process 100, Nbr 3.3.3.3 on FastEthernet1/0 from LOADING to FULL, Loading Done
R3已经是area 1的主选举路由了
配置IPV6的接口地址
R1(config)#ipv6 unicast-routing
R1(config)#int f0/0
R1(config-if)#ipv6 address 2001:12:12::1/64
R1(config-if)#
R2(config)#ipv6 unicast-routing
R2(config)#int f0/0
R2(config-if)#ipv6 address 2001:12:12::2/64
R2(config-if)#no sh
R2(config-if)#do ping 2001:12:12::1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2001:12:12::1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/27/44 ms
R2(config)#int f1/0
R2(config-if)#ipv6 address 2001:23:23::1/64
R2(config-if)#no sh
R3(config)#ipv6 unicast-routing
R3(config)#int f1/0
R3(config-if)#ipv6 ad
R3(config-if)#ipv6 address 2001:23:23::2/64
R3(config-if)#no sh
R3(config-if)#do ping 2001:23:23::1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2001:23:23::1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/27/44 ms
R3(config-if)#
精确宣告IPV6 路由地址
R1(config)#ipv6 router ospf 200
R1(config-rtr)#router-id 1.1.1.1
R1(config-rtr)#int f0/0
R1(config-if)#ipv6 ospf 200 area 0
唯一的区别是IPV6是在接口配置IPV4是在路由接口配置的
R2(config)#ipv6 router ospf 200
R2(config-rtr)#rou
R2(config-rtr)#router-id 2.2.2.2
R2(config-rtr)#int f0/0
R2(config-if)#ipv6 os
R2(config-if)#ipv6 ospf ?
R2(config-if)#ipv6 ospf 200 area 0
R2(config)#int f1/0
R2(config-if)#ipv6 ospf 200 area 1
R3(config)#ipv6 router ospf 200
R3(config-rtr)#router-id 3.3.3.3
R3(config-rtr)#int f1/0
R3(config-if)#ipv6 ospf 200 area 1
R3(config-if)#e
R3#sh run int f1/0
Building configuration...
Current configuration : 150 bytes
!
interface FastEthernet1/0
ip address 192.168.23.2 255.255.255.0
duplex auto
speed auto
ipv6 address 2001:23:23::2/64
ipv6 ospf 200 area 1
end
在各路由上看IPV6的邻居
R1#sh ipv6 ospf neighbor
Neighbor ID Pri State Dead Time Interface ID Interface
2.2.2.2 1 FULL/BDR 00:00:32 3 FastEthernet0/0
R1#
R2#sh ipv6 ospf neighbor
Neighbor ID Pri State Dead Time Interface ID Interface
1.1.1.1 1 FULL/DR 00:00:38 3 FastEthernet0/0
3.3.3.3 1 FULL/BDR 00:00:31 3 FastEthernet1/0
R2#
R3#sh ipv6 ospf neighbor
Neighbor ID Pri State Dead Time Interface ID Interface
2.2.2.2 1 FULL/DR 00:00:39 4 FastEthernet1/0
从R1 R3互通验证
R1#ping 2001:23:23::2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2001:23:23::2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 40/41/48 ms
R1#
R3#ping 2001:12:12::1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2001:12:12::1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 40/44/48 ms
R3#
来源:oschina
链接:https://my.oschina.net/u/4351661/blog/4870784