Cisco IOS reflexive ACLの使い方

スポンサーリンク

reflecxive ACLとは戻り方向を許可する特殊なACLです。今日ではFirewall製品などで何も意識しなくても設定できてしまう機能ですが、仕様理解のために一度は実際に手を動かしてみてるのは良い学習になります。

コマンド一覧

このシナリオで重要なコマンド一覧は以下の通りです。

Router(config)#ip access-list extended ACL_OUTBOUND
Router(config-ext-nacl)#10 permit ip any any reflect MIRROR

Router(config)#ip access-list extended ACL_INBOUND
Router(config-ext-nacl)#10 evaluate MIRROR
Router(config-ext-nacl)#99 deny ip any any

構成図

以下の環境で動作確認を行います。なお、これらルータはOSPF, BGPを動作させています。


           OUTSIDE            INSIDE

         e0/0    e0/1      e0/0    e0/1
 +--------+.1    .2+--------+.2    .3+--------+
 |   R1   +--------+   R2   +--------+   R3  | 
 +--------+        +--------+        +--------+
        192.168.12.0/24   192.168.23.0/24

 R1 Loopback0     R2 Loopback0     R3 Loopback0
 10.1.1.1/32      10.2.2.2/32      10.3.3.3/32
 [R1]
router ospf 1
 network 0.0.0.0 255.255.255.255 area 0
!
router bgp 100
 network 10.1.1.1 mask 255.255.255.255
 neighbor 192.168.12.2 remote-as 200

 [R2]
router ospf 1
 network 0.0.0.0 255.255.255.255 area 0
!
router bgp 200
 network 10.1.1.1 mask 255.255.255.255
 neighbor 192.168.12.1 remote-as 100
 neighbor 192.168.23.3 remote-as 300

 [R3]
router ospf 1
 network 0.0.0.0 255.255.255.255 area 0
!
router bgp 300
 network 10.1.1.1 mask 255.255.255.255
 neighbor 192.168.23.2 remote-as 200

設定全文は下記ファイルです。ルーティングなどの詳細設定は下記を参照ください。

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
memory-size iomem 5
!
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 10.1.1.1 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.12.1 255.255.255.0
 half-duplex
!
interface Ethernet0/1
 no ip address
 shutdown
 half-duplex
!
interface Ethernet0/2
 no ip address
 shutdown
 half-duplex
!
interface Ethernet0/3
 no ip address
 shutdown
 half-duplex
!
!
router ospf 1
 log-adjacency-changes
 network 0.0.0.0 255.255.255.255 area 0
!
router bgp 100
 no synchronization
 bgp log-neighbor-changes
 network 10.1.1.1 mask 255.255.255.255
 neighbor 192.168.12.2 remote-as 200
 no auto-summary
!
ip http server
ip forward-protocol nd
!
!
!
!
!
!
control-plane
!
!
!
!
mgcp behavior g729-variants static-pt
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
 login
!
!
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
memory-size iomem 5
!
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 10.2.2.2 255.255.255.255
!
interface Ethernet0/0
 ip address 192.168.23.2 255.255.255.0
 half-duplex
!
interface Ethernet0/1
 ip address 192.168.12.2 255.255.255.0
 half-duplex
!
interface Ethernet0/2
 no ip address
 shutdown
 half-duplex
!
interface Ethernet0/3
 no ip address
 shutdown
 half-duplex
!
!
router ospf 1
 log-adjacency-changes
 network 0.0.0.0 255.255.255.255 area 0
!
router bgp 200
 no synchronization
 bgp log-neighbor-changes
 network 10.2.2.2 mask 255.255.255.255
 neighbor 192.168.12.1 remote-as 100
 neighbor 192.168.23.3 remote-as 300
 no auto-summary
!
ip http server
ip forward-protocol nd
!
!
!
!
!
!
control-plane
!
!
!
!
mgcp behavior g729-variants static-pt
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
 login
!
!
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
memory-size iomem 5
!
!
ip cef
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
interface Loopback0
 ip address 10.3.3.3 255.255.255.255
!
interface Ethernet0/0
 no ip address
 shutdown
 half-duplex
!
interface Ethernet0/1
 ip address 192.168.23.3 255.255.255.0
 half-duplex
!
interface Ethernet0/2
 no ip address
 shutdown
 half-duplex
!
interface Ethernet0/3
 no ip address
 shutdown
 half-duplex
!
!
router ospf 1
 log-adjacency-changes
 network 0.0.0.0 255.255.255.255 area 0
!
router bgp 300
 no synchronization
 bgp log-neighbor-changes
 network 10.3.3.3 mask 255.255.255.255
 neighbor 192.168.23.2 remote-as 200
 no auto-summary
!
ip http server
ip forward-protocol nd
!
!
!
!
!
!
control-plane
!
!
!
!
mgcp behavior g729-variants static-pt
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
 login
!
!
end

基本設定

仕様説明

Reflexive ACLとは、ある方向のパケットを監査し、その戻りパケットを許可する仕組みです。例えば、宛先ポートが80で送信元ポートが52831であるHTTP通信を監査したら、その逆である宛先ポートが52831で送信元ポートが80である通信のみを許可するようになります。

以下のようにreflectキーワードを使用して監査したいパケットを定義します。前述の通り戻りのパケットを許可したいので送信元と宛先の両方の情報が必要となります。ですので、Reflexive ACLは拡張ACLに対して設定しなければなりません

Router(config)#ip access-list extended ACL_TO_R1
Router(config-ext-nacl)#10 permit ip any any reflect MIRROR

以下のようにevaluateキーワードを用いて戻りパケットを許可します。

