0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Packet TracerでACLを試してみた

Posted at

背景・目的

過去にPacket Tracerでいくつか試してみました。今回はACLについて試してみます。

まとめ

下記に特徴を整理します。

特徴 説明
ACLとは ルーターは、通過するパケットとACLを比較しACLの条件に一致した場合はその指定された動作に従ってパケットを処理する
ACLの種類 標準ACLと拡張ACLがある
標準ACL パケットの送信元IPアドレスをチェックする
拡張ACL 下記をチェックする
・送信元IPアドレス
・宛先IPアドレス
・プロトコル番号
・送信元ポート番号
・宛先ポート番号
ACLのルール 1行づつ記述し、複数エントリできる
ルーターは、ACLの行の上から順に評価し、該当する行があればそこで終了する
ACLの最後は、暗黙的なすべてDenyが存在する

概要

ACLとは

  • ルーターでは、通過するパケットをチェックし許可された通信だけを転送するように制御できる
  • 通信の制御には、ACL(Access Control List)が利用される
  • ルータに送られてくる通信を許可する通信と拒否する通信に分けることをパケットフィルタリングという
  • ルーターは、ACLの内容に基づいてフィルタリングを行う
  • ルーターは、通過するパケットとACLを比較しACLの条件に一致した場合はその指定された動作に従ってパケットを処理する

ACLの種類

標準ACLと拡張ACLがある

標準ACL

  • パケットの送信元IPアドレスをチェックする
  • さらに、番号付き標準ACLと名前付き標準ACLがある
  • 番号付き標準ACLは、番号で識別される
  • 名前付き標準ACLは、作成時に示す文字列を指定する

拡張ACL

  • 拡張ACLは下記をチェックします
    • 送信元IPアドレス
    • 宛先IPアドレス
    • プロトコル番号
    • 送信元ポート番号
    • 宛先ポート番号
  • 標準ACLと同様に番号付きと名前付きの拡張ACLがある

ACLのルール

  • 1行づつ記述する
  • 複数エントリできる
  • ルーターは、ACLの行の上から順に評価し、該当する行があればそこで終了する
  • ACLの最後は、暗黙的なすべてDenyが存在する
    • どれも該当しなかった場合、拒否される
  • 順番を意識する必要がある

ワイルドカードマスク

  • ACLではフィルタリングの条件をワイルドカードマスクを使用する
  • ACLでワイルドカードマスクを用いる場合、特定の送信元や宛先を指定する場合に省略形を用いることが出来る
  • 下記に例を示します
パターン ワイルドカードマスク 省略形
特定のIPのみ 192.168.100.10 0.0.0.0 host 192.168.100.10
すべてのIP 0.0.0.0 255.255.255.255 any

ACLの適用

  • ACLは作成後にルーターのインターフェイスに適用する
  • 各インターフェイスには、インバウンドとアウトバウンドでそれぞれ1つずつACLを適用できる

インバウンドに適用した場合

  • インバウンドで適用した場合、ルーターのインターフェイスにパケットが届いたときにACLによるチェックが行われる

アウトバウンドに適用した場合

  • アウトバウンドで適用した場合、ルーティングテーブルの検索などの処理が行われたあとにルーターからパケットが出ていくときにチェックが行われる

実践

前回、下記で試したVLANに対してACLを設定してみます。

標準ACLの確認

分類 ノード 設定項目 設定内容 備考
L3SW Switch0 hostname SW0
vlan No 100
vlan name vlan100
vlan ip 192.168.100.1
vlan No 200
vlan name vlan200
vlan ip 192.168.200.1
FastEthernet0/1 VLAN100に所属
FastEthernet0/2 VLAN100に所属
FastEthernet0/3 VLAN200に所属
FastEthernet0/4 VLAN200に所属
VLAN100 PC0 hostname PC0
IPv4 192.168.100.100
Subnet Mask 255.255.255.0
Default Gateway 192.168.100.1
PC1 hostname PC1
IPv4 192.168.100.101
Subnet Mask 255.255.255.0
Default Gateway 192.168.100.2
VLAN200 PC2 hostname PC2
IPv4 192.168.200.100
Subnet Mask 255.255.255.0
Default Gateway 192.168.200.1
PC3 hostname PC3
IPv4 192.168.200.101
Subnet Mask 255.255.255.0
Default Gateway 192.168.200.2

