分享

默认路由配置

 舟客 2012-02-11

默认路由:当一台路由器上配置了默认路由,若它在数据转发的时候找不到去往目的网络的路由,他会去匹配默认路 由,把数据报文丢给默认路由配置的下一跳路由器。在我们维护工作中,如果默认路由配置的得当,会给我们减轻了很大的工作量;另一方面配置默认路由也可以缩 减了路由表项。默认路由虽然好,但也不是万能的,在网络数据规划的时候,一定要用的得当。

配置方法:默认路由的配置cisco的设备支持三种模式

1、ip route 0.0.0.0 0.0.0.0 [下一条地址] :这种方式用的最多,通常给路由器配置默认网关就采用这种方式。

2、ip default-gateway  [下一条地址] : 这种方式需要关闭路由器的路由功能(no ip routing),然后才能配置。

3、ip default-network [下一条网络号] :与上面两种方式不同的是,通过这种方式配置的默认网关,会自动引入其它的路由协议。

配置实验:

 实验拓扑如下:

实验步骤:

在R1上分别采用三种方式配置默认网关,然后测试,在R1上ping R2 2.2.2.2,如果能通说明配置正确。

1、ip route 0.0.0.0 0.0.0.0 [下一条地址] :

R1>enable
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#interface loopback 0
R1(config-if)#ip add 1.1.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#interface fastEthernet 0/0
R1(config-if)#ip add 192.168.1.1 255.255.255.0
R1(config-if)#no shutdown
00:01:39: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
00:01:40: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#exit
R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.1.2
R1(config)#exit
R1#show ip route
Codes: C – connected, S – static, I – IGRP, 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, E – EGP
       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 192.168.1.2 to network 0.0.0.0

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
C    192.168.1.0/24 is directly connected, FastEthernet0/0
S*   0.0.0.0/0 [1/0] via 192.168.1.2

R1#ping 2.2.2.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/33/44 ms

2、ip default-gateway  [下一条地址] :

 

R1#conf  t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#no ip route 0.0.0.0 0.0.0.0
R1(config)#exit
R1#show ip route
Codes: C – connected, S – static, I – IGRP, 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, E – EGP
       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

 

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
C    192.168.1.0/24 is directly connected, FastEthernet0/0
R1(config)#no ip routing
R1(config)#ip default-gateway 192.168.1.2
R1(config)#end
R1#show ip route
Default gateway is 192.168.1.2

 

Host               Gateway           Last Use    Total Uses  Interface
ICMP redirect cache is empty

 

R1#ping 2.2.2.2

 

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/18/20 ms
R1#

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多