Router(config)#ip access-list extended ACL_FROM_R1
Router(config-ext-nacl)#10 evaluate MIRROR
Router(config-ext-nacl)#99 deny ip any any

戻りパケットのみの許可であると、ルーティングプロトコルまで拒否してしまう可能性が高いので、以下のようにルーティングプロトコルを許可する設定も必要となります

Router(config)#ip access-list extended ACL_FROM_R1
Router(config-ext-nacl)#10 evaluate MIRROR
Router(config-ext-nacl)#20 permit ospf any any
Router(config-ext-nacl)#30 permit tcp any any eq bgp
Router(config-ext-nacl)#40 permit tcp any eq bgp any
Router(config-ext-nacl)#99 deny ip any any

動作確認

R2に以下設定を投入し、片方向の通信のみを許可します。

 [R2]
ip access-list extended ACL_TO_R1
 10 permit ip any any reflect MIRROR
!
ip access-list extended ACL_FROM_R1
 10 evaluate MIRROR
 20 permit ospf any any
 30 permit tcp any any eq bgp
 40 permit tcp any eq bgp any
 99 deny ip any any
!
interface Ethernet0/1
 ip access-group ACL_FROM_R1 in
 ip access-group ACL_TO_R1 out

R1からR3への通信は拒否されている事を確認します。

 [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:
U.U.U
Success rate is 0 percent (0/5)
R1#

R3からR1へ疎通可能である事を確認します。また、showコマンドで戻りパケットのみが許可されている事を確認します。

 [R3]
R3#ping 10.1.1.1 source Loopback 0

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 10.3.3.3
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/71/136 ms
R3#telnet 192.168.12.1
Trying 192.168.12.1 ... Open


User Access Verification

Password:
R1>

 [R2]
R2#show ip access-lists
Extended IP access list ACL_FROM_R1
    10 evaluate MIRROR
    20 permit ospf any any (142 matches)
    30 permit tcp any any eq bgp (13 matches)
    40 permit tcp any eq bgp any (30 matches)
    99 deny ip any any (215 matches)
Extended IP access list ACL_TO_R1
    10 permit ip any any reflect MIRROR (58 matches)
Reflexive IP access list MIRROR
     permit tcp host 192.168.12.1 eq telnet host 192.168.23.3 eq 29691 (37 matches) (time left 296)
     permit icmp host 10.1.1.1 host 10.3.3.3  (10 matches) (time left 285)
R2#

ルーティングプロトコルに関する考察

RIPは特に確認応答がありませんので、Reflexive ACLでは以下のように指定して下さい。宛先がRIPであるUDPのみを許可すれば充分です。

Router(config-ext-nacl)#10 permit udp any any eq rip

OSFP, EIGRPは確認応答がありますが、以下のような指定で問題ありません。それぞれ、protocol number 88, 89を全て許可した事になりますので、送信パケットも確認応答も両方許可されます。

Router(config-ext-nacl)#20 permit ospf any any
Router(config-ext-nacl)#30 permit eigrp any any

BGPはtcpによる通信で確認応答も許可しなければならない事に注意して下さい。Reflexive ACLでは以下のような指定が必要です。

Router(config-ext-nacl)#40 permit tcp any any eq bgp
Router(config-ext-nacl)#50 permit tcp any eq bgp any

local traffic

ACLによる対応

Reflexive ACLはlocal trafficの取り扱いがやや面倒です。例えば、R2にreflexive ACLを適用した場合は、R2から発信されるトラフィックはACLの評価対象外となります。従って、何も考慮しないとR2からの発信したトラフィックの戻りは全て拒否されてしまいます。

このような問題の解決方法として、以下のようにACLを設定する回避方法があります。以下は、R2から発信するping, traceroute, telnetを許可する例です。

 [R2]
ip access-list extended ACL_TO_R1
 10 permit ip any any reflect MIRROR
!
ip access-list extended ACL_FROM_R1
 10 evaluate MIRROR
 20 permit ospf any any
 30 permit tcp any any eq bgp
 40 permit tcp any eq bgp any
 50 permit icmp any any echo-reply
 60 permit icmp any any time-exceeded
 70 permit icmp any any port-unreachable
 80 permit tcp any eq telnet any established
 99 deny ip any any
!
interface Ethernet0/1
 ip access-group ACL_FROM_R1 in
 ip access-group ACL_TO_R1 out

R2からR1へのping, traceroute, telnetが可能である事を確認します。

 [R2]
R2#ping 10.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/35/72 ms
R2#
R2#traceroute 10.1.1.1

Type escape sequence to abort.
Tracing the route to 10.1.1.1

  1 192.168.12.1 56 msec *  124 msec
R2#
R2#
R2#telnet 10.1.1.1
Trying 10.1.1.1 ... Open


User Access Verification

Password:
R1>

route-mapによる対応

route-mapによって一度ローカルからローカルへ転送する事で、ACLを適用させる回避方法もあります。

 [R2]
ip access-list extended ACL_TO_R1
 10 permit ip any any reflect MIRROR
!
ip access-list extended ACL_FROM_R1
 10 evaluate MIRROR
 20 permit ospf any any
 30 permit tcp any any eq bgp
 40 permit tcp any eq bgp any
 99 deny ip any any
!
interface Ethernet0/1
 ip access-group ACL_FROM_R1 in
 ip access-group ACL_TO_R1 out
!
route-map RMAP_DIVERT permit 10
 set ip next-hop 10.2.2.2
!
ip local policy route-map RMAP_DIVERT

R2からR1へのping, traceroute, telnetが可能である事を確認します。

 [R2]
R2#ping 10.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/35/72 ms
R2#
タイトルとURLをコピーしました