現状の設定を確認

ルーティング

  1. ルーティングが有効になっているか確認します
    SW0#show running-config | include routing
    ip routing
    SW0#
    

VLAN

  1. Vlanを確認します

    SW0#show vlan
    
    VLAN Name                             Status    Ports
    ---- -------------------------------- --------- -------------------------------
    1    default                          active    Fa0/5, Fa0/6, Fa0/7, Fa0/8
                                                    Fa0/9, Fa0/10, Fa0/11, Fa0/12
                                                    Fa0/13, Fa0/14, Fa0/15, Fa0/16
                                                    Fa0/17, Fa0/18, Fa0/19, Fa0/20
                                                    Fa0/21, Fa0/22, Fa0/23, Fa0/24
                                                    Gig0/1, Gig0/2
    100  vlan100                          active    Fa0/1, Fa0/2
    200  vlan200                          active    Fa0/3, Fa0/4
    1002 fddi-default                     active    
    1003 token-ring-default               active    
    1004 fddinet-default                  active    
    1005 trnet-default                    active    
    
    VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
    ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
    1    enet  100001     1500  -      -      -        -    -        0      0
    100  enet  100100     1500  -      -      -        -    -        0      0
    200  enet  100200     1500  -      -      -        -    -        0      0
    1002 fddi  101002     1500  -      -      -        -    -        0      0   
    1003 tr    101003     1500  -      -      -        -    -        0      0   
    1004 fdnet 101004     1500  -      -      -        ieee -        0      0   
    1005 trnet 101005     1500  -      -      -        ibm  -        0      0   
    
    VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
    ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
    
    Remote SPAN VLANs
    ------------------------------------------------------------------------------
    
    Primary Secondary Type              Ports
    ------- --------- ----------------- ------------------------------------------
    SW0#
    
    
  2. VLAN100を確認します

    SW0#show ip interface Vlan100
    Vlan100 is up, line protocol is up
      Internet address is 192.168.100.1/24
      Broadcast address is 255.255.255.255 
      Address determined by setup command 
      MTU is 1500 bytes 
      Helper address is not set
      Directed broadcast forwarding is disabled 
      Outgoing access list is not set 
      Inbound  access list is not set 
      Proxy ARP is enabled
      Local Proxy ARP is disabled 
      Security level is default 
      Split horizon is enabled 
      ICMP redirects are always sent 
      ICMP unreachables are always sent 
      ICMP mask replies are never sent 
      IP fast switching is disabled 
      IP fast switching on the same interface is disabled 
      IP Null turbo vector 
      IP multicast fast switching is disabled 
      IP multicast distributed fast switching is disabled 
      IP route-cache flags are None 
      Router Discovery is disabled 
      IP output packet accounting is disabled 
      IP access violation accounting is disabled 
      TCP/IP header compression is disabled 
      RTP/IP header compression is disabled 
      Probe proxy name replies are disabled 
      Policy routing is disabled 
      Network address translation is disable 
      WCCP Redirect outbound is disabled 
      WCCP Redirect inbound is disabled 
      WCCP Redirect exclude is disabled 
      BGP Policy Mapping is disabled 
    
    SW0#
    
  3. VLAN200を確認します

    SW0#show ip interface Vlan200
    Vlan200 is up, line protocol is up
      Internet address is 192.168.200.1/24
      Broadcast address is 255.255.255.255 
      Address determined by setup command 
      MTU is 1500 bytes 
      Helper address is not set
      Directed broadcast forwarding is disabled 
      Outgoing access list is not set 
      Inbound  access list is not set 
      Proxy ARP is enabled
      Local Proxy ARP is disabled 
      Security level is default 
      Split horizon is enabled 
      ICMP redirects are always sent 
      ICMP unreachables are always sent 
      ICMP mask replies are never sent 
      IP fast switching is disabled 
      IP fast switching on the same interface is disabled 
      IP Null turbo vector 
      IP multicast fast switching is disabled 
      IP multicast distributed fast switching is disabled 
      IP route-cache flags are None 
      Router Discovery is disabled 
      IP output packet accounting is disabled 
      IP access violation accounting is disabled 
      TCP/IP header compression is disabled 
      RTP/IP header compression is disabled 
      Probe proxy name replies are disabled 
      Policy routing is disabled 
      Network address translation is disable 
      WCCP Redirect outbound is disabled 
      WCCP Redirect inbound is disabled 
      WCCP Redirect exclude is disabled 
      BGP Policy Mapping is disabled 
    
    SW0#
    
    

