陶瓷加热灯 温度:RIP和EIGRP通告缺省路由的总结
一.RIP
①重分发静态缺省路由
ip route 0.0.0.0 0.0.0.0 s1/0
router rip
version 2
no auto-summary
redistribute connected
②使用命令default-information originate
router rip
version 2
no auto-summary
default-information originate //与OSPF不同,RIP在没有缺省路由的情况下也可以向其他路由器通告一条缺省路由,另外后面没有always参数
③使用命令ip default-network
router rip
version 2
no auto-summary
全局配置模式下 ip default-network 1.0.0.0 //后面所指定的网络为主类网络,不能是子网,否则不起作用(不管是否开启汇总).并且所指网络不用加入RIP进程,而EIGRP则必须加入进程。
拓扑图如上
R1上有一个环回口loopback0:1.1.1.1/24
R1和R2之间的网段为192.168.12.0/24
R2和R3之间的网段为192.168.23.0/24
R1关键配置如下:
router rip
version 2
network 192.168.12.0 //未将LOOPBACK0口加入RIP进程
no auto-summary
ip default-network 1.0.0.0
查看R1路由表:
R1#sh ip route
Gateway of last resort is not set //没有指定最后可选网关,因为R1就是到缺省网络的网关
C 192.168.12.0/24 is directly connected, Serial1/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
R 3.3.3.0 [120/2] via 192.168.12.2, 00:00:03, Serial1/0
R 192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:03, Serial1/0
查看R2路由表:
R2#sh ip route
Gateway of last resort is 192.168.12.1 to network 0.0.0.0 //在RIP里,R1上配置的命令ip default-network会使R1把0.0.0.0作为缺省路由通告,而不是命令ip default-network所指定的网络。这一点又和EIGRP有所不同
C 192.168.12.0/24 is directly connected, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
R 3.3.3.0 [120/1] via 192.168.23.3, 00:00:11, Serial1/1
C 192.168.23.0/24 is directly connected, Serial1/1
R* 0.0.0.0/0 [120/1] via 192.168.12.1, 00:00:00, Serial1/0
二.EIGRP
①重分发静态缺省路由
ip route 0.0.0.0 0.0.0.0 1.1.1.1
router eigrp 1
no auto-summary
redistribute static
②配置一條指向接口的靜態缺省路由,再在EIGRP進程里network 0.0.0.0 0.0.0.0
ip route 0.0.0.0 0.0.0.0 s1/0
router eigrp 1
no auto-summary
net 0.0.0.0 0.0.0.0
這里之所以要設置靜態缺省路由指向出接口,是因為若靜態路由是設置的出接口,那么在路由表中會認為這條路由是直連的(S* 0.0.0.0/0 is directly connected, Serial1/0),在EIGRP進程中使用net 0.0.0.0 0.0.0.0會把路由器上所有的直連網段都加入進程中,當然也會把缺省路由加入進程,這臺路由器就會向其他EIGRP鄰居通告缺省路由。使用该方法的缺点就是network 0.0.0.0会把路由器上所有直连网络加入EIGRP进程。
③使用命令ip summray-address eigrp 0.0.0.0 0.0.0.0
拓撲圖如上
R1上有一个环回口loopback0:1.1.1.1/24
loopback1:1.1.2.1/24
loopback2:1.1.3.1/24
R1和R2之间的网段为192.168.12.0/24
R2和R3之间的网段为192.168.23.0/24
R1关键配置如下:
interface Serial0
ip address 192.168.12.1 255.255.255.0
ip summary-address eigrp 1 0.0.0.0 0.0.0.0 5
serial restart-delay 0
no dce-terminal-timing-enable
router eigrp 1
network 1.1.0.0 0.0.255.255
network 192.168.12.1 0.0.0.0
no auto-summary
在使用ip summary-address eigrp 1 0.0.0.0 0.0.0.0 5之前,R2路由表如下:
R2#sh ip route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial1/0
1.0.0.0/24 is subnetted, 3 subnets
D 1.1.1.0 [90/2297856] via 192.168.12.1, 00:00:16, Serial1/0
D 1.1.2.0 [90/2297856] via 192.168.12.1, 00:00:16, Serial1/0
D 1.1.3.0 [90/2297856] via 192.168.12.1, 00:00:16, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
D 3.3.3.0 [90/2297856] via 192.168.23.3, 00:36:46, Serial1/1
C 192.168.23.0/24 is directly connected, Serial1/1
使用ip summary-address eigrp 1 0.0.0.0 0.0.0.0 5之后,R2路由表如下:
R2#sh ip route
Gateway of last resort is 192.168.12.1 to network 0.0.0.0
C 192.168.12.0/24 is directly connected, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
D 3.3.3.0 [90/2297856] via 192.168.23.3, 00:38:10, Serial1/1
C 192.168.23.0/24 is directly connected, Serial1/1
D* 0.0.0.0/0 [90/2297856] via 192.168.12.1, 00:00:17, Serial1/0
R2上確實有了一條缺省路由,但是因為0.0.0.0 0.0.0.0匯總了所有的網絡,所以所有的明細路由都沒有了。
如果想對1.0.0.0的三個子網做匯總的話,可以在接口上繼續使用ip summary-address命令:
ip summary-address eigrp 1 1.1.0.0 255.255.252.0
觀察R2路由表:
R2#sh ip route
Gateway of last resort is 192.168.12.1 to network 0.0.0.0
C 192.168.12.0/24 is directly connected, Serial1/0
1.0.0.0/22 is subnetted, 1 subnets
D 1.1.0.0 [90/2297856] via 192.168.12.1, 00:00:57, Serial1/0 //汇总路由还是会通告给R2,并不会被抑制
3.0.0.0/24 is subnetted, 1 subnets
D 3.3.3.0 [90/2297856] via 192.168.23.3, 00:43:43, Serial1/1
C 192.168.23.0/24 is directly connected, Serial1/1
D* 0.0.0.0/0 [90/2297856] via 192.168.12.1, 00:05:50, Serial1/0
如果想使用该命令通告一条缺省路由,而又不抑制所有明细路由,可以在ip summary-address后调用leak-map:
ip summary-address eigrp 1 0.0.0.0 0.0.0.0 5 leak-map DETAIL //通过leak-map来调用名为DETAIL的route-map
route-map DETAIL //这条route-map下可以不写任何命令,默认就是允许所有
④使用命令ip default-network
使用这条命令需要分情况
1.与ip default-network后所指网络相连的接口ip地址为主类网络(非子网)
拓扑图如上
R1上有一个环回口loopback0:1.1.1.1/8 //主类网络
R1和R2之间的网段为192.168.12.0/24
R2和R3之间的网段为192.168.23.0/24
R1关键配置如下:
router eigrp 1
network 1.0.0.0 //必须要把ip default-network所指定的网络通告进EIGRP,否则不起作用。这点和RIP不同,RIP不用把所指网络通告进RIP就可以通告缺省路由
network 192.168.12.1 0.0.0.0
no auto-summary
ip default-network 1.0.0.0 //后面所接网络必须是主类网络
查看R1路由表:
R1#sh ip route
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial1/0
C* 1.0.0.0/8 is directly connected, Loopback0
3.0.0.0/24 is subnetted, 1 subnets
D 3.3.3.0 [90/2809856] via 192.168.12.2, 01:19:18, Serial1/0
D 192.168.23.0/24 [90/2681856] via 192.168.12.2, 01:19:35, Serial1/0
查看R2路由表:
R2#sh ip route
Gateway of last resort is 192.168.12.1 to network 1.0.0.0 //EIGRP使用ip default-network命令后所指的网络作为缺省网络通告出去,所以这里显示的是1.0.0.0。而RIP是将0.0.0.0作为缺省网络通告出去。这是两者之间的又一个区别
C 192.168.12.0/24 is directly connected, Serial1/0
D* 1.0.0.0/8 [90/2297856] via 192.168.12.1, 00:02:47, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
D 3.3.3.0 [90/2297856] via 192.168.23.3, 01:21:30, Serial1/1
C 192.168.23.0/24 is directly connected, Serial1/1
2.与ip default-network后所指网络相连的接口ip地址为子网地址
拓扑图和ip编址同上,R1的loopback0 ip地址改为1.1.1.1/24(1.0.0.0的子网)
R1配置步骤如下:
1.ip default-network 1.1.1.0
输入这条命令后,会生成这样一条路由:S 1.0.0.0/8 [1/0] via 1.1.1.0
2.ip default-network 1.0.0.0
输入该命令后,第一步中生成的路由会成为缺省路由:S* 1.0.0.0/8 [1/0] via 1.1.1.0
3.把这条静态路由重分发进入EIGRP进程(关闭自动汇总)
注意,可以将ip default-network所指网段通告进EIGRP,也可以不通告进EIGRP。区别是若通告了这个网段,那么内部路由器会有一条1.1.1.0的路由条目,反之则没有
查看R2路由表:
R2#sh ip route
Gateway of last resort is 192.168.12.1 to network 1.0.0.0
C 192.168.12.0/24 is directly connected, Serial1/0
1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
D 1.1.1.0/24 [90/2297856] via 192.168.12.1, 00:15:59, Serial1/0
D*EX 1.0.0.0/8 [170/2297856] via 192.168.12.1, 00:07:36, Serial1/0
3.0.0.0/24 is subnetted, 1 subnets
D 3.3.3.0 [90/2297856] via 192.168.23.3, 01:58:46, Serial1/1
C 192.168.23.0/24 is directly connected, Serial1/1
还有一种方法,就是只输入命令ip default-network 1.0.0.0,并且打开EIGRP的自动汇总,注意这时就必须把网络1.1.1.0通告进EIGRP进程,因为EIGRP使用真实的网络作为缺省网络。上面那一种方法不用通告进去是因为本质上还是重分发静态路由。因为这个方法需要打开auto-summary,因此会有较大的限制。
最后要说明的是,EIGRP里不存在default-information originate命令