Cisco IOS Firewallの基本的な設定

スポンサーリンク

Cisco IOS Firewallは”ip inspect”コマンドを用いて設定する片方向の通信を許可する機能です。ここでは基本的な設定について説明します。

コマンド一覧

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

Router(config)# ip access-list extended <acl_name>
Router(config-ext-nacl)# 10 permit udp any any eq rip
Router(config-ext-nacl)# 99 deny ip any any

Router(config)# ip inspect alert-off
Router(config)# ip inspect audit-trail
Router(config)# ip inspect name <inspect_name> <protocol> [ alert { on | off }] [ audit-trail { on | off }]
Router(config)# ip inspect name <inspect_name> <protocol> [ timeout <sec> ]
Router(config)# ip inspect name <inspect_name> <protocol> [ router-traffic ]
Router(config)# ip inspect name <inspect_name> dns [ timeout <sec> ]
Router(config)# ip inspect hashtable-size [ 1024 | 2048 | 4096 | 8192 ]

Router(config)# interface <interface>
Router(config-if)# ip inspect <inspect_name> out
Router(config-if)# ip access-group <acl_name> in

構成図

以下の構成で動作確認を行います。

         e0/0    e0/1      e0/0    e0/1
 +--------+.1    .2+--------+.2  dhcp+--------+
 |   R1   +--------+   R2   +--------+   R3  | 
 +--------+        +--------+        +--------+
        192.168.12.0/24   192.168.23.0/24
   Inside           Firewall           Outside

 R1 Loopback0     R2 Loopback0     R3 Loopback0
 10.1.1.1/32      10.2.2.2/32      10.3.3.3/32
 [R1]
router rip
 version 2
 network 10.0.0.0
 network 192.168.12.0
 no auto-summary

 [R2]
router rip
 version 2
 network 10.0.0.0
 network 192.168.12.0
 network 192.168.23.0
 no auto-summary

 [R3]
router rip
 version 2
 network 10.0.0.0
 network 192.168.23.0
 no auto-summary

設定全文は下記ファイルです。詳細設定は下記を参照ください。

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
!
!
ip auth-proxy max-nodata-conns 3
ip admission max-nodata-conns 3
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
! 
!
!
!
!
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 rip
 version 2
 network 10.0.0.0
 network 192.168.12.0
 no auto-summary
!
ip http server
no ip http secure-server
!
ip forward-protocol nd
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
!
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
!
!
ip auth-proxy max-nodata-conns 3
ip admission max-nodata-conns 3
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
! 
!
!
!
!
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 rip
 version 2
 network 10.0.0.0
 network 192.168.12.0
 network 192.168.23.0
 no auto-summary
!
ip http server
no ip http secure-server
!
ip forward-protocol nd
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
!
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
!
enable password cisco
!
no aaa new-model
memory-size iomem 5
!
!
ip cef
!
!
ip auth-proxy max-nodata-conns 3
ip admission max-nodata-conns 3
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
! 
!
!
!
!
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 rip
 version 2
 network 10.0.0.0
 network 192.168.23.0
 no auto-summary
!
ip http server
no ip http secure-server
ip http path flash:
!
ip forward-protocol nd
!
!
!
!
!
control-plane
!
!
!
!
!
!
!
!
!
!
line con 0
line aux 0
line vty 0 4
 login
!
!
end

仕様説明

基本設定

基本的なポリシーとしてdeny allであるextended access-listを作成します。ただし、このaccess-listはルーティングプロトコルを拒否しないように注意して下さい。

IOS firewallはACLに対して一時的に許可するLayer4の情報を付与します。従って、standard access-listでは機能しない(extended access-listは必須である)事に注意して下さい。

設定例は以下の通りです。

Router(config)# ip access-list extended <acl_name>
Router(config-ext-nacl)# 10 permit udp any any eq rip
Router(config-ext-nacl)# 99 deny ip any any

パケットを覗き見し、戻りを許可したいプロトコルを指定します。

