R1、R2、R3的配置信息:
R1
r1(config)#int loopback 0
r1(config-if)#ip add 192.168.1.1 255.255.255.240
r1(config-if)#exit
r1(config)#int loopback 1
r1(config-if)#ip add 192.168.1.17 255.255.255.240
R2
r2(config)#int f0/0
r2(config-if)#ip address 192.168.12.2 255.255.255.0
r2(config-if)#no shu
r2(config-if)#int f0/1
r2(config-if)#ip address 192.168.23.1 255.255.255.0
r2(config-if)#no shu
r2(config)#access-list 100 permit tcp any any
r2(config)#exit
r2(config)#access-list 100 deny tcp host 192.168.12.1 any eq 23
r2(config)#int f0/1
r2(config-if)#ip access-group 100 out
R3
Router(config)#int f0/1
Router(config-if)#ip address 192.168.23.2 255.255.255.0
Router(config-if)#no shu
测试:
未添加拒绝telnet前
r1#ping 192.168.23.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.2, timeout is 2 seconds:
UUUUU
Success rate is 0 percent (0/5)
r1#telnet 192.168.23.2
Trying 192.168.23.2 ...Open
添加后
[Connection to 192.168.23.2 closed by foreign host]
r1#ping 192.168.23.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.2, timeout is 2 seconds:
UUUUU
Success rate is 0 percent (0/5)
r1#telnet 192.168.23.2
Trying 192.168.23.2 ...Open
[Connection to 192.168.23.2 closed by foreign host]