在路由器上代理ARP配置

  • 格式:doc
  • 大小:39.50 KB
  • 文档页数:3

1 1. 1proxy arp

代理ARP避免在每一台主机上配置路由表(网关)。

代理arp被路由器作为向主机表明自身可用的一种手段,在这个实验里面,我们将R1和R3仿真成终端主机,当R1需要R3发送报文时(目的为3.3.3.3),在没有配置默认网关的情况下,R1可以向12.1.1.2发送一个ARP请求,本地路由器R2收到这个请求后,并且知道如何到达网络3.3.3.0因此路由器将回复以上请求。其中把自己的数据链路标示作为ARP回复报文中的硬件地址。事实上,路由器欺骗了本地的主机R1,让他认为路由器的接口就是3.3.3.3的接口,最终所有发向3.3.3.3的报文都被送往路由器。

以下实验R2和R3通过OSPF保持连通,而R1仿真为终端,注意R1不可配置环回口,否则默认ARP请求会发向环回口。

R3(config)#interface loopback 0

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.1 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)#interface serial1

R#(config-if)#ipaddress 23.1.1.3 255.255.255.0

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

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-if)#interface serial 1

R2(config-if)#ip address 23.1.1.2 255.255.255.0

R2(config-if)#clockrate 64000

R2(config-if)#no shut

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

R1(config)#interface ethernet 0

R1(config-if)#ip address 112.1.1.1 255.255.255.0

此时,这种情况下,R1没有R3的路由,R1根本不会去发送ARP请求来解析目的地址,通过以下配置,将R1的路由功能关闭,这个时候R1犹如一个终端主机。

R1(config-if)#no ip routing

此时查看R1的路由表

R1#show ip route

Default gateway is not set 2 Host Gateway Last Use Total Uses Interface

ICMP redirect cache is empty

R1#traceroute 3.3.3.3

Type escape sequence to abort.

Tracing the route to 3.3.3.3

1 112.1.1.2 4 msec 4 msec 4 msec

2 23.1.1.3 16 msec 20 msec *

R1能够到达R3,是因为R1关闭了路由功能后,在没有设置默认的网关的情况下,会对所有不可知的地址,发送广播ARP请求,R2的E0接口收到请求后,查看路由表是否有3.3.3.3的对用路由,如有,便用其接受到请求的接口的MAC应答ARP。我们在R1上面同时ping多个地址,验证这一点:

R1分别ping3.3.3.1 3.3.3.3 3.3.3.4

R1#show arp

Protocol Address Age (min) Hardware Addr Type Interface

Internet 3.3.3.3 4 0010.7b80.4c86 ARPA Ethernet0

Internet 3.3.3.2 0 0010.7b80.4c86 ARPA Ethernet0

Internet 3.3.3.1 0 0010.7b80.4c86 ARPA Ethernet0

Internet 3.3.3.4 0 0010.7b80.4c86 ARPA Ethernet0

Internet 112.1.1.1 - 0030.94e5.ca62 ARPA Ethernet0

Internet 112.1.1.2 4 0010.7b80.4c86 ARPA Ethernet0

可见解析出来的地址,全部和R2的e0接口MAC一致,这个实验如果采用串行接口。串行接口如封装PPP/HDLC。则看不到这个arp表的内容,因为点到点的协议,硬件地址没有差异,但proxy-arp的过程是一致的,我们尝试关闭R2的proxy-arp功能,这样R1就得不到应答了

代理ARP可能需要较大的ARP缓存,每个不在本网段的IP地址都被创建一个表项,都映射到网关的硬件地址,在使用代理ARP的主机看来,世界就像一个大的没有路由器的物理网络。

R2(config)#interface e0

R2(config-if)#no ip proxy-arp

再在R1测试,测试前先清除ARP缓冲表项:

R1#clear arp

R1#show arp

Protocol Address Age (min) Hardware Addr Type Interface

Internet 112.1.1.1 - 0030.94e5.ca62 ARPA Ethernet0

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 0 percent (0/5)

一旦proxy-arp关闭,则R2只对本地接口的IP地址arp做出应答,R1如要到达R3,则需要配置默认网关如下:

R1(config)#ip default-gateway 112.1.1.2

R1#ping 3.3.3.3

Type escape sequence to abort. 3 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 = 32/32/36 ms

R1#show arp

Protocol Address Age (min) Hardware Addr Type Interface

Internet 112.1.1.1 - 0030.94e5.ca62 ARPA Ethernet0

Internet 112.1.1.2 0 0010.7b80.4c86 ARPA Ethernet0

可见ARP表里面,不在有3.3.3.3的条目,因为R1只需要把所有未知地址数据包给默认网关112.1.1.2即可,因此R1也只解析网关的链路地址。

对于ms windows一系的操作系统,不设置网关的话,不会发ARP请求未知网络地址,如果不知道网关地址或想避免重定向,在网关支持proxy-arp的情况下,windows主机可以将网关地址设置成自己的IP。