Router(config)# ip inspect name <inspect_name> <protocol_1>
Router(config)# ip inspect name <inspect_name> <protocol_2>
Router(config)# ip inspect name <inspect_name> <protocol_3>

上記をinterfaceに設定します。

Router(config)# interface <interface>
Router(config-if)# ip inspect <inspect_name> out
Router(config-if)# ip access-group <acl_name> in

alert audit

Cisco IOS Firewallはalert(警告メッセージ)とaudit(監査ログ)に対応しています。alertはCBACによって何らかの侵入であると判断された場合の警告メッセージです。auditはIPアドレス, ポート番号, 通信の総量などの詳細情報を全ての通信に対して出力する機能です(ログネック注意)。

デフォルトの状態ではalertは有効でauditは無効になっています。デフォルト設定を変更したい場合は、以下の設定を投入します。

Router(config)# ip inspect alert-off
Router(config)# ip inspect audit-trail

以下のコマンドで、プロトコル単位でalert, auditの有効無効を切り替える事もできます。

Router(config)# ip inspect name <inspect_name> <protocol> [ alert { on | off }] [ audit-trail { on | off }]

timeout

戻りパケットを許可する時間をチューニングする事ができます。通信が全くない状態になってから一定時間経過すると、
通信を管理するセッションテーブルから情報が削除されます。(tcpに関しては、コネクションが閉じられると(fin, fin+ack, ackの通信が終わると)セッションテーブルから情報が削除されます。)

timeout時間は、以下のコマンドでプロトコル単位の指定が可能です。

Router(config)# ip inspect name <inspect_name> <protocol> [ timeout <sec> ]

なお、通信を管理するセッションテーブルは以下のコマンドで確認する事ができます。

R2#show ip inspect sessions
Established Sessions
 Session 646E134C (10.1.1.1:8)=>(192.168.23.3:0) icmp SIS_OPEN
 Session 646E10CC (192.168.12.1:50211)=>(10.3.3.3:53) dns SIS_OPEN
R2#

dns-timeout

UDPは”ip inspect name udp”コマンドで許可する事ができます。このコマンドの場合、デフォルト設定のtimeout時間30秒が適用されます。

しかし、DNS queryのtimeout時間に限っては、この設定が反映されません。DNS queryのtimeout時間を定義するのには以下コマンドを使用します。

Router(config)# ip inspect dns-timeout [ <sec> ]

router-traffic

Cisco IOSはルータを経由するパケットを覗き見します。言い換えれば、デフォルト設定ではルータ発信のパケットは覗き見されないので、ルータ発信のパケットの戻りは許可されません。ルータ発信のパケットも覗き見し戻りを許可したい場合は、以下のような”router-traffic”キーワードを使用します。

CCIE R&Sの試験は”ルータ発信のpingを許可して下さい”との出題パターンがよく見られます。

Router(config)# ip inspect name <inspect_name> <protocol> [ router-traffic ]

基本的にrouter-trafficキーワードを指定してもルーティングプロトコルは許可されません。

戻りを許可するという事は、戻りの通信は送信元と宛先のIPアドレスが入れ替わった状態になっていなければなりません。もし、router-trafficキーワードでルーティングプロトコルを許可したいのならば、neighborコマンドでユニキャストによるルーティングを実装する必要があります

hashtable-size

Cisco IOSはセッションテーブルの中から当該のエントリを素早く探索できるようハッシュテーブルを保持しています。ハッシュテーブルのサイズはセッションのエントリ数と同じくらいに設定しておくのがCiscoの推奨設定となっております。(ハッシュテーブルが多き過ぎるとハッシュ値計算が長くなる一方、ハッシュテーブルが小さすぎるとハッシュ値の衝突頻度が大きくなりエントリ探索に時間がかかります。)

Router(config)# ip inspect hashtable-size [ 1024 | 2048 | 4096 | 8192 ]

ip inspect

設定投入

R2に以下の設定を投入します。HTTP通信のみ許可し、それ以外は戻りを許さない設定とします。

 [R2]
ip access-list extended ACL_DENY_ANY
 10 permit udp any any eq rip
 99 deny ip any any
