实验目标:禁止 192.168.0.0/24 Telnet 到 PC-B,但能 Ping。
六、 实验步骤
第一步:参照实验三和上表,配置所有接口的地址,并测试连通性
Router-A#ping 192.168.1.2
PING 192.168.1.2 (192.168.1.2): 56 data bytes
!!!!!
--- 192.168.1.2 ping statistics ---
5 packets transmitted, 5 packets received, 0% packet loss
round-trip min/avg/max = 20/28/30 ms
第二步:参照实验七,配置静态路由
Router-A#sh ip route
Codes: C - connected, S - static, R - RIP, B - BGP, BC - BGP connected
D - DEIGRP, DEX - external DEIGRP, O - OSPF, OIA - OSPF inter area
ON1 - OSPF NSSA external type 1, ON2 - OSPF NSSA external type 2
OE1 - OSPF external type 1, OE2 - OSPF external type 2
DHCP - DHCP type
VRF ID: 0
C
192.168.0.0/24
is directly connected, FastEthernet0/0
C
192.168.1.0/24
is directly connected, Serial1/1
S
192.168.2.0/24
[1,0] via 192.168.1.2
Router-B#sh ip route
Codes: C - connected, S - static, R - RIP, B - BGP, BC - BGP connected
D - DEIGRP, DEX - external DEIGRP, O - OSPF, OIA - OSPF inter area
ON1 - OSPF NSSA external type 1, ON2 - OSPF NSSA external type 2
OE1 - OSPF external type 1, OE2 - OSPF external type 2
DHCP - DHCP type
VRF ID: 0
S
192.168.0.0/24
[1,0] via 192.168.1.1
C
192.168.1.0/24
is directly connected, Serial1/0
C
192.168.2.0/24
is directly connected, FastEthernet0/0
第三步:PC-A 能与 PC-B 通讯
第四步:在ROUTER-A 上设置访问列表
Router-A#conf
Router-A_config#ip access-list extended 192 !定义扩展访问列表
Router-A_config_ext_nacl#deny tcp 192.168.0.0 255.255.255.0 192.168.2.2 255.255.255.255 eq 23
!设置扩展访问列表,拒绝Telnet
Router-A_config_ext_nacl#permit icmp any any !允许Ping
Router-A_config_ext_nacl#exit
Router-A_config#int f0/0 !进入离源比较近的接口
Router-A_config_f0/0#ip access-group 192 in !绑定访问列表在IN 的方向
第五步:查看访问列表
Router-A#sh ip access-list
Extended IP access list 192
deny tcp 192.168.0.0 255.255.255.0 192.168.2.2 255.255.255.0 eq telnet
permit icmp any any
第六步:验证
七、 注意事项和排错
1. 扩展访问列表通常放在离源比较近的地方
2. 扩展访问列表可以基于源、目标 IP、协议、端口号等条件过滤
3. 命令比较长,可以通过?的方式查看帮助
4. 注意隐含的 DENY
八、 配置序列
Router-A#sh run
Building configuration...
Current configuration:
!
!version 1.3.2E
service timestamps log date
service timestamps debug date
no service password-encryption
!
hostname Router-A
!
!
!
!
!
!
interface FastEthernet0/0
ip address 192.168.0.1 255.255.255.0
no ip directed-broadcast
ip access-group 192 in
!
interface Serial1/0
no ip address
no ip directed-broadcast
physical-layer speed 64000
!
interface Serial1/1
ip address 192.168.1.1 255.255.255.0
no ip directed-broadcast
physical-layer speed 64000
!
interface Async0/0
no ip address
no ip directed-broadcast
!
!
!
ip route 192.168.2.0 255.255.255.0 192.168.1.2
!
!
ip access-list extended 192
deny tcp 192.168.0.0 255.255.255.0 192.168.2.2 255.255.255.0 eq telnet
permit icmp any any
!
!
!
九、 共同思考
1. 为什么扩展访问列表通常放在源比较近的接口?
2. 访问列表中主机还有什么表示方法?
3. 为什么访问列表中至少要有一条允许?