实现EIGRP默认路由:
方法1:写一条默认路由,重发布到EIGRP中
R2(config)#ip route 0.0.0.0 0.0.0.0 s0/0 172.16.12.1 //使用出站接口和下一跳IP地址均可
R2(config-router)#redistribute static metric 1544 20000 1 255 1500
查看R3上的路由表如下:
Gateway of last resort is 192.168.23.2 to network 0.0.0.0
D 192.168.45.0/24 [90/2681856] via 192.168.34.4, 00:31:50, Serial0/1
D 192.168.25.0/24 [90/2681856] via 192.168.23.2, 00:31:52, Serial0/0
C 192.168.23.0/24 is directly connected, Serial0/0
C 192.168.34.0/24 is directly connected, Serial0/1
D*EX 0.0.0.0/0 [170/7289856] via 192.168.23.2, 00:00:05, Serial0/0
默认路由条目以外部路由存在
方法2:使用EIGRP特有的IP default-network宣告默认路由
ip default-network 后的IP地址一定要是主类IP地址,并且处于所宣告该网段的接口的IP地址也必须的主类IP地址。
如果R2配置如下:
router eigrp 10
network 172.16.0.0
network 192.168.23.0
network 192.168.25.0
no auto-summary
R2(config)#ip default-network 172.16.12.0
则R2上show run会发现多处一条静态路由:ip route 172.16.0.0 255.255.0.0 172.16.12.0
该静态路由是由宣告子网所造成的。所产生的路由表如下:
Gateway of last resort is 172.16.12.1 to network 0.0.0.0
D 192.168.45.0/24 [90/2681856] via 192.168.25.5, 00:05:14, Serial0/2
C 192.168.25.0/24 is directly connected, Serial0/2
172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
C 172.16.12.0/24 is directly connected, Serial0/0
S 172.16.0.0/16 [1/0] via 172.16.12.0 生成的静态路由
C 192.168.23.0/24 is directly connected, Serial0/1
D 192.168.34.0/24 [90/2681856] via 192.168.23.3, 00:05:14, Serial0/1
S* 0.0.0.0/0 [1/0] via 172.16.12.1
正确方法:router eigrp 10
network 172.16.0.0
network 192.168.23.0
network 192.168.25.0
no auto-summary
R2(config)#int s0/0
R2(config-if)#ip add 172.16.12.2 255.255.0.0
R2(config)#ip default-network 172.16.0.0
查看R2路由表
Gateway of last resort is 172.16.12.1 to network 0.0.0.0
D 192.168.45.0/24 [90/2681856] via 192.168.25.5, 00:20:58, Serial0/2
C 192.168.25.0/24 is directly connected, Serial0/2
C* 172.16.0.0/16 is directly connected, Serial0/0
C 192.168.23.0/24 is directly connected, Serial0/1
D 192.168.34.0/24 [90/2681856] via 192.168.23.3, 00:20:58, Serial0/1
S* 0.0.0.0/0 [1/0] via 172.16.12.1
172.16.0.0的默认路由用于宣告给EIGRP邻居,作为邻居的最后求助(last-resort)的网关,但ip default-network对自己不生效,所以必须再在R2上配置
ip route 0.0.0.0 0.0.0.0 172.16.12.1
查看R3路由表:
Gateway of last resort is 192.168.23.2 to network 172.16.0.0
//R3将通告给自己172.16.0.0默认路由的路由器设定为网关
D 192.168.45.0/24 [90/2681856] via 192.168.34.4, 00:24:25, Serial0/1
D 192.168.25.0/24 [90/2681856] via 192.168.23.2, 00:24:26, Serial0/0
172.16.0.0/16 is subnetted, 1 subnets
D* 172.16.0.0 [90/2681856] via 192.168.23.2, 00:05:48, Serial0/0
C 192.168.23.0/24 is directly connected, Serial0/0
C 192.168.34.0/24 is directly connected, Serial0/1
建议在R2上简历一个C类的环回口,然后作为表示本台路由器的默认路由宣告给EIGRP邻居
R2上部分配置如下:
interface Loopback0
ip address 192.168.1.1 255.255.255.0
router eigrp 10
network 192.168.1.0
network 192.168.23.0
network 192.168.25.0
no auto-summary
ip default-network 192.168.1.0
ip route 0.0.0.0 0.0.0.0 172.16.12.1
查看R2路由表:
Gateway of last resort is 172.16.12.1 to network 0.0.0.0
D 192.168.45.0/24 [90/2681856] via 192.168.25.5, 00:32:03, Serial0/2
C 192.168.25.0/24 is directly connected, Serial0/2
C 172.16.0.0/16 is directly connected, Serial0/0
C 192.168.23.0/24 is directly connected, Serial0/1
D 192.168.34.0/24 [90/2681856] via 192.168.23.3, 00:32:03, Serial0/1
C* 192.168.1.0/24 is directly connected, Loopback0
S* 0.0.0.0/0 [1/0] via 172.16.12.1
解析:在R2上所配置的IP default-network 的网段主要用于标示R2,告诉自己的EIGRP邻居,“如果不知道如何转发数据包,就交给该网段(就是R2)”。仅当使用该命令的路由器能够到达指定网络时,才会将其作为候选默认路由宣告给其他EIGRP路由器。同时还必须将该命令中指定的网络号通告给其他EIGRP路由器,这样这些路由器才能将该网络作为其默认路由,并将其最后求助的网关设置为该默认网络。该网段必须是由EIGRP加入到路由选择表中的,或是根据静态路由生成并被重分布到EIGRP中的。
方法3:写一条出站接口默认路由,并将该默认路由宣告进EIGRP中
默认情况下,EIGRP不重分布默认路由0.0.0.0 0.0.0.0,然而,如果EIGRP配置中包含命令network 0.0.0.0,则命令ip route 0.0.0.0 0.0.0.0 interface(出站接口) 将导致EIGRP重发布一条默认路由。但使用下一跳IP地址将不会导致这样的结果。
R2上配置如下:
router eigrp 10
network 192.168.23.0
network 192.168.25.0
network 0.0.0.0
no auto-summary
ip route 0.0.0.0 0.0.0.0 Serial0/0 注意:必须使用出站接口
使用该方法会将所有接口宣告进EIGRP中,不推荐使