Chinaunix首页 | 论坛 | 博客
  • 博客访问: 728880
  • 博文数量: 256
  • 博客积分: 3502
  • 博客等级: 中校
  • 技术积分: 3988
  • 用 户 组: 普通用户
  • 注册时间: 2012-04-17 21:13
文章分类

全部博文(256)

文章存档

2014年(11)

2013年(134)

2012年(111)

我的朋友

分类:

2012-07-11 15:10:22

1.2   IP重定向

当数据链路上连接多个器时,如AB2个路由器,假如主机终端X设置的缺省网关为A,而实际目的地址需通过B才能到达,路由器A不仅要向路由器B转发报文,而且还要向主机发送ICMP重定向信息,通知他如果继续想特定的目的发送报文,那么请接将报文发送给路由器B,以下实验R1仿真为终端X,R2R3即为路由器AB

R1和上一个实验一样的。

R2

R2(config)#clock timezone cet 1

R2(config)#ip subnet-zero

R2(config)#interface loopback 0

R2(config-if)#ip address 2.2.2.2 255.255.255.0

R2(config-if)#ip ospf network point-to-point

R2(config)#interface ethernet 0

R2(config-if)#ip address 112.1.1.2 255.255.255.0

R2(config-if)#router ospf 10

R2(config-router)#router-id 2.2.2.2

R2(config-router)#network 0.0.0.0 255.255.255.255 area 0

R3

R3(config)#interface ethernet 0

R3(config-if)#ip address 112.1.1.3 255.255.255.0

R3(config)#interface loopback 0

R3(config-if)#ip address 3.3.3.1 255.255.255.0 secondary

R3(config-if)#ip address 3.3.3.3 255.255.255.0 secondary

R3(config-if)#ip address 3.3.3.2 255.255.255.0 secondary

R3(config-if)#ip address 3.3.3.4 255.255.255.0 secondary

R3(config-if)#ip address 3.3.3.3 255.255.255.0

R3(config-if)#ip ospf network point-to-point

R3(config-if)#router ospf 10

R3(config-router)#router-id 3.3.3.3

R3(config-router)#network 0.0.0.0 255.255.255.255 area 0

R1已经关闭了路由功能,所有已开始时看不到任何路由的只有默认网关:

R1#show ip route

Default gateway is 112.1.1.2

 

Host               Gateway           Last Use    Total Uses Interface

ICMP redirect cache is empty           

在这种情况下,R1如要访问R3,默认情况下会先到R2,因为R2/R3都在同一个网络内,因此R2收到R1的目的为3.3.3.3的数据报文后,查看路由表,发现下一跳就是接收该数据报文的接口E0,等于接收和发送都是同一个接口,因此,R2便通知R1,下次往3.3.3.3直接发给R3即可。

R1#ping 3.3.3.3

 

Type escape sequence to abort.

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

!!!!!

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

R1#show ip route

Default gateway is 112.1.1.2

 

Host               Gateway           Last Use    Total Uses Interface

3.3.3.3            112.1.1.3             0:00             8 Ethernet0

这个重定向是基于主机地址的,即针对每一个主机地址,都会单独做重定向,而不是一个网段,因为在pingICMP报文里,目的地址并没有携带掩码信息,让R1 ping R3的环回口德各个地址之后:

R1#show ip route

Default gateway is 112.1.1.2

 

Host               Gateway           Last Use    Total Uses Interface

3.3.3.3            112.1.1.3             0:02             8 Ethernet0

3.3.3.2            112.1.1.3             0:00             8 Ethernet0

3.3.3.1            112.1.1.3             0:00             8 Ethernet0

3.3.3.4            112.1.1.3             0:00             8 Ethernet0

注意,这个重定向信息,由路由器发出,对主机有效,如果R1启用路由功能,配置默认路由指向R2,一样会收到重定向信息,但是对于作为路由器的R1,会忽视重定向信息,仍然会将后继数据报文发给R2,可通过以下办法验证:

启用R1的路由功能:

R1(config)#ip routing

R2(config)#access-list 101 permit ip any host 3.3.3.3

R2(config)#access-list 101 permit ip any any

R2(config)#interface ethernet 0

R2(config-if)#ip access-group 101 in

R1发起ping

R1#ping 3.3.3.3

 

Type escape sequence to abort.

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

!!!!!

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

R1#ping 3.3.3.3

 

Type escape sequence to abort.

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

!!!!!

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

 

查看R2的访问列表计数:可见全部数据报文都经过了R2的以太网口在转发出去。

R2#show ip access-lists 101

Extended IP access list 101

    10 permit ip any host 3.3.3.3 (20 matches)

20 permit ip any any (132 matches)

IOS对于进入本接口之后,本路由器应答或从相同接口转发出去的数据报文,会双倍计数,即五个数据报文计数为10.

5)关闭R1的路由功能,并在此pingR3

R1#ping 3.3.3.3

 

Type escape sequence to abort.

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

!!!!!

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

查看R2的通过访问控制,截取的数据报文个数:

R2#show access-lists 101

Extended IP access list 101

    10 permit ip any host 3.3.3.3 (22 matches)

    20 permit ip any any (434 matches)

计数增长了2,实质上只截取了1个数据报文,即R2收到第一个数据报文之后,发出重定向,之后,R1便直接将目的地址为3.3.3.3的数据报文转发给R3.

7)重定向可以关闭

R2config#interface e0

R2config-if#no ip redirects

关闭重定向之后,全部数据报文通过R2再转发给R3

阅读(1640) | 评论(0) | 转发(1) |
0

上一篇:Cisco SDM 见解

下一篇:Cisco ACS dot1x 配置

给主人留下些什么吧!~~