实验目的:

1、掌握通过ip default-network命令配置EIGRP默认网络。

实验拓扑:

实验步骤:

1、配置各路由器的名称、相连接口IP地址,并且使用Ping命令确认各路由器的直连口的互通性。 

R1

R2(config)#int s1/0

R2(config-if)#ip add 172.16.1.2 255.255.255.252

R2(config-if)#no shut

R2(config-if)#int s1/1

R2(config-if)#ip add 192.168.10.1 255.255.255.252

R2(config-if)#no shut

R2(config-if)#int s1/2

R2(config-if)#ip add 172.16.1.4 255.255.255.252

R2(config-if)#no shut

2、R3配置成外部网络,例如Internet。在R3配置一条默认路由使EIGRP的内部网络通过这条默认路由到达外部网络。

R3(config)#ip route 0.0.0.0 0.0.0.0 192.168.10.1

3、R1R2R4上配置EIGRP协议,以建立内部网络。

R1

R1(config)#router eigrp 80

R1(config-router)#network 172.16.0.0

R1(config-router)#exit

R2

R2(config)#router eigrp 80

R2(config-router)#network 192.168.0.0

R2(config-router)#exit

R4

R4(config)#router eigrp 80

R4(config-router)#network 172.16.0.0

R4(config-router)#exit

4、R2查看路由表验证EIGRP邻居是否顺利建立。

R2#sh ip eigrp nei

IP-EIGRP neighbors for process 80

H   Address                 Interface       Hold Uptime   SRTT   RTO  Q  Seq

                                            (sec)         (ms)       Cnt Num

1   172.16.2.1              Se1/2             13 00:00:38 1924  5000  0  2

0   172.16.1.1              Se1/0             13 00:00:39  516  3096  0  2

   可以看到R2已经顺利地跟R1R4建立了邻居关系。

5、  R2作为单肩路由,需建立一条默认路由指向R3

R2(config)#ip route 0.0.0.0 0.0.0.0 192.168.10.2

配置完后,使用ping命令从R2ping R3验证下是否生效:

R2#ping 192.168.0.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/18/36 ms

R2#ping 192.168.1.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/10/24 ms

6、  这样,R2可以访问外部网络。然而同样位于内部网络的R1R4是否也可以访问外部网络呢?

首先看下R1的路由表

R1#sh 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

 

     172.16.0.0/30 is subnetted, 2 subnets

C       172.16.1.0 is directly connected, Serial1/1

D       172.16.2.0 [90/2681856] via 172.16.1.2, 00:06:05, Serial1/1

     可以看到,并没有到达外部网络192.168.0.0的路由。再用ping命令尝试一下

R1#ping 192.168.0.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:

.....

Success rate is 0 percent (0/5)

显然是不能通。在R4上面也是一样的结果。究竟该怎么配置才可以上让R1R4 访问外部网络呢?

7、  有两种方法可以让R1R4 访问外部网络。第一种方法是在R1R4上分别配置一条默认路由指向R2

R1

R1(config)#ip route 0.0.0.0 0.0.0.0 172.16.1.2

R4

R4(config)#ip route 0.0.0.0 0.0.0.0 172.16.2.2

现在再来看下R4的路由表

R4#sh ip route

*Sep 29 22:41:35.391: %SYS-5-CONFIG_I: Configured from console by console

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.2.2 to network 0.0.0.0

 

     172.16.0.0/30 is subnetted, 2 subnets

D       172.16.1.0 [90/2681856] via 172.16.2.2, 00:15:38, Serial1/1

C       172.16.2.0 is directly connected, Serial1/1

S*   0.0.0.0/0 [1/0] via 172.16.2.2

可以看到已经产生了一条指向R2接口的默认路由了。再使用ping命令验证:

R4#ping 192.168.0.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/19/36 ms

果真成功了。从上面的配置,可以总结得出要解决外部网络无法访问的问题就需要给内部路由器配置默认路由指向出口路由器R2。但试想一下,如果内部路由器数量非常多的情况下,岂不是要一个个路由器地去配置一条默认路由?明显这样是很不现实的。下面介绍第二种方法。

8、  第二种方法比较简便,就是在R2上配置一条默认网络命令,自动向内部网络宣告默认路由。注意使用第二种方法前记得先将用命令no ip route 0.0.0.0 0.0.0.0 172.16.1.2将先前配置在R1R4上的默认路由删除掉。

 

R2(config)#router eigrp 80

R2(config-router)#network 192.168.10.0

R2(config-router)#exit

R2(config)#ip default-network 192.168.10.0

R1上再查看路由表

R1# sh 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 192.168.10.0

 

D*   192.168.10.0/24 [90/2681856] via 172.16.1.2, 00:02:55, Serial1/1

     172.16.0.0/30 is subnetted, 2 subnets

C       172.16.1.0 is directly connected, Serial1/1

D       172.16.2.0 [90/2681856] via 172.16.1.2, 00:45:18, Serial1/1

可以看到R1上已经学习到了R2 的默认路由。再用ping命令验证

R1#ping 192.168.1.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 4/26/52 ms

对比这两种方法,可以明显看得第二种方法在单肩路由器使用ip default-network命令可以有效节省内部网络配置任务。不过需要注意的是ip default-network其指出默认网络,建议采用主类网络。因为ip default-network命令是一个有类的命令(classfull,如果宣告的网络不是主类网,将不会被标记成*号。如果使用无类网络,则可能会出现无法解释的问题。