Home  >  Article  >  Database  >  ip access-group num in

ip access-group num in

WBOY
WBOYOriginal
2016-06-07 15:44:062679browse

欢迎进入网络技术社区论坛,与200万技术人员互动交流 >>进入 一直以为自己对这个ip access-group num in | out 应用很理解,当自己做实验分析的时候分现很模糊,以下是认真的分析总结: 首先: 路由器每个接口应用ACL是针对每个数据包的过滤,三层是IP数据包,

欢迎进入网络技术社区论坛,与200万技术人员互动交流 >>进入

  一直以为自己对这个ip access-group num in | out 应用很理解,当自己做实验分析的时候分现很模糊,以下是认真的分析总结:

ip access-group num in

  首先:

  路由器每个接口应用ACL是针对每个数据包的过滤,三层是IP数据包,二层是数据帧MAC

  路由器对自己内部产生的数据不会起作用

  in就是路由器接口收到的数据,out就是路由器接口离开的数据

  站在路由器的角度,路由器只能是一个接口in,从另一个接口out(不会是从一个接口in,又从这个接口out)

  (有一个很恶心的比喻:人是router吃是in大便是out)

  如下图:一个纯LAN的网络,在R1的f0/0应该ip access-group /out

  !

  interface FastEthernet0/0

  ip address .1 255.255.255.0

  ip access-group 1 out

  duplex auto

  speed auto

  !

  access-list 1 deny .2

  access-list 1 permit .3

  如果:ACL在接口out方向不起数据包过滤的作用

  R1#ping .2

  Type escape sequence to abort.

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

  !!!!!

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

  R1#ping .3

  Type escape sequence to abort.

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

  !!!!!

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

  分析为什么:在R1路由器产生ping .2的数据包,源地址12.1.1.1,目的地址12.1.1.2但由于是路由器自己产生的数据包在接口上不起作用,所以相对f0/0的out方向不起作用。看回的ping包,从R2路由器产生回包,源地址12.1.1.2,目的地址12.1.1.1相对R1的f0/0接口是in方向,但没做in方向的数据过滤,同理ping 12.1.1.3也通

  !

  interface FastEthernet0/0

  ip address .1 255.255.255.0

  ip access-group

  duplex auto

  speed auto

  !

  相反在f0/0接口上起in方向的数据过滤结果:

  R1#

  R1#ping .1

  Type escape sequence to abort.

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

  ....

  Success rate is 0 percent (0/4)

  R1#ping .2

  Type escape sequence to abort.

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

  ...

  Success rate is 0 percent (0/3)

  R1#ping .3

  Type escape sequence to abort.

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

  !!!!!

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

  结果分析:R1路由器自己产生数据包ping .2 源地址:12.1.1.1,目的地址:12.1.1.2,相对f0/0接口数据发送出去,但是内部自己产生的数据包不起作用,所以发送成功,看回的数据包,R2产生回的数据包,源地址:12.1.1.2,目的地址:12.1.1.1到达R1的f0/0接口相对R1路由器f0/0就是为in方向这时作用ACL过滤,过滤掉源为12.1.1.2的地址,所以不成功

  相反,源地址.3满足ACL,所以ping通.

  总之,访问列表设计为过滤通过路由器的流量,但不过滤路由器产生的流量。

ip access-group num in

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn