CCNP Day4 EIGRP默认路由
1、配置拓扑(在R3上添加一条默认路由)
R3(config)#ip router 0.0.0.0 0.0.0.0 loopback 0 /**第一种配置方法**/
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 0.0.0.0 to network 0.0.0.0 1.0.0.0/24 is subnetted, 1 subnets D 1.1.1.0 [90/2300416] via 192.168.23.1, 00:35:14, Serial1/0 3.0.0.0/24 is subnetted, 1 subnets C 3.3.3.0 is directly connected, Loopback0 172.16.0.0/24 is subnetted, 1 subnets D 172.16.12.0 [90/2172416] via 192.168.23.1, 00:35:18, Serial1/0 C 192.168.23.0/24 is directly connected, Serial1/0 S* 0.0.0.0/0 is directly connected, Loopback0 /**默认路由带*号**/ R3(config)#
2、把默认路由宣告到Eigrp
R3(config)#router eigrp 100 R3(config-router)#network 0.0.0.0 R3(config-router)#end R3#show ip rou *Nov 25 11:02:34.911: %SYS-5-CONFIG_I: Configured from console by console 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/24 is subnetted, 1 subnets D 1.1.1.0 [90/2300416] via 192.168.23.1, 00:39:32, Serial1/0 3.0.0.0/24 is subnetted, 1 subnets C 3.3.3.0 is directly connected, Loopback0 172.16.0.0/24 is subnetted, 1 subnets D 172.16.12.0 [90/2172416] via 192.168.23.1, 00:39:36, Serial1/0 C 192.168.23.0/24 is directly connected, Serial1/0 S* 0.0.0.0/0 is directly connected, Loopback0 R3#
3、在R1和R2上查看路由
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 192.168.23.2 to network 0.0.0.0 1.0.0.0/24 is subnetted, 1 subnets D 1.1.1.0 [90/156160] via 172.16.12.1, 00:40:52, FastEthernet0/0 3.0.0.0/24 is subnetted, 1 subnets D 3.3.3.0 [90/2297856] via 192.168.23.2, 00:42:38, Serial1/0 172.16.0.0/24 is subnetted, 1 subnets C 172.16.12.0 is directly connected, FastEthernet0/0 C 192.168.23.0/24 is directly connected, Serial1/0 D* 0.0.0.0/0 [90/2297856] via 192.168.23.2, 00:01:24, Serial1/0 R2# 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 not set 1.0.0.0/24 is subnetted, 1 subnets C 1.1.1.0 is directly connected, Loopback0 3.0.0.0/24 is subnetted, 1 subnets D 3.3.3.0 [90/2300416] via 172.16.12.2, 00:02:15, FastEthernet0/0 172.16.0.0/24 is subnetted, 1 subnets C 172.16.12.0 is directly connected, FastEthernet0/0 D 192.168.23.0/24 [90/2172416] via 172.16.12.2, 00:02:15, FastEthernet0/0 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 172.16.12.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 3.0.0.0/24 is subnetted, 1 subnets D 3.3.3.0 [90/2300416] via 172.16.12.2, 00:40:44, FastEthernet0/0 172.16.0.0/24 is subnetted, 1 subnets C 172.16.12.0 is directly connected, FastEthernet0/0 D 192.168.23.0/24 [90/2172416] via 172.16.12.2, 00:40:44, FastEthernet0/0 D* 0.0.0.0/0 [90/2300416] via 172.16.12.2, 00:01:18, FastEthernet0/0 R1#
静态路由的第二战配置方法(下一条是出口IP)
R3# R3#config t Enter configuration commands, one per line. End with CNTL/Z. 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 1.0.0.0/24 is subnetted, 1 subnets D 1.1.1.0 [90/2300416] via 192.168.23.1, 00:57:16, Serial1/0 3.0.0.0/24 is subnetted, 1 subnets C 3.3.3.0 is directly connected, Loopback0 172.16.0.0/24 is subnetted, 1 subnets D 172.16.12.0 [90/2172416] via 192.168.23.1, 00:57:19, Serial1/0 C 192.168.23.0/24 is directly connected, Serial1/0 R3(config)#ip route 0.0.0.0 0.0.0.0 3.3.3.254 R3(config)# R3(config)# R3(config)# 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 3.3.3.254 to network 0.0.0.0 1.0.0.0/24 is subnetted, 1 subnets D 1.1.1.0 [90/2300416] via 192.168.23.1, 00:58:13, Serial1/0 3.0.0.0/24 is subnetted, 1 subnets C 3.3.3.0 is directly connected, Loopback0 172.16.0.0/24 is subnetted, 1 subnets D 172.16.12.0 [90/2172416] via 192.168.23.1, 00:58:17, Serial1/0 C 192.168.23.0/24 is directly connected, Serial1/0 S* 0.0.0.0/0 [1/0] via 3.3.3.254 R3(config)#
R3(config)#
R3(config)#
R3(config)#router eigrp 100
R3(config-router)#network 0.0.0.0
R3(config-router)#end
R3#show
*Nov 25 11:30:31.731: %SYS-5-CONFIG_I: Configured from console by console
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 3.3.3.254 to network 0.0.0.0
1.0.0.0/24 is subnetted, 1 subnets
D 1.1.1.0 [90/2300416] via 192.168.23.1, 01:07:32, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
172.16.0.0/24 is subnetted, 1 subnets
D 172.16.12.0 [90/2172416] via 192.168.23.1, 01:07:36, Serial1/0
C 192.168.23.0/24 is directly connected, Serial1/0
S* 0.0.0.0/0 [1/0] via 3.3.3.254
R3#
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 not set 1.0.0.0/24 is subnetted, 1 subnets C 1.1.1.0 is directly connected, Loopback0 3.0.0.0/24 is subnetted, 1 subnets D 3.3.3.0 [90/2300416] via 172.16.12.2, 00:59:50, FastEthernet0/0 172.16.0.0/24 is subnetted, 1 subnets C 172.16.12.0 is directly connected, FastEthernet0/0 D 192.168.23.0/24 [90/2172416] via 172.16.12.2, 00:59:50, FastEthernet0/0 R1# 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 not set 1.0.0.0/24 is subnetted, 1 subnets D 1.1.1.0 [90/156160] via 172.16.12.1, 00:59:47, FastEthernet0/0 3.0.0.0/24 is subnetted, 1 subnets D 3.3.3.0 [90/2297856] via 192.168.23.2, 01:01:33, Serial1/0 172.16.0.0/24 is subnetted, 1 subnets C 172.16.12.0 is directly connected, FastEthernet0/0 C 192.168.23.0/24 is directly connected, Serial1/0 R2#
以IP为出口的静态路由不会同步到其它路由器,需要外部路由重发布。
外部路由重分布
R3(config)#route R3(config)#router eigrp 100 R3(config-router)#redistribute static R3(config-router)#end R3#show *Nov 25 11:34:33.911: %SYS-5-CONFIG_I: Configured from console by console 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 3.3.3.254 to network 0.0.0.0 1.0.0.0/24 is subnetted, 1 subnets D 1.1.1.0 [90/2300416] via 192.168.23.1, 01:11:32, Serial1/0 3.0.0.0/24 is subnetted, 1 subnets C 3.3.3.0 is directly connected, Loopback0 172.16.0.0/24 is subnetted, 1 subnets D 172.16.12.0 [90/2172416] via 192.168.23.1, 01:11:36, Serial1/0 C 192.168.23.0/24 is directly connected, Serial1/0 S* 0.0.0.0/0 [1/0] via 3.3.3.254 R3#
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 192.168.23.2 to network 0.0.0.0 1.0.0.0/24 is subnetted, 1 subnets D 1.1.1.0 [90/156160] via 172.16.12.1, 01:11:57, FastEthernet0/0 3.0.0.0/24 is subnetted, 1 subnets D 3.3.3.0 [90/2297856] via 192.168.23.2, 01:13:43, Serial1/0 172.16.0.0/24 is subnetted, 1 subnets C 172.16.12.0 is directly connected, FastEthernet0/0 C 192.168.23.0/24 is directly connected, Serial1/0 D*EX 0.0.0.0/0 [170/2297856] via 192.168.23.2, 00:01:17, Serial1/0 R2#
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 172.16.12.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
3.0.0.0/24 is subnetted, 1 subnets
D 3.3.3.0 [90/2300416] via 172.16.12.2, 01:14:37, FastEthernet0/0
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.12.0 is directly connected, FastEthernet0/0
D 192.168.23.0/24 [90/2172416] via 172.16.12.2, 01:14:37, FastEthernet0/0
D*EX 0.0.0.0/0 [170/2300416] via 172.16.12.2, 00:03:59, FastEthernet0/0
R1#
如果多条静态路由中,只想发布其中的一条,可以使用route-map来控制,如下:
R3#enable
R3#config t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#acc
R3(config)#access-list 1 permit 0.0.0.0
R3(config)#route-map A permit 10
R3(config-route-map)#match ip address 1
R3(config-route-map)#
R3(config-route-map)#exit
R3(config)#router eig
R3(config)#router eigrp 100
R3(config-router)#redistribute static route
R3(config-router)#redistribute static route-map A
R3(config-router)#