1.標記一個路由條目 為缺省網絡 2.在RIP,EIGRP/IGRP中提供缺省網絡的傳播
【補充說明】
1.使用ip default-network標記靜態路由指定的路由為缺省網絡,在RIP中不會傳播出去;在IGRP、EIGRP中不存在這 個問題,因為它們本來就需要將這個網段通告到路由協議中才能傳播出去
2.使用ip default-network標記直連網絡為缺省不會被使用,因為沒有下一跳。
【案例說明】
【實驗一】
R1:
interface Serial1/0
ip address 192.168.12.1 255.255.255.0
serial restart-delay 0
!
interface Serial2/0
no ip address
shutdown
serial restart-delay 0
!
router rip
network 192.168.12.0
R2:
interface Serial1/0
ip address 192.168.23.2 255.255.255.0
!
interface Serial2/0
ip address 192.168.12.2 255.255.255.0
router rip
network 192.168.12.0
ip default-network 3.0.0.0
ip route 3.0.0.0 255.0.0.0 192.168.23.3
R3:
interface Loopback3
ip address 6.6.6.6 255.255.255.0 secondary
ip address 3.3.3.3 255.255.255.0
!
interface Serial2/0
ip address 192.168.23.3 255.255.255.0
!
ip route 0.0.0.0 0.0.0.0 192.168.23.2
查看結果
R2#sh ip rou
Gateway of last resort is 192.168.23.3 to network 3.0.0.0
C 192.168.12.0/24 is directly connected, Serial2/0
S* 3.0.0.0/8 [1/0] via 192.168.23.3
C 192.168.23.0/24 is directly connected, Serial1/0
R1#sh ip rou
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial1/0
可以看到R1并沒有獲得這個路由條目。下面更改一下R2的配置:
R2:
no ip default-network 3.0.0.0
no ip route 3.0.0.0 255.0.0.0 192.168.23.3
ip default-network 192.168.23.0
R2#sh ip rou
Gateway of last resort is not set
C 192.168.12.0/24 is directly connected, Serial2/0
C* 192.168.23.0/24 is directly connected, Serial1/0
R2#
*Oct 3 07:15:26.147: RIP: sending v1 update to 255.255.255.255 via Serial2/0 (192.168.12.2)
*Oct 3 07:15:26.147: RIP: build update entries
*Oct 3 07:15:26.147: subnet 0.0.0.0 metric 1
R1#sh ip rou
Gateway of last resort is 192.168.12.2 to network 0.0.0.0
C 192.168.12.0/24 is directly connected, Serial1/0
R* 0.0.0.0/0 [120/1] via 192.168.12.2, 00:00:20, Serial1/0
此時可以看到192.168.23.0也沒有在RIP中通告,但是由于使用了ip default-network使其變為了默認網絡,從而將該網段通告了出去。
但是此時在R1上ping 6.6.6.6會ping 不通,因就在于R2上現在的缺省網絡無下一跳,Gateway of last resort is not set,
R1#ping 6.6.6.6
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 6.6.6.6, timeout is 2 seconds:
U
*Oct 3 07:21:46.751: IP: tableid=0, s=192.168.12.1 (local), d=6.6.6.6 (Serial1/0), routed via RIB
*Oct 3 07:21:46.751: IP: s=192.168.12.1 (local), d=6.6.6.6 (Serial1/0), len 100,
sending
*Oct 3 07:21:46.779: IP: tableid=0, s=192.168.12.2 (Serial1/0), d=192.168.12.1 (Serial1/0), routed via RIB
R2(config)#
*Oct 3 07:21:46.711: IP: s=192.168.12.1 (Serial2/0), d=6.6.6.6, len 100,
unroutable
*Oct 3 07:21:46.711: IP: tableid=0, s=192.168.12.2 (local), d=192.168.12.1 (Serial2/0), routed via RIB
解決方案:在R2上添加靜態缺省
R2(config)#ip route 0.0.0.0 0.0.0.0 192.168.23.3
R1#ping 6.6.6.6
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 6.6.6.6, timeout is 2 seconds:
!!!!!
搞定!
[實驗二]ip default-network在EIGRP中應用案例
R1:
R1(config)#router eigrp 100
R1(config-router)#net 192.168.12.0
R2:
R2(config)#no router rip
R2(config)#router eigrp 100
R2(config-router)#net 192.168.12.0
R2(config-router)#net 192.168.23.0
R2(config-router)#pa s1/0
實驗結果
R2#sh ip rou
Gateway of last resort is 192.168.23.3 to network 0.0.0.0
C 192.168.12.0/24 is directly connected, Serial2/0
C* 192.168.23.0/24 is directly connected, Serial1/0
S* 0.0.0.0/0 [1/0] via 192.168.23.3
R1#sh ip rou
Gateway of last resort is 192.168.12.2 to network 192.168.23.0
C 192.168.12.0/24 is directly connected, Serial1/0
D* 192.168.23.0/24 [90/2681856] via 192.168.12.2, 00:00:21, Serial1/0
R1#ping 6.6.6.6
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 6.6.6.6, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 40/41/48 ms
可以看到配置中和RIP不同的情況,需要將所通告的默認路由網段通告到 EIGRP/IGRP中;而且通告出去不像RIP變為了0 .0.0.0/0,仍舊是缺省網絡。