インターフェイス

  1. インターフェイスを確認します。VLANにIPが設定してあります
    SW0#show ip interface brief
    Interface              IP-Address      OK? Method Status                Protocol 
    FastEthernet0/1        unassigned      YES unset  up                    up 
    FastEthernet0/2        unassigned      YES unset  up                    up 
    FastEthernet0/3        unassigned      YES unset  up                    up 
    FastEthernet0/4        unassigned      YES unset  up                    up 
    FastEthernet0/5        unassigned      YES unset  down                  down 
    FastEthernet0/6        unassigned      YES unset  down                  down 
    FastEthernet0/7        unassigned      YES unset  down                  down 
    FastEthernet0/8        unassigned      YES unset  down                  down 
    FastEthernet0/9        unassigned      YES unset  down                  down 
    FastEthernet0/10       unassigned      YES unset  down                  down 
    FastEthernet0/11       unassigned      YES unset  down                  down 
    FastEthernet0/12       unassigned      YES unset  down                  down 
    FastEthernet0/13       unassigned      YES unset  down                  down 
    FastEthernet0/14       unassigned      YES unset  down                  down 
    FastEthernet0/15       unassigned      YES unset  down                  down 
    FastEthernet0/16       unassigned      YES unset  down                  down 
    FastEthernet0/17       unassigned      YES unset  down                  down 
    FastEthernet0/18       unassigned      YES unset  down                  down 
    FastEthernet0/19       unassigned      YES unset  down                  down 
    FastEthernet0/20       unassigned      YES unset  down                  down 
    FastEthernet0/21       unassigned      YES unset  down                  down 
    FastEthernet0/22       unassigned      YES unset  down                  down 
    FastEthernet0/23       unassigned      YES unset  down                  down 
    FastEthernet0/24       unassigned      YES unset  down                  down 
    GigabitEthernet0/1     unassigned      YES unset  down                  down 
    GigabitEthernet0/2     unassigned      YES unset  down                  down 
    Vlan1                  unassigned      YES unset  administratively down down 
    Vlan100                192.168.100.1   YES manual up                    up 
    Vlan200                192.168.200.1   YES manual up                    up
    SW0#
    

VLAN100→VLAN200

  1. PC0→PC2へ疎通します。成功します
    C:\>ping 192.168.200.100
    
    Pinging 192.168.200.100 with 32 bytes of data:
    
    Reply from 192.168.200.100: bytes=32 time<1ms TTL=127
    Reply from 192.168.200.100: bytes=32 time<1ms TTL=127
    Reply from 192.168.200.100: bytes=32 time<1ms TTL=127
    Reply from 192.168.200.100: bytes=32 time<1ms TTL=127
    
    Ping statistics for 192.168.200.100:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
    

VLAN200→VLAN100

  1. PC2→PCへ疎通します。成功します
    C:\>ping 192.168.100.100
    
    Pinging 192.168.100.100 with 32 bytes of data:
    
    Reply from 192.168.100.100: bytes=32 time<1ms TTL=127
    Reply from 192.168.100.100: bytes=32 time<1ms TTL=127
    Reply from 192.168.100.100: bytes=32 time<1ms TTL=127
    Reply from 192.168.100.100: bytes=32 time<1ms TTL=127
    
    Ping statistics for 192.168.100.100:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
    
    C:\>
    

標準ACLの設定

