ospf传递默认路由
第一步、预配置
r1(config)#int s2/1
r1(config-if)#ip add 12.0.0.1 255.255.255.0
r1(config-if)#no sh
r1(config-if)#int lo0
r1(config-if)#ip add 1.1.1.1 255.255.255.0
r1(config-if)#exit
r1(config)#router ospf 1
r1(config-router)#net 12.0.0.1 0.0.0.0 a 1
r1(config-router)#net 1.0.0.0 0.255.255.255 a 1
r1(config-router)#end
r2(config)#int s2/1
r2(config-if)#ip add 12.0.0.2 255.255.255.0
r2(config-if)#no sh
r2(config-if)#int s2/2
r2(config-if)#ip add 23.0.0.2 255.255.255.0
r2(config-if)#no sh
r2(config-if)#int lo0
r2(config-if)#ip add 2.2.2.2 255.255.255.0
r2(config-if)#exit
r2(config)#router ospf 1
r2(config-router)#net 12.0.0.2 0.0.0.0 a 1
r2(config-router)#net 2.2.2.2 0.0.0.0 a 1
r2(config-router)#net 23.0.0.2 0.0.0.0 a 0
r2(config-router)#end
r3(config)#int s2/1
r3(config-if)#ip add 23.0.0.3 255.255.255.0
r3(config-if)#no sh
r3(config-if)#int s2/2
r3(config-if)#ip add 34.0.0.3 255.255.255.0
r3(config-if)#no sh
r3(config-if)#int lo0
r3(config-if)#ip add 3.3.3.3 255.255.255.0
r3(config-if)#exit
r3(config)#router ospf 1
r3(config-router)#net 23.0.0.3 0.0.0.0 a 0
r3(config-router)#net 3.3.3.3 0.0.0.0 a 0
r3(config-router)#net 34.0.0.3 0.0.0.0 a 2
r3(config-router)#end
第二步、在r3上配置默认路由
方法一:
r3(config)#router ospf 1
r3(config-router)#default-information originate always
r3(config-router)#end
查看路由表:
r1#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 12.0.0.2 to network 0.0.0.0
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/65] via 12.0.0.2, 00:02:30, Serial2/1
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/129] via 12.0.0.2, 00:01:49, Serial2/1
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.0.0.0 [110/128] via 12.0.0.2, 00:02:30, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
O*E2 0.0.0.0/0 [110/1] via 12.0.0.2, 00:00:04, Serial2/1
r2#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 23.0.0.3 to network 0.0.0.0
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/65] via 12.0.0.1, 00:02:24, Serial2/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/65] via 23.0.0.3, 00:00:02, Serial2/2
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/2
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
O*E2 0.0.0.0/0 [110/1] via 23.0.0.3, 00:00:02, Serial2/2
r3#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
O IA 1.1.1.1 [110/129] via 23.0.0.2, 00:00:16, Serial2/1
2.0.0.0/32 is subnetted, 1 subnets
O IA 2.2.2.2 [110/65] via 23.0.0.2, 00:00:16, Serial2/1
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.0.0.0 [110/128] via 23.0.0.2, 00:00:16, Serial2/1
r3上没有默认路由,r1和r2上有
方法二:不加always,加一条默认路由
r3(config)#router ospf 1
r3(config-router)#no default-information originate always
r3(config-router)#default-information originate
r3(config-router)#exit
r3(config)#ip route 0.0.0.0 0.0.0.0 s2/1
r3(config)#end
r1#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 12.0.0.2 to network 0.0.0.0
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/65] via 12.0.0.2, 00:03:55, Serial2/1
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/129] via 12.0.0.2, 00:03:15, Serial2/1
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.0.0.0 [110/128] via 12.0.0.2, 00:03:55, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
O*E2 0.0.0.0/0 [110/1] via 12.0.0.2, 00:00:19, Serial2/1
r2#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 23.0.0.3 to network 0.0.0.0
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/65] via 12.0.0.1, 00:03:49, Serial2/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/65] via 23.0.0.3, 00:01:27, Serial2/2
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/2
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
O*E2 0.0.0.0/0 [110/1] via 23.0.0.3, 00:00:12, Serial2/2
r3#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 0.0.0.0 to network 0.0.0.0
1.0.0.0/32 is subnetted, 1 subnets
O IA 1.1.1.1 [110/129] via 23.0.0.2, 00:01:20, Serial2/1
2.0.0.0/32 is subnetted, 1 subnets
O IA 2.2.2.2 [110/65] via 23.0.0.2, 00:01:20, Serial2/1
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.0.0.0 [110/128] via 23.0.0.2, 00:01:20, Serial2/1
S* 0.0.0.0/0 is directly connected, Serial2/1
r1、r2、r3上都有默认路由
r1(config)#int s2/1
r1(config-if)#ip add 12.0.0.1 255.255.255.0
r1(config-if)#no sh
r1(config-if)#int lo0
r1(config-if)#ip add 1.1.1.1 255.255.255.0
r1(config-if)#exit
r1(config)#router ospf 1
r1(config-router)#net 12.0.0.1 0.0.0.0 a 1
r1(config-router)#net 1.0.0.0 0.255.255.255 a 1
r1(config-router)#end
r2(config)#int s2/1
r2(config-if)#ip add 12.0.0.2 255.255.255.0
r2(config-if)#no sh
r2(config-if)#int s2/2
r2(config-if)#ip add 23.0.0.2 255.255.255.0
r2(config-if)#no sh
r2(config-if)#int lo0
r2(config-if)#ip add 2.2.2.2 255.255.255.0
r2(config-if)#exit
r2(config)#router ospf 1
r2(config-router)#net 12.0.0.2 0.0.0.0 a 1
r2(config-router)#net 2.2.2.2 0.0.0.0 a 1
r2(config-router)#net 23.0.0.2 0.0.0.0 a 0
r2(config-router)#end
r3(config)#int s2/1
r3(config-if)#ip add 23.0.0.3 255.255.255.0
r3(config-if)#no sh
r3(config-if)#int s2/2
r3(config-if)#ip add 34.0.0.3 255.255.255.0
r3(config-if)#no sh
r3(config-if)#int lo0
r3(config-if)#ip add 3.3.3.3 255.255.255.0
r3(config-if)#exit
r3(config)#router ospf 1
r3(config-router)#net 23.0.0.3 0.0.0.0 a 0
r3(config-router)#net 3.3.3.3 0.0.0.0 a 0
r3(config-router)#net 34.0.0.3 0.0.0.0 a 2
r3(config-router)#end
第二步、在r3上配置默认路由
方法一:
r3(config)#router ospf 1
r3(config-router)#default-information originate always
r3(config-router)#end
查看路由表:
r1#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 12.0.0.2 to network 0.0.0.0
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/65] via 12.0.0.2, 00:02:30, Serial2/1
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/129] via 12.0.0.2, 00:01:49, Serial2/1
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.0.0.0 [110/128] via 12.0.0.2, 00:02:30, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
O*E2 0.0.0.0/0 [110/1] via 12.0.0.2, 00:00:04, Serial2/1
r2#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 23.0.0.3 to network 0.0.0.0
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/65] via 12.0.0.1, 00:02:24, Serial2/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/65] via 23.0.0.3, 00:00:02, Serial2/2
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/2
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
O*E2 0.0.0.0/0 [110/1] via 23.0.0.3, 00:00:02, Serial2/2
r3#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
O IA 1.1.1.1 [110/129] via 23.0.0.2, 00:00:16, Serial2/1
2.0.0.0/32 is subnetted, 1 subnets
O IA 2.2.2.2 [110/65] via 23.0.0.2, 00:00:16, Serial2/1
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.0.0.0 [110/128] via 23.0.0.2, 00:00:16, Serial2/1
r3上没有默认路由,r1和r2上有
方法二:不加always,加一条默认路由
r3(config)#router ospf 1
r3(config-router)#no default-information originate always
r3(config-router)#default-information originate
r3(config-router)#exit
r3(config)#ip route 0.0.0.0 0.0.0.0 s2/1
r3(config)#end
r1#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 12.0.0.2 to network 0.0.0.0
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/65] via 12.0.0.2, 00:03:55, Serial2/1
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/129] via 12.0.0.2, 00:03:15, Serial2/1
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.0.0.0 [110/128] via 12.0.0.2, 00:03:55, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
O*E2 0.0.0.0/0 [110/1] via 12.0.0.2, 00:00:19, Serial2/1
r2#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 23.0.0.3 to network 0.0.0.0
1.0.0.0/32 is subnetted, 1 subnets
O 1.1.1.1 [110/65] via 12.0.0.1, 00:03:49, Serial2/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/65] via 23.0.0.3, 00:01:27, Serial2/2
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/2
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
O*E2 0.0.0.0/0 [110/1] via 23.0.0.3, 00:00:12, Serial2/2
r3#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 0.0.0.0 to network 0.0.0.0
1.0.0.0/32 is subnetted, 1 subnets
O IA 1.1.1.1 [110/129] via 23.0.0.2, 00:01:20, Serial2/1
2.0.0.0/32 is subnetted, 1 subnets
O IA 2.2.2.2 [110/65] via 23.0.0.2, 00:01:20, Serial2/1
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.0.0.0 [110/128] via 23.0.0.2, 00:01:20, Serial2/1
S* 0.0.0.0/0 is directly connected, Serial2/1
r1、r2、r3上都有默认路由