!
ip inspect name INSPECT http audit-trail on
!
interface Ethernet 0/0
 ip access-group ACL_DENY_ANY in
 ip inspect INSPECT out

動作確認準備

動作確認のため、R3をHTTP serverとして設定します。また、running-configをflash配下にコピーしダウンロード可能なようにします。

 [R3]
enable password cisco
ip http server
ip http path flash:
ip http authentication enable

R3#show running-config | redirect flash:running-config
R3#

動作確認

R1からR3へのHTTP通信とpingを試みます。inspectされて戻り通信が一時的に許可されるHTTPは疎通可能ですが、pingは疎通不能である事が読み取れます。

 [R1]
R1#copy http://cisco:cisco@10.3.3.3/running-config null:
Loading http://***********@10.3.3.3/running-config !
981 bytes copied in 0.388 secs (2528 bytes/sec)
R1#
R1#
R1#ping 10.3.3.3

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.3.3.3, timeout is 2 seconds:
...
Success rate is 0 percent (0/3)
R1#

上記通信に伴い、R2には監査ログ(audit log)が出力されている事も確認しましょう。

 [R2]
R2#
*Mar  1 00:13:52.439: %FW-6-SESS_AUDIT_TRAIL_START: Start http session: initiator (192.168.12.1:25015) -- responder (10.3.3.3:80)
R2#
R2#
*Mar  1 00:13:57.799: %FW-6-SESS_AUDIT_TRAIL: Stop http session: initiator (192.168.12.1:25015) sent 166 bytes -- responder (10.3.3.3:80) sent 1255 bytes
R2#

DNS timeout

設定投入

R2において、udp,icmpを許可する設定を投入します。また、dnp timeoutは7秒とします。

ip inspect name INSPECT udp
ip inspect name INSPECT icmp
ip inspect dns-timeout 7

動作確認準備

動作確認のため、R3をDNS Serverとして設定します。

 [R3]
ip host R1 10.1.1.1
ip host R2 10.2.2.2
ip host R3 10.3.3.3
ip dns server

 [R1, R2]
ip name-server 10.3.3.3

動作確認

R1からR3への名前解決を使用したpingを発生させます。

 [R1]
R1#ping R3 repeat 10

Translating "R3"...domain server (10.3.3.3) [OK]

Type escape sequence to abort.
Sending 10, 100-byte ICMP Echos to 192.168.23.3, timeout is 2 seconds:
!!!!!!!!!!
Success rate is 100 percent (10/10), round-trip min/avg/max = 56/76/100 ms
R1#

R2にて”show ip inspect sessions”コマンドを連打します。7秒後にはdnsセッションが管理されなくなり、10秒後にはicmpセッションが管理されなくなります。

R2#show ip inspect sessions
Established Sessions
 Session 646B1C8C (192.168.12.1:49971)=>(10.3.3.3:53) udp SIS_OPEN
 Session 646B1A0C (192.168.12.1:8)=>(192.168.23.3:0) icmp SIS_OPEN
R2#
R2#
R2#show ip inspect sessions
Established Sessions
 Session 646B1A0C (192.168.12.1:8)=>(192.168.23.3:0) icmp SIS_OPEN
R2#
R2#show ip inspect sessions

R2#

timeout等の詳細設定は以下コマンドで確認する事ができます。

 [R2]
R2#show ip inspect config
Session audit trail is disabled
Session alert is enabled
one-minute (sampling period) thresholds are [unlimited : unlimited] connections
max-incomplete sessions thresholds are [unlimited : unlimited]
max-incomplete tcp connections per host is unlimited. Block-time 0 minute.
tcp synwait-time is 30 sec -- tcp finwait-time is 5 sec
tcp idle-time is 3600 sec -- udp idle-time is 30 sec
dns-timeout is 7 sec
Inspection Rule Configuration
 Inspection name INSPECT
    http alert is on audit-trail is on timeout 3600
    udp alert is on audit-trail is off timeout 30
    icmp alert is on audit-trail is off timeout 10

R2#
タイトルとURLをコピーしました