DynagenでCCIEを目指す
standard Access List, extended Access List
最終更新:
it_certification
-
view
1. 目的
- standard ACL, extended ACLの使い方を確認します。
2. 構成
2.1. 設定概要
- OSPFによってルーティングします。
2.2. 構成図

2.3. netファイル
model = 3660 [localhost] [[3660]] image = C:\Program Files\Dynamips\images\c3660-ik9o3s-mz.124-6.T.bin ram = 128 [[ROUTER R1]] f0/0 = R2 f0/0 [[ROUTER R2]] f0/1 = R3 f0/1 [[ROUTER R3]]
2.4. 初期設定
- R1
! version 12.4 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R1 ! boot-start-marker boot-end-marker ! ! no aaa new-model ! resource policy ! memory-size iomem 5 ! ! ip cef no ip domain lookup ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Loopback0 ip address 1.1.1.1 255.255.255.255 ! interface FastEthernet0/0 ip address 192.168.12.1 255.255.255.0 duplex auto speed auto ! interface FastEthernet0/1 no ip address shutdown duplex auto speed auto ! router ospf 1 log-adjacency-changes passive-interface default no passive-interface FastEthernet0/0 network 1.1.1.1 0.0.0.0 area 0 network 192.168.12.1 0.0.0.0 area 0 ! ip http server no ip http secure-server ! ! ! no cdp run ! ! ! control-plane ! ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
- R2
! version 12.4 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R2 ! boot-start-marker boot-end-marker ! ! no aaa new-model ! resource policy ! memory-size iomem 5 ! ! ip cef no ip domain lookup ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Loopback0 ip address 2.2.2.2 255.255.255.255 ! interface FastEthernet0/0 ip address 192.168.12.2 255.255.255.0 duplex auto speed auto ! interface FastEthernet0/1 ip address 192.168.23.2 255.255.255.0 duplex auto speed auto ! router ospf 1 log-adjacency-changes passive-interface default no passive-interface FastEthernet0/0 no passive-interface FastEthernet0/1 network 2.2.2.2 0.0.0.0 area 0 network 192.168.12.2 0.0.0.0 area 0 network 192.168.23.2 0.0.0.0 area 0 ! ip http server no ip http secure-server ! ! ! no cdp run ! ! ! control-plane ! ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
- R3
! version 12.4 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption ! hostname R3 ! boot-start-marker boot-end-marker ! ! no aaa new-model ! resource policy ! memory-size iomem 5 ! ! ip cef no ip domain lookup ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! interface Loopback0 ip address 3.3.3.3 255.255.255.255 ! interface FastEthernet0/0 no ip address shutdown duplex auto speed auto ! interface FastEthernet0/1 ip address 192.168.23.3 255.255.255.0 duplex auto speed auto ! router ospf 1 log-adjacency-changes passive-interface default no passive-interface FastEthernet0/1 network 3.3.3.3 0.0.0.0 area 0 network 192.168.23.3 0.0.0.0 area 0 ! ip http server no ip http secure-server ! ! ! no cdp run ! ! ! control-plane ! ! ! ! ! ! ! ! ! line con 0 line aux 0 line vty 0 4 ! ! end
3. [検証] standard ACL
3.1. 設定投入前の確認
R1からR3への疎通を確認します。送信元IPアドレスが1.1.1.1(Lo 0)でも192.168.12.1(f 0/0)でも疎通可能である事を確認します。
R1#ping 3.3.3.3 source 1.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds: Packet sent with a source address of 1.1.1.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 20/59/128 ms R1# R1# R1#ping 3.3.3.3 source 192.168.12.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds: Packet sent with a source address of 192.168.12.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 16/42/76 ms R1#
3.2. 設定投入
R2 f0/0のin方向に対し、送信元が192.168.12.0/24であるパケットのみを許可するよう設定します。
R2(config)#access-list 1 permit 192.168.12.0 0.0.0.255 R2(config)# R2(config)# R2(config)#interface FastEthernet 0/0 R2(config-if)#ip access-group 1 in
3.3. 設定確認
送信元が1.1.1.1(Lo 0)であるpingが遮断されるようになった事が確認できます。
R1#ping 3.3.3.3 source 1.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds: Packet sent with a source address of 1.1.1.1 U.U.U Success rate is 0 percent (0/5) R1# R1#ping 3.3.3.3 source 192.168.12.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds: Packet sent with a source address of 192.168.12.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 28/56/108 ms R1#
3.4. 設定削除
本検証で投入した設定を削除します。
R2(config)#no access-list 1 R2(config)# R2(config)# R2(config)#interface FastEthernet 0/0 R2(config-if)#no ip access-group 1 in
4. [検証] extended ACL
4.1. 検証準備
R1, R3間でtelnet, ssh接続がせきるように設定します。設定例は以下の通りです。(R3の設定については省略)
なお、設定の意味につきましてはトップページ/動作検証 ネットワーク系/telnet and ssh managementを参照下さい。
なお、設定の意味につきましてはトップページ/動作検証 ネットワーク系/telnet and ssh managementを参照下さい。
R1(config)#enable secret cisco R1(config)#ip domain-name cisco.com R1(config)#username cisco secret sanjose R1(config)# R1(config)# R1(config)# R1(config)#crypto key generate rsa The name for the keys will be: R1.cisco.com Choose the size of the key modulus in the range of 360 to 2048 for your General Purpose Keys. Choosing a key modulus greater than 512 may take a few minutes. How many bits in the modulus [512]: % Generating 512 bit RSA keys, keys will be non-exportable...[OK] R1(config)# *Mar 1 00:23:05.843: %SSH-5-ENABLED: SSH 1.99 has been enabled R1(config)# R1(config)# R1(config)#line vty 0 4 R1(config-line)#password cisco R1(config-line)#transport input telnet ssh R1(config-line)#login local
R1, R3間で互いにtelnet, sshログインができる事を確認して下さい。
R1#telnet 192.168.23.3 Trying 192.168.23.3 ... Open User Access Verification Username: cisco Password: R3> R3> R3>exit [Connection to 192.168.23.3 closed by foreign host] R1# R1# R1#ssh -l cisco 192.168.23.3 Password: R3> R3> R3>exit [Connection to 192.168.23.3 closed by foreign host] R1#
4.2. 設定投入
standard ACLは送信元アドレスでしか制御する事ができませんが、extended ACLはポート番号や宛先アドレスでも制御する事ができます。R2のin方向に以下のACLを適用します。
R2(config)#access-list 100 permit tcp any any eq 22 R2(config)#access-list 100 permit ospf any any R2(config)#access-list 100 permit icmp any 192.168.23.0 0.0.0.255 R2(config)# R2(config)#interface FastEthernet 0/0 R2(config-if)#ip access-group 100 in
4.3. 設定確認
TCPは22番ポートのみを許可しています。R1からR3への接続について、telnetは失敗しますがsshは成功する事を確認します。
R1#telnet 192.168.23.3 Trying 192.168.23.3 ... % Destination unreachable; gateway or host down R1# R1# R1#ssh -l cisco 192.168.23.3 Password: R3>exit [Connection to 192.168.23.3 closed by foreign host] R1#
宛先アドレスは192.168.23.0/24のみを許可しています。R1からR3へのpingについて、宛先がLo 0(3.3.3.3)であるpingは失敗しますが、宛先がf0/1 (192.168.23.3)であるpingは成功します。
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: U.U.U Success rate is 0 percent (0/5) R1# R1# R1#ping 192.168.23.3 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 192.168.23.3, timeout is 2 seconds: !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 20/44/92 ms R1#
4.4. 設定削除
本検証で投入した設定を削除します。
R2(config)#no access-list 100 R2(config)# R2(config)#interface FastEthernet 0/0 R2(config-if)#ip acces R2(config-if)#no ip access-group 100 in
5. [検証] 名前つきACL
5.1. standard ACL
ACL番号ではなく名前でACLを定義する事もできます。名前つきACLでstandard ACLを定義します。設定例は以下の通りです。
R2(config)#ip access-list standard STD_IN R2(config-std-nacl)#remark standard_input <- 名前つきACLはコメントを定義する事もできます R2(config-std-nacl)#permit 192.168.12.0 0.0.0.255 R2(config-std-nacl)#exit R2(config)# R2(config)# R2(config)#interface FastEthernet 0/0 R2(config-if)#ip access-group STD_IN in
設定が反映されている事を確認します。
R1#ping 3.3.3.3 source 1.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds: Packet sent with a source address of 1.1.1.1 U.U.U Success rate is 0 percent (0/5) R1# R1#ping 3.3.3.3 source 192.168.12.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds: Packet sent with a source address of 192.168.12.1 !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 16/46/88 ms R1#
5.2. extended ACL
extended ACLも名前つきACLで定義する事ができます。設定例は以下の通りです。
R2(config)#ip access-list extended EXT_IN R2(config-ext-nacl)#remark extended_input R2(config-ext-nacl)#permit tcp any any eq 22 R2(config-ext-nacl)#permit ospf any any R2(config-ext-nacl)#permit icmp any any R2(config-ext-nacl)#exit R2(config)# R2(config)# R2(config)#interface FastEthernet 0/0 R2(config-if)#no ip access-group STD_IN in R2(config-if)#ip access-group EXT_IN in
設定が反映されている事を確認します。telnet接続はできなくなりましたが、ssh接続が可能である事を確認します。
R1#telnet 3.3.3.3 Trying 3.3.3.3 ... % Destination unreachable; gateway or host down R1# R1# R1#ssh -l cisco 3.3.3.3 Password: R3>
5.3. 設定削除
本検証で投入した設定を削除します。
R2(config)#no ip access-list standard STD_IN R2(config)#no ip access-list extended EXT_IN R2(config)# R2(config)#interface FastEthernet 0/0 R2(config-if)#no ip access-group EXT_IN in
6. [検証] 片方向の通信
6.1. 片方向通信の設定
extended ACLでは片方向のみの通信を許可する事ができます。establishを指定する事で、「確立された通信のみ許可(具体的には、TCPでSYN=1, ACK=0であるTCPを遮断)」する事ができます。
R2(config)#ip access-list extended TELNET_EST R2(config-ext-nacl)#permit tcp any any established R2(config-ext-nacl)#permit ospf any any R2(config-ext-nacl)#exit R2(config)# R2(config)# R2(config)#interface FastEthernet 0/1 R2(config-if)#ip access-group TELNET_EST in
6.2. 設定確認
R1からR3へのtelnetが成功する事を確認します。
R1#telnet 192.168.23.3 Trying 192.168.23.3 ... Open User Access Verification Username: cisco Password: R3>exit
一方、R3からR1へのtelnetは失敗する事を確認します。
R3#telnet 192.168.12.1 Trying 192.168.12.1 ... % Destination unreachable; gateway or host down R3#
7. [補足] establish と ポート番号指定
7.1. 設定投入
以下の通り、establishedとポート番号の指定を同時に行う事もできます。直観的には、telnetの片方向通信のみを許可する設定のように見えますが、うまく機能しません。
R2(config)#no ip access-list extended TELNET_EST R2(config)#ip access-list extended TELNET_EST R2(config-ext-nacl)#permit tcp any any eq telnet established R2(config-ext-nacl)#permit ospf any any R2(config-ext-nacl)#exit
7.2. 動作確認
R3からR1への通信では、仕様通りに通信を拒否している様子が読み取れます。
R3#telnet 192.168.12.1 Trying 192.168.12.1 ... % Destination unreachable; gateway or host down R3#
R1からR3への通信を試みると、何故かtime outが発生してしまいます。
R1#telnet 192.168.23.3 Trying 192.168.23.3 ... % Connection timed out; remote host not responding R1#
7.3. IOSのバージョン
上記のような不可思議な動作をしたIOSのバージョンは以下の通りです。
R2#show version Cisco IOS Software, 3600 Software (C3660-IK9O3S-M), Version 12.4(6)T, RELEASE SOFTWARE (fc1) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2006 by Cisco Systems, Inc. Compiled Thu 23-Feb-06 00:08 by ccai ROM: ROMMON Emulation Microcode ROM: 3600 Software (C3660-IK9O3S-M), Version 12.4(6)T, RELEASE SOFTWARE (fc1) R2 uptime is 29 minutes System returned to ROM by unknown reload cause - suspect boot_data[BOOT_COUNT] 0x0, BOOT_COUNT 0, BOOTDATA 19 System image file is "tftp://255.255.255.255/unknown"
8. [補足] ルーティングプロトコルの許可
8.1. ルーティングプロトコルの許可
ACLを使用する場合は、明示的にルーティングプロトコルを許可しないと経路が交換できなくなってしまいます。例えば、OSPFを許可する場合の設定は以下の通りです。
R2(config-ext-nacl)#permit ospf any any
8.2. ルーティングプロトコルの許可忘れ
以下の通り、わざとルーティングプロトコルを許可しない設定を投入します。しばらく経つとR2, R3間でneighborが切れてしまいます。
R2(config)#no ip access-list extended TELNET_EST R2(config)#ip access-list extended TELNET_EST R2(config-ext-nacl)#permit tcp any any established R2(config-ext-nacl)# *Mar 1 00:36:25.751: %OSPF-5-ADJCHG: Process 1, Nbr 3.3.3.3 on FastEthernet0/1 from FULL to DOWN, Neighbor Down: Dead timer expired R2(config-ext-nacl)# R2(config-ext-nacl)# R2(config-ext-nacl)#do show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 1.1.1.1 1 FULL/BDR 00:00:37 192.168.12.1 FastEthernet0/0 R2(config-ext-nacl)#
添付ファイル