R0#sh ip int bri
Interface IP-Address OK? Method Status Protocol FastEthernet0/0 192.168.0.251 YES NVRAM up up FastEthernet0/1 unassigned YES NVRAM administratively down down R0#sh ip ospf ne
Neighbor ID Pri State Dead Time Address Interface
192.168.0.249 1 FULL/BDR 00:00:36 192.168.0.249 FastEthernet0/0
R0#sh 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
172.16.0.0/24 is subnetted, 1 subnets
O 172.16.0.0 [110/20] via 192.168.0.249, 00:09:42, FastEthernet0/0 C 192.168.0.0/24 is directly connected, FastEthernet0/0 |
R1#sh ip ospf ne
Neighbor ID Pri State Dead Time Address Interface
192.168.0.251 1 FULL/DR 00:00:30 192.168.0.251 FastEthernet0/0 R1#sh ip int bri Interface IP-Address OK? Method Status Protocol FastEthernet0/0 192.168.0.249 YES NVRAM up up FastEthernet0/1 172.16.0.2 YES NVRAM up up
R1#sh 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
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.0.0 is directly connected, FastEthernet0/1 C 192.168.0.0/24 is directly connected, FastEthernet0/0 |
zebra# sh run
Current configuration:
! hostname zebra password zebra enable password zebra ! interface eth0 ipv6 nd suppress-ra ! interface lo ! interface pan0 ipv6 nd suppress-ra ! ! ! ! line vty ! end |
ospfd# sh run
Current configuration:
! hostname ospfd password zebra log stdout ! ! ! interface eth0 ! interface lo ! interface pan0 ! ! line vty ! end |
router ospf
network 172.16.0.0/16 area 0.0.0.0 network 192.168.0.0/24 area 0.0.0.0 |
R0#sh ip ospf ne
Neighbor ID Pri State Dead Time Address Interface
192.168.0.186 1 FULL/DROTHER 00:00:35 192.168.0.186 FastEthernet0/0 192.168.0.249 1 FULL/BDR 00:00:32 192.168.0.249 FastEthernet0/0
R1#sh ip ospf ne
Neighbor ID Pri State Dead Time Address Interface
192.168.0.186 1 FULL/DROTHER 00:00:35 192.168.0.186 FastEthernet0/0 192.168.0.251 1 FULL/DR 00:00:33 192.168.0.251 FastEthernet0/0 |
zebra# sh ip route
Codes: K - kernel route, C - connected, S - static, R - RIP, O - OSPF, I - ISIS, B - BGP, > - selected route, * - FIB route
K>* 0.0.0.0/0 via 192.168.0.1, eth0
C>* 127.0.0.0/8 is directly connected, lo K>* 169.254.0.0/16 is directly connected, eth0 O 172.16.0.0/24 [110/12] via 192.168.0.249, eth0, 00:12:27 O 192.168.0.0/24 [110/2] is directly connected, eth0, 00:12:27 C>* 192.168.0.0/24 is directly connected, eth0
这里很多人可能没见过K,K表示kernel,这是quagga表示ubuntu系统的路由和接口信息时用的。
|
interface eth0
ip ospf cost 1(这里也不一定非要1,只要比正常的开销小就行)
router ospf (需要将本地路由重分布到ospf中去,这样才能更新到R1和R0上)
redistribute kernel (这条没有测试是否为必须,但是一旦开启就会将zebra中标志为K的条目发送出去) redistribute connected (方法二需要) redistribute static (方法一需要) |
R0#sh 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
172.16.0.0/24 is subnetted, 1 subnets
O 172.16.0.0 [110/20] via 192.168.0.249, 00:09:42, FastEthernet0/0 C 192.168.0.0/24 is directly connected, FastEthernet0/0 |
R0#sh 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 E2 169.254.0.0/16 [110/20] via 192.168.0.186, 00:04:55, FastEthernet0/0(这条是redistribute kernel传递出来的)
172.16.0.0/24 is subnetted, 1 subnets O 172.16.0.0 [110/11] via 192.168.0.186, 00:04:55, FastEthernet0/0 C 192.168.0.0/24 is directly connected, FastEthernet0/0 |
R0# sh 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
172.16.0.0/24 is subnetted, 1 subnets
O E2 172.16.0.0 [110/20] via 192.168.0.186, 00:11:56, FastEthernet0/0 C 192.168.0.0/24 is directly connected, FastEthernet0/0 |
R0# sh 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
172.16.0.0/24 is subnetted, 1 subnets
O 172.16.0.0 [110/20] via 192.168.0.249, 00:00:01, FastEthernet0/0 C 192.168.0.0/24 is directly connected, FastEthernet0/0 |