標準ACLの作成

  1. PC0(192.168.100.100)からの通信を拒否し、PC1(Any)からは許可

    SW0#configure terminal 
    Enter configuration commands, one per line.  End with CNTL/Z.
    SW0(config)#access-list 10 deny 192.168.100.100
    SW0(config)#access-list 10 permit any
    SW0(config)#
    
  2. VLAN100へ作成したaccess-gruoup(10)のINに適用します

    SW0#configure terminal 
    Enter configuration commands, one per line.  End with CNTL/Z.
    SW0(config)#interface vlan 100
    SW0(config-if)#ip access-group 10 in
    SW0(config-if)#exit
    
  3. access-listを確認します

    SW0#show access-lists
    Standard IP access list 10
        10 deny host 192.168.100.100
        20 permit any
    
    SW0#
    
  4. インターフェイスに適用されました

    SW0#show running-config | section interface Vlan100
    interface Vlan100
     mac-address XXX.XXX.XXX
     ip address 192.168.100.1 255.255.255.0
     ip access-group 10 in
    SW0#    
    

ACL後の疎通

VLAN100→VLAN200

PC0→PC2
  1. PC0→PC2へ疎通します。失敗しました
    C:\>ping 192.168.200.100
    
    Pinging 192.168.200.100 with 32 bytes of data:
    
    Reply from 192.168.100.1: Destination host unreachable.
    Reply from 192.168.100.1: Destination host unreachable.
    Reply from 192.168.100.1: Destination host unreachable.
    Reply from 192.168.100.1: Destination host unreachable.
    
    Ping statistics for 192.168.200.100:
        Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
    
    C:\>ping 192.168.200.101
    
    Pinging 192.168.200.101 with 32 bytes of data:
    
    Reply from 192.168.100.1: Destination host unreachable.
    Reply from 192.168.100.1: Destination host unreachable.
    Reply from 192.168.100.1: Destination host unreachable.
    Reply from 192.168.100.1: Destination host unreachable.
    
    Ping statistics for 192.168.200.101:
        Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
    
    C:\>
    
  2. Denyで16件マッチしました
    SW0#show access-lists 
    Standard IP access list 10
        10 deny host 192.168.100.100 (16 match(es))
        20 permit any (9 match(es))
    
    SW0#
    
PC1→PC2
  1. 疎通します。成功しました
    C:\>ping 192.168.200.101
    
    Pinging 192.168.200.101 with 32 bytes of data:
    
    Reply from 192.168.200.101: bytes=32 time<1ms TTL=127
    Reply from 192.168.200.101: bytes=32 time<1ms TTL=127
    Reply from 192.168.200.101: bytes=32 time<1ms TTL=127
    Reply from 192.168.200.101: bytes=32 time<1ms TTL=127
    
    Ping statistics for 192.168.200.101:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
    
    C:\>
    

VLAN200→VLAN100

PC2→PC0
  1. 疎通します。失敗しました。ICMPの戻りでエラーになるので想定通りです
    C:\>ping 192.168.100.100
    
    Pinging 192.168.100.100 with 32 bytes of data:
    
    Request timed out.
    Request timed out.
    Request timed out.
    Request timed out.
    
    Ping statistics for 192.168.100.100:
        Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
    
    C:\>
    
PC2→PC1
  1. 疎通します。成功しました
    C:\>ping 192.168.100.101
    
    Pinging 192.168.100.101 with 32 bytes of data:
    
    Reply from 192.168.100.101: bytes=32 time<1ms TTL=127
    Reply from 192.168.100.101: bytes=32 time<1ms TTL=127
    Reply from 192.168.100.101: bytes=32 time<1ms TTL=127
    Reply from 192.168.100.101: bytes=32 time<1ms TTL=127
    
    Ping statistics for 192.168.100.101:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
    
    C:\>
    

拡張ACLの確認

分類 ノード 設定項目 設定内容 備考
L3SW Switch0 hostname SW0
vlan No 100
vlan name vlan100
vlan ip 192.168.100.1
vlan No 200
vlan name vlan200
vlan ip 192.168.200.1
FastEthernet0/1 VLAN100に所属
FastEthernet0/2 VLAN100に所属
FastEthernet0/3 VLAN200に所属
FastEthernet0/4 VLAN200に所属
VLAN100 PC0 hostname PC0
IPv4 192.168.100.100
Subnet Mask 255.255.255.0
Default Gateway 192.168.100.1
PC1 hostname PC1
IPv4 192.168.100.101
Subnet Mask 255.255.255.0
Default Gateway 192.168.100.2
VLAN200 PC2 hostname PC2
IPv4 192.168.200.100
Subnet Mask 255.255.255.0
Default Gateway 192.168.200.1
PC3 hostname PC3
IPv4 192.168.200.101
Subnet Mask 255.255.255.0
Default Gateway 192.168.200.2

