1、ACL访问控制列表ACL访问控制列表D一个端口执行哪条ACL,这需要按照列表中的条件语句执行顺序来判断。如果一个数据包的报头跟表中某个条件判断语句相匹配,那么后面的语句就将被忽略,不再进行检查。 数据包只有在跟第一个判断条件不匹配时,它才被交给ACL中的下一个条件判断语句进行比较。如果匹配(假设为允许发送),则不管是第一条还是最后一条语句,数据都会立即发送到目的接口。如果所有的ACL判断语句都检测完毕,仍没有匹配的语句出口,则该数据包将视为被拒绝而被丢弃。 这里要注意,ACL不能对本路由器产生的数据包进行控制。 ACL的分类 目前有两种主要的ACL:标准ACL和扩展ACL。 这两种ACL的区别
2、是,标准ACL只检查数据包的源地址; 扩展ACL既检查数据包的源地址,也检查数据包的目的地址,同时还可以检查数据包的特定协议类型、端口号等。 网络管理员可以使用标准ACL阻止来自某一网络的所有通信流量,或者允许来自某一特定网络的所有通信流量,或者拒绝某一协议簇(比如IP)的所有通信流量。 扩展ACL比标准ACL提供了更广泛的控制范围。例如,网络管理员如果希望做到“允许外来的Web通信流量通过,拒绝外来的FTP和Telnet等通信流量”,那么,他可以使用扩展ACL来达到目的,标准ACL不能控制这么精确。 在路由器配置中,标准ACL和扩展ACL的区别是由ACL的表号来体现的,上表指出了每种协议所允
3、许的合法表号的取值范围。 正确放置ACL ACL通过过滤数据包并且丢弃不希望抵达目的地的数据包来控制通信流量。然而,网络能否有效地减少不必要的通信流量,这还要取决于网络管理员把ACL放置在哪个地方。 假设在图3所示的一个运行TCP/IP协议的网络环境中,网络只想拒绝从RouterA的T0接口连接的网络到RouterD的E1接口连接的网络的访问,即禁止从网络1到网络2的访问。 根据减少不必要通信流量的通行准则,网管员应该尽可能地把ACL放置在靠近被拒绝的通信流量的来源处,即RouterA上。如果网管员使用标准ACL来进行网络流量限制,因为标准ACL只能检查源IP地址,所以实际执行情况为:凡是检查
4、到源IP地址和网络1匹配的数据包将会被丢掉,即网络1到网络2、网络3和网络4的访问都将被禁止。由此可见,这个ACL控制方法不能达到网管员的目的。同理,将ACL放在RouterB和RouterC上也存在同样的问题。只有将ACL放在连接目标网络的RouterD上(E0接口),网络才能准确实现网管员的目标。由此可以得出一个结论: 标准ACL要尽量靠近目的端。 网管员如果使用扩展ACL来进行上述控制,则完全可以把ACL放在RouterA上,因为扩展ACL能控制源地址(网络1),也能控制目的地址(网络2),这样从网络1到网络2访问的数据包在RouterA上就被丢弃,不会传到RouterB、RouterC
5、和RouterD上,从而减少不必要的网络流量。因此,我们可以得出另一个结论:扩展ACL要尽量靠近源端。 ACL的配置 ACL的配置分为两个步骤: 第一步:在全局配置模式下,使用下列命令创建ACL: Router (config)# access-list access-list-number permit | deny test-conditions 其中,access-list-number为ACL的表号。人们使用较频繁的表号是标准的IP ACL(199)和扩展的IP ACL(100199)。 在路由器中,如果使用ACL的表号进行配置,则列表不能插入或删除行。如果列表要插入或删除一行,必须先
6、去掉所有ACL,然后重新配置。当ACL中条数很多时,这种改变非常烦琐。一个比较有效的解决办法是:在远程主机上启用一个TFTP服务器,先把路由器配置文件下载到本地,利用文本编辑器修改ACL表,然后将修改好的配置文件通过TFTP传回路由器。 这里需要特别注意的是,在ACL的配置中,如果删掉一条表项,其结果是删掉全部ACL,所以在配置时一定要小心。 在Cisco IOS11.2以后的版本中,网络可以使用名字命名的ACL表。这种方式可以删除某一行ACL,但是仍不能插入一行或重新排序。所以,笔者仍然建议使用TFTP服务器进行配置修改。 第二步:在接口配置模式下,使用access-group命令ACL应用
7、到某一接口上: Router (config-if)# protocol access-group access-list-number in | out 其中,in和out参数可以控制接口中不同方向的数据包,如果不配置该参数,缺省为out。 ACL在一个接口可以进行双向控制,即配置两条命令,一条为in,一条为out,两条命令执行的ACL表号可以相同,也可以不同。但是,在一个接口的一个方向上,只能有一个ACL控制。 值得注意的是,在进行ACL配置时,网管员一定要先在全局状态配置ACL表,再在具体接口上进行配置,否则会造成网络的安全隐患。路由器是工作在OSI参考模型第三层网络层的数据包转发设备。
8、路由器通过转发数据包来实现网络互连。虽然路由器可以支持多种协议(如TCP/IP、 IPX/SPX、AppleTalk等协议),但是在我国绝大多数路由器运行TCP/IP协议。路由器通常连接两个或多个由IP子网或点到点协议标识的逻辑端口,至少拥有1个物理端口。路由器根据收到数据包中的网络层地址以及路由器内部维护的路由表决定输出端口以及下一跳地址,并且重写链路层数据包头实现转发数据包。路由器通过动态维护路由表来反映当前的网络拓扑,并通过与网络上其他路由器交换路由和链路信息来维护路由表。路由器设备厂商最有名的是Cisco公司,以下是Cisco路由器配置的常用命令汇总,希望对正在学习和应用思科路由器的你
9、有帮助。启动接口,分配IP地址:routerrouter enablerouter#router# configure terminalrouter(config)#router(config)# interface Type Portrouter(config-if)# no shutdownrouter(config-if)# ip address IP-Address Subnet-Maskrouter(config-if)# z配置RIP路由协议:30秒更新一次router(config)# router riprouter(config-if)# network Network-Nu
10、mber router(config-if)# z配置IGRP路由协议:90秒更新一次router(config)# router igrp AS-Number router(config -if)# network Network-Number router(config-if)# z配置Novell IPX路由协议:Novell RIP 60秒更新一次router(config)# ipx routing node addressrouter(config)# ipx maximum-paths Paths router(config)# interface Type Portrouter
11、(config-if)# ipx network Network-Number encapsulation encapsulation-type secondary router(config-if)# z配置DDR:router(config)# dialer-list Group-Number protocol Protocol-Type permitlist ACL-Numberrouter(config)# interface bri 0router(config-if)# dialer-group Group-Numberrouter(config-if)# dialer map P
12、rotocol-Type Next-Hop-Address name Hostname Telphone-Numberrouter(config-if)# z配置ISDN:router(config)# isdn swith-type Swith-Type router(config-if)# z 配置Frame Relay: router(config-if)# encapsulation frame-relay cisco IEtf router(config-if)# frame-relay lmi-type ansi cisco q933a router(config-if)# ban
13、dwidth kilobitsrouter(config-if)# frame-relay invers-arp Protocol dlci router(config-if)# z配置标准ACL:router(config)# access-list Access-List-Number permit deny source source-mask router(config)# interface Type Portrouter(config-if)# ip access-group Access-List-Number in out router(config-if)# z配置扩展ACL
14、:router(config)# access-list Access-List-Number permit deny Protocol Protocol-Number source source-wildcard Source-Port destination destination-wildcard Destination-Port established router(config)# interface Type Portrouter(config-if)# ip access-group Access-List-Number in out router(config-if)# z配置
15、命名ACL:router(config)# ip access-list standard extended ACL-Namerouter(config std- ext- nacl)# permit deny IP-Access-List-Test-Conditions router(config std- ext- nacl)# no permit deny IP-Access-List-Test-Conditions router(config std- ext- nacl)# zrouter(config)# interface Type Portrouter(config-if)#
16、ip access-group ACL-Name 1199 in out router(config-if)# z配置DCE时钟:router# show controllers Type Port router(confin-if)# clock rate 64000 router(config-if)# z配置PPP协议:router(config)# username Name passWord Set-Password-Here router(config)# interface Type Portrouter(config-if)# encapsulation ppp router(
17、config-if)# ppp outhentication chap chap pap pap chap pap router(config-if)# ppp pap sent-username Name password Password router(config-if)# zPAP单向认证配置实例:验证方:router-server(config)# username ClIEnt passWord 12345 router-server(config)# interface serial 0router-server(config-if)# encapsulation ppprout
18、er-server(config-if)# ppp authentication pap router-server(config-if)# z被验证方:router-client(config-if)# encapsulation ppprouter-client(config-if)# ppp pap sent-username Client password 12345 router-client(config-if)# zPAP双向认证配置实例:路由器 A:routerA(config)# username B password 12345routerA(config)# interf
19、ace serial 0routerA(config-if)# encapsulation ppprouterA(config-if)# ppp authentication paprouterA(config-if)# ppp pap sent-username A password 54321routerA(config-if)# z路由器 B:routerB(config)# username A password 54321routerB(config)# interface serial 1routerB(config-if)# encapsulation ppprouterB(co
20、nfig-if)# ppp authentication paprouterB(config-if)# ppp pap sent-username B password 12345routerB(config-if)# zCHAP单向认证配置实例:验证方:router-server(config)# username router-client password 12345router-server(config)# interface serial 0router-server(config-if)# encapsulation ppprouter-server(config-if)# pp
21、p authentication chaprouter-server(config-if)# z被验证方:router-client(config-if)# encapsulation ppprouter-client(config-if)# ppp authentication chaprouter-client(config-if)# ppp chap hostname router-clientrouter-client(config-if)# ppp chap password 12345router-client(config-if)# zCHAP双向认证配置实例: 路由器 A:ro
22、uterA(config)# username routerB passWord 12345routerA(config)# interface serial 0routerA(config-if)# encapsulation ppprouterA(config-if)# ppp authentication chaprouterA(config-if)# ppp chap hostname routerArouterA(config-if)# ppp chap password 54321routerA(config-if)# z路由器 B:routerB(config)# usernam
23、e routerA password 54321routerB(config)# interface serial 1routerB(config-if)# encapsulation ppprouterB(config-if)# ppp authentication chaprouterB(config-if)# ppp chap hostname routerBrouterB(config-if)# ppp chap password 12345routerB(config-if)# zTelnet使用:routerA# terminal monitor routerA# telnet I
24、P-Address Router-Name routerB# exit logout routerB# 再按 routerA# show sessions routerA# Connect-Number routerA# disconnect IP-Address Router-Name routerA# show user routerA# clear line 0 1 2 3 4 禁止任何Telnet到本机:router(config)# line vty 0 4router(config-line)# access-class ACL-Numberrouter(config)# z设置主
25、机名:router(config)# hostname Set-Hostnamerouter(config)# zrouter(config)# z设置用户模式密码:router(config)# line console 0router(config-line)# loginrouter(config-line)# password Set-Passwordrouter(config-line)# z设置Telnet密码:router(config)# line vty 0 4router(config-line)# loginrouter(config-line)# passWord Se
26、t-Passwordrouter(config-line)# z设置特权模式密码:router(config)# enable password Set-Password router(config)# enable secret Set-Password router(config)# z给所有密码加密:router(config)# service password-ancryption Set-Password-Hererouter(config)# no service password-ancryption router(config)# z设置登录Banner:router(con
27、fig)# banner motd 分隔符 Set-Banner-InFORMation-Here 分隔符 设置接口的描述信息:router(config-if)# description Set-Port-InFORMation-Hererouter(config)# zCDP的控制:router(config-if)# cdp enable router(config-if)# no cdp enable router(config)# cdp run router(config)# no cdp run Ping的使用:router# ping IP-Addressrouter# ping