当Eigrp路由连接一个外部网络时,可以通告一条静态的默认路由到EIGRP中去.即当做边界或称为”网关”,发布时,只能发主类网段。
R1:
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface FastEthernet0/0
ip address 10.1.1.1 255.255.255.0
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface FastEthernet0/0
ip address 10.1.1.1 255.255.255.0
duplex auto
speed auto
speed auto
router eigrp 100
network 1.1.1.0 0.0.0.255
network 10.1.1.0 0.0.0.255
no auto-summary
!
network 1.1.1.0 0.0.0.255
network 10.1.1.0 0.0.0.255
no auto-summary
!
R2:
interface Loopback0
ip address 172.16.1.1 255.255.255.0
!
interface FastEthernet0/0
ip address 10.1.1.2 255.255.255.0
duplex auto
speed auto
!
router eigrp 100
network 10.1.1.0 0.0.0.255
network 172.16.1.0 0.0.0.255
no auto-summary
interface Loopback0
ip address 172.16.1.1 255.255.255.0
!
interface FastEthernet0/0
ip address 10.1.1.2 255.255.255.0
duplex auto
speed auto
!
router eigrp 100
network 10.1.1.0 0.0.0.255
network 172.16.1.0 0.0.0.255
no auto-summary
ip default-network 172.16.0.0
ip route 172.16.0.0 255.255.0.0 172.16.1.2
ip route 172.16.0.0 255.255.0.0 172.16.1.2
查看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
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 172.16.1.2 to network 172.16.0.0
1.0.0.0/24 is subnetted, 1 subnets
D 1.1.1.0 [90/156160] via 10.1.1.1, 00:08:16, FastEthernet0/0
* 172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
S* 172.16.0.0/16 [1/0] via 172.16.1.2 //产生了一条静态默认路由,经过172.16.1.2
C 172.16.1.0/24 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, FastEthernet0/0
D 1.1.1.0 [90/156160] via 10.1.1.1, 00:08:16, FastEthernet0/0
* 172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
S* 172.16.0.0/16 [1/0] via 172.16.1.2 //产生了一条静态默认路由,经过172.16.1.2
C 172.16.1.0/24 is directly connected, Loopback0
10.0.0.0/24 is subnetted, 1 subnets
C 10.1.1.0 is directly connected, FastEthernet0/0
查看R1的路由表:
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
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 10.1.1.2 to network 172.16.0.0
1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 1.1.1.0/24 is directly connected, Loopback0
D 1.0.0.0/8 is a summary, 00:01:17, Null0
D* 172.16.0.0/16 [90/156160] via 10.1.1.2, 00:00:09, FastEthernet0/0 //所有到172.16.0.0的网段都会发到F1/0接口上.直到达到路由器R2,即边界路由器
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.1.1.0/30 is directly connected, FastEthernet0/0
D 10.0.0.0/8 is a summary, 00:01:17, Null0
C 1.1.1.0/24 is directly connected, Loopback0
D 1.0.0.0/8 is a summary, 00:01:17, Null0
D* 172.16.0.0/16 [90/156160] via 10.1.1.2, 00:00:09, FastEthernet0/0 //所有到172.16.0.0的网段都会发到F1/0接口上.直到达到路由器R2,即边界路由器
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.1.1.0/30 is directly connected, FastEthernet0/0
D 10.0.0.0/8 is a summary, 00:01:17, Null0
如果在R2上不发布一个主类网络,如下:
R2(config)#no ip default-network 172.16.0.0
R2(config)#ip default-network 172.16.1.0 //把172.16.0.0 换成172.16.1.0
R2(config)#no ip default-network 172.16.0.0
R2(config)#ip default-network 172.16.1.0 //把172.16.0.0 换成172.16.1.0
R1路由表显示如下:
R1#clear ip route *
R1#sh ip route
Gateway of last resort is not set
1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 1.1.1.0/24 is directly connected, Loopback0
D 1.0.0.0/8 is a summary, 00:05:53, Null0
D 172.16.0.0/16 [90/156160] via 10.1.1.2, 00:01:58, FastEthernet0/0 //从EIGRP学来的默认路由已经消失
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.1.1.0/30 is directly connected, FastEthernet0/0
D 10.0.0.0/8 is a summary, 00:05:53, Null0
R1#clear ip route *
R1#sh ip route
Gateway of last resort is not set
1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 1.1.1.0/24 is directly connected, Loopback0
D 1.0.0.0/8 is a summary, 00:05:53, Null0
D 172.16.0.0/16 [90/156160] via 10.1.1.2, 00:01:58, FastEthernet0/0 //从EIGRP学来的默认路由已经消失
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.1.1.0/30 is directly connected, FastEthernet0/0
D 10.0.0.0/8 is a summary, 00:05:53, Null0