現状の設定を確認

  1. 上記の標準ACLを解除します

    SW0(config)#interface Vlan100
    SW0(config-if)#no ip access-group 10 in
    SW0(config-if)#no shutdown
    SW0(config-if)#exit
    SW0(config)#    
    
    SW0(config)#no access-list 10
    
    
  2. 確認します

    SW0#show access-lists 
    SW0#show running-config | section interface Vlan100
    interface Vlan100
     mac-address 0040.0b24.8801
     ip address 192.168.100.1 255.255.255.0
    SW0#
    

拡張ACLを適用

PC0→PC2への通信をブロックします

  1. アクセスリストを設定します

    SW0#conf t
    Enter configuration commands, one per line.  End with CNTL/Z.
    SW0(config)#access-list 101 deny icmp 192.168.100.100 0.0.0.0 192.168.200.100 0.0.0.0
    SW0(config)#access-list 101 permit ip any any
    SW0(config)#
    SW0(config)#exit
    SW0#
    
  2. インターフェイスVLAN100に設定します

    SW0(config)#interface Vlan 100
    SW0(config-if)#ip acce
    SW0(config-if)#ip access-group 101 in
    SW0(config-if)#exit
    SW0(config)#
    
  3. access-listを確認します

    SW0#show access-lists 
    Extended IP access list 101
        10 deny icmp host 192.168.100.100 host 192.168.200.100
        20 permit ip any any
    
    SW0#
    
  4. インターフェイスへの適用状況を確認します

    SW0#show runn
    SW0#show running-config | section interface Vlan100
    interface Vlan100
     mac-address XXXXXXX
     ip address 192.168.100.1 255.255.255.0
     ip access-group 101 in
    SW0#
    

設定後の確認

PC0→PC2への通信(失敗)

  1. 失敗しました
    C:\>ping 192.168.200.100
    
    Pinging 192.168.200.100 with 32 bytes of data:
    
    Reply from 192.168.100.1: Destination host unreachable.
    Reply from 192.168.100.1: Destination host unreachable.
    Reply from 192.168.100.1: Destination host unreachable.
    Reply from 192.168.100.1: Destination host unreachable.
    
    Ping statistics for 192.168.200.100:
        Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
    
    C:\>
    

PC0→PC3への通信(失敗)

  1. 成功しました
    C:\>ping 192.168.200.101
    
    Pinging 192.168.200.101 with 32 bytes of data:
    
    Reply from 192.168.200.101: bytes=32 time<1ms TTL=127
    Reply from 192.168.200.101: bytes=32 time<1ms TTL=127
    Reply from 192.168.200.101: bytes=32 time<1ms TTL=127
    Reply from 192.168.200.101: bytes=32 time<1ms TTL=127
    
    Ping statistics for 192.168.200.101:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 0ms, Average = 0ms
    
    C:\>
    

PC2→PC0への通信(成功)

  1. 成功しました。拡張ACLで方向を指定しているので

    C:\>ping 192.168.100.100
    
    Pinging 192.168.100.100 with 32 bytes of data:
    
    Reply from 192.168.100.100: bytes=32 time=1ms TTL=128
    Reply from 192.168.100.100: bytes=32 time=16ms TTL=128
    Reply from 192.168.100.100: bytes=32 time=21ms TTL=128
    Reply from 192.168.100.100: bytes=32 time<1ms TTL=128
    
    Ping statistics for 192.168.100.100:
        Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    Approximate round trip times in milli-seconds:
        Minimum = 0ms, Maximum = 21ms, Average = 9ms
    
    C:\>
    

考察

今回、ACLの特徴、標準ACLと拡張ACLの違いを学び、試してみました。次回はNATなどをまなんでm

参考

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?