1
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?

[AIX] IPSecフィルター・ルールを設定して通信を制御する

1
Last updated at Posted at 2026-04-05

はじめに

AIXのIPSecフィルター機能を使用し、ネットワークレベルでアクセス制御(パケットフィルタリング)を実装する手順をご紹介します。

特定のIPアドレスからの通信のみを許可し、それ以外の同一サブネットからの通信をすべて拒否するという、ファイアウォールに相当する基本的な設定を、smitty を用いて構成し ping で動作確認を行います。

11.png

  • 参考

・IBM AIX: Using IPSec Rules to Filter Network Traffic
https://www.ibm.com/support/pages/node/6590907

・IP セキュリティー・フィルターの構成
https://www.ibm.com/docs/ja/aix/7.3.0?topic=security-ip-filter-configuration


動画

当記事の動画です。理解の一助にお役立てください。


環境

ホスト IP アドレス 備考
AIX1(本機) 172.16.110.142 設定対象サーバー
AIX2 172.16.110.171 許可対象ホスト
RHEL1 172.16.110.59 拒否対象(172.16.0.0/16 セグメント)
RHEL2 172.16.110.241 拒否対象(172.16.0.0/16 セグメント)

方針:

  • 172.16.110.171(AIX2)からの inbound 通信を permit
  • 172.16.0.0/16 セグメントからの inbound 通信を deny
  • ルールは en0 インターフェースに適用

1. 許可(Permit)ルールの作成

特定のIPアドレス(AIX2, 172.16.110.171)からの通信を許可するルールを作成します。

# smitty ipsec4

(smitty 遷移)

Advanced IP Security Configuration

Configure IP Security Filter Rules

Add an IP Security Filter Rule


以下の通り、許可ルールのパラメーターを設定します。

Rule Action を permit に設定し、IP Source Address に許可したい特定のIPを指定します。マスクは 255.255.255.255(単一ホスト)です。

                                   Add an IP Security Filter Rule

Type or select values in entry fields.
Press Enter AFTER making all desired changes.

[TOP]                                                   [Entry Fields]
** Rule Action                                        [permit]                                    +
* IP Source Address                                  [172.16.110.171]  #< 設定
* IP Source Mask                                     [255.255.255.255] #< 設定
  IP Destination Address                             [172.16.110.142]  #< 設定
  IP Destination Mask                                [255.255.255.255] #< 設定
* Apply to Source Routing? (PERMIT/inbound only)     [yes]      +
* Protocol                                           [all]      +
* Source Port / ICMP Type Operation                  [any]      +
* Source Port Number / ICMP Type                     [0]        #
* Destination Port / ICMP Code Operation             [any]      +
* Destination Port Number / ICMP Type                [0]        #
* Routing                                            [both]     +
* Direction                                          [inbound]  +  #< 設定
* Log Control                                        [no]       +
* Fragmentation Control                              [0]        +
* Interface                                          [en0]      +   #< 設定
  Expiration Time (sec)                              []         #
  Pattern Type                                       [none]     +
  Pattern / Pattern File                             []
  Description                                        []

Enter を押して実行

                                           COMMAND STATUS

Command: OK            stdout: yes           stderr: no

Before command completion, additional instructions may appear below.

Filter rule 3 for IPv4 has been added successfully.



上記設定をコマンドラインから実行する場合は、次のようになります。

# /usr/sbin/genfilt -v 4  -a 'P' -s '172.16.110.171' -m '255.255.255.255 ' -d '172.16.110.142' -M '255.255.255.255' -g 'y' -c 'all' -o 'any' -p  '0' -O 'any' -P '0' -r 'B' -w 'B' -l 'N' -t '0'

・genfilt コマンド
https://www.ibm.com/docs/ja/aix/7.3.0?topic=g-genfilt-command


2. 拒否(Deny)ルールの作成

次に、サブネット全体(172.16.0.0/16)からの通信を拒否するルールを作成します。IPSec フィルターは rule0 から順に評価され、最初に一致したルールが適用されます。

先ほどと同じ Add an IP Security Filter Rule の画面を開き、以下のように設定します。

Rule Action を deny に設定し、IP Source Address と Mask で制限したいネットワーク帯域を指定します。

                                   Add an IP Security Filter Rule

Type or select values in entry fields.
Press Enter AFTER making all desired changes.

[TOP]                                                   [Entry Fields]
* Rule Action                                        [deny]     +   #< 設定
* IP Source Address                                  [172.16.0.0]    #< 設定
* IP Source Mask                                     [255.255.0.0]   #< 設定
  IP Destination Address                             []
  IP Destination Mask                                []
* Apply to Source Routing? (PERMIT/inbound only)     [yes]      +
* Protocol                                           [all]      +
* Source Port / ICMP Type Operation                  [any]      +
* Source Port Number / ICMP Type                     [0]        #
* Destination Port / ICMP Code Operation             [any]      +
* Destination Port Number / ICMP Type                [0]        #
* Routing                                            [both]     +
* Direction                                          [inbound]  +    #< 設定
* Log Control                                        [no]       +
* Fragmentation Control                              [0]        +
* Interface                                          [en0]      +    #< 設定
  Expiration Time (sec)                              []         #
  Pattern Type                                       [none]     +
  Pattern / Pattern File                             []
  Description                                        []

Enter を押して実行

                                           COMMAND STATUS		
		
Command: OK            stdout: yes           stderr: no		
		
Before command completion, additional instructions may appear below.		
		
Filter rule 4 for IPv4 has been added successfully.		



上記設定をコマンドラインから実行する場合は、次のようになります。

# /usr/sbin/genfilt -v 4  -a 'D' -s '172.16.0.0' -m '255.255.0.0' -d '0.0.0.0' -M '0.0.0.0' -g 'y' -c 'all' -o 'any' -p '0' -O 'any' -P '0' -r  'B' -w 'I' -l 'N' -t '0' -i 'en0'

3. IPSecの起動とフィルター・ルールの確認

設定したルールを有効にするため、IPSec サービスを起動します。

# smitty ipsec4 

(smitty 遷移)

Start/Stop IP Security

Start IP Security

                                         Start IP Security

Type or select values in entry fields.
Press Enter AFTER making all desired changes.

                                                        [Entry Fields]
  Start IP Security                                  [Now and After Reboot]   +
  Deny All Non_Secure IP Packets                     [no]                     +

Enter を押して実行

                                           COMMAND STATUS

Command: OK            stdout: yes           stderr: no

Before command completion, additional instructions may appear below.

ipsec_v4 Available
Default rule for IPv4 in ODM has been changed.
Successfully set default action to PERMIT

コマンドが正常終了すると、ipsec_v4 デバイスが Available になります。

# lsdev -Cc ipsec
ipsec_v4 Available  IP Version 4 Security Extension
ipsec_v6 Available  IP Version 6 Security Extension

続いて、作成したフィルター・ルールの一覧を確認します。

# lsfilt -v4 a

既存のルールを含め、Rule 0〜4 が設定されていることが確認できます。

  • Rule 3 (permit): 172.16.110.171からの通信を許可
  • Rule 4 (deny): 172.16.0.0/16からの通信を拒否

意図した通りの順序でルールが登録されています。

実行ログ (折りたたんでいます)
# lsfilt -v4 a
Beginning of IPv4 filter rules.
Rule 1:
Rule action         : permit
Source Address      : 0.0.0.0
Source Mask         : 0.0.0.0
Destination Address : 0.0.0.0
Destination Mask    : 0.0.0.0
Source Routing      : no
Protocol            : udp
Source Port         : eq  4001
Destination Port    : eq  4001
Scope               : both
Direction           : both
Logging control     : no
Fragment control    : all packets
Tunnel ID number    : 0
Interface           : all
Auto-Generated      : yes
Expiration Time     : 0
Description         : Default Rule

Rule 2:
*** Dynamic filter placement rule for IKE tunnels ***
Logging control     : no

Rule 3:
Rule action         : permit
Source Address      : 172.16.110.171
Source Mask         : 255.255.255.255
Destination Address : 0.0.0.0
Destination Mask    : 0.0.0.0
Source Routing      : yes
Protocol            : all
Source Port         : any 0
Destination Port    : any 0
Scope               : both
Direction           : inbound
Logging control     : no
Fragment control    : all packets
Tunnel ID number    : 0
Interface           : en0
Auto-Generated      : no
Expiration Time     : 0
Description         :

Rule 4:
Rule action         : deny
Source Address      : 172.16.0.0
Source Mask         : 255.255.0.0
Destination Address : 0.0.0.0
Destination Mask    : 0.0.0.0
Source Routing      : yes
Protocol            : all
Source Port         : any 0
Destination Port    : any 0
Scope               : both
Direction           : inbound
Logging control     : no
Fragment control    : all packets
Tunnel ID number    : 0
Interface           : en0
Auto-Generated      : no
Expiration Time     : 0
Description         :

Rule 0:
Rule action         : permit
Source Address      : 0.0.0.0
Source Mask         : 0.0.0.0
Destination Address : 0.0.0.0
Destination Mask    : 0.0.0.0
Source Routing      : yes
Protocol            : all
Source Port         : any 0
Destination Port    : any 0
Scope               : both
Direction           : both
Logging control     : no
Fragment control    : all packets
Tunnel ID number    : 0
Interface           : all
Auto-Generated      : no
Expiration Time     : 0
Description         : Default Rule

End of IPv4 filter rules.
#

4. フィルター・ルールのアクティベート

登録したルールをシステムに反映(アクティベート)させます。

# smitty ipsec4 

Advanced IP Security Configuration

Activate/Update/Deactivate IP Security Filter Rule

                         Activate/Update/Deactivate IP Security Filter Rule

Move cursor to desired item and press Enter.

  Activate / Update   ##<= 選択
  Deactivate


            +--------------------------------------------------------------------------+
            |                              ARE YOU SURE?                               |
            |                                                                          |
            | Continuing may delete information you may want                           |
            | to keep.  This is your last chance to stop                               |
            | before continuing.                                                       |
            |     Press Enter to continue.                                             |
            |     Press Cancel to return to the application.                           |
            |                                                                          |
            | F1=Help                 F2=Refresh              F3=Cancel                |
F1=Help     | F8=Image                F10=Exit                Enter=Do                 |
F9=Shell    +--------------------------------------------------------------------------+

Enter を押して実行します。

                                           COMMAND STATUS

Command: OK            stdout: yes           stderr: no

Before command completion, additional instructions may appear below.

ipsec_v4 Available
Default rule for IPv4 in ODM has been changed.
Successfully set default action to PERMIT

正常に実行され、ルールが適用されました。


5. 動作確認(Pingテスト)

想定通りに通信が制御されているか、各ホストからの ping で確認を行います。

① 許可したホスト AIX2(172.16.110.171)に対して ping が通る:

# ping 172.16.110.171
PING 172.16.110.171 (172.16.110.171): 56 data bytes
64 bytes from 172.16.110.171: icmp_seq=0 ttl=255 time=0 ms
64 bytes from 172.16.110.171: icmp_seq=1 ttl=255 time=0 ms
--- 172.16.110.171 ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss

:ok_woman: 成功。 Rule 3 の permit ルールにより通信が許可されています。



② 拒否したサブネットにあるホスト RHEL1(172.16.110.59) に ping が通らない

# ping 172.16.110.59
PING 172.16.110.59 (172.16.110.59): 56 data bytes

:no_good_tone1: 失敗(無応答)。Rule 4 の deny ルールにより通信が遮断されています。



③拒否したサブネット内のさらに別のホスト RHEL2(172.16.110.241)にpingが通らない

# ping 172.16.110.241
PING 172.16.110.241 (172.16.110.241): 56 data bytes
^C
--- 172.16.110.241 ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss

:no_good: 失敗(100% packet loss)。 同様にブロックされています。



④自分自身にpingが通る

自身のIPアドレス確認

# ifconfig -a
en0: flags=1e084863,814c0<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),LARGESEND,CHAIN>
        inet 172.16.110.142 netmask 0xffff0000 broadcast 172.16.255.255
         tcp_sendspace 262144 tcp_recvspace 262144 rfc1323 1
lo0: flags=e08084b,c0<UP,BROADCAST,LOOPBACK,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,LARGESEND,CHAIN>
        inet 127.0.0.1 netmask 0xff000000 broadcast 127.255.255.255
        inet6 ::1%1/64
         tcp_sendspace 131072 tcp_recvspace 131072 rfc1323 1
# ping 172.16.110.142
PING 172.16.110.142 (172.16.110.142): 56 data bytes
64 bytes from 172.16.110.142: icmp_seq=0 ttl=255 time=0 ms
^C
--- 172.16.110.142 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max = 0/0/0 ms
#

:ok_woman_tone2: 成功。 自ホスト宛の通信は正常に行えています。


ルール評価の整理

inbound パケット到着
     │
     ├─ Rule 1  : UDP 4001 ← permit(IKE デフォルトルール)
     ├─ Rule 2  : IKE 動的フィルター
     ├─ Rule 3  : src=172.16.110.171/32 ← permit ✅
     ├─ Rule 4  : src=172.16.0.0/16    ← deny   🚫
     └─ Rule 0  : 0.0.0.0/0           ← permit(デフォルト)


まとめ

AIXのネイティブ機能であるIPSecを利用することで、外部のファイアウォール機器に頼らずにOSレベルでパケットフィルタリングが可能です。
smitty を利用することで、視覚的かつ直感的にルールを定義でき、即座にトラフィック制御を行えます。

項目 内容
設定ツール smitty ipsec4
ルール確認 lsfilt -v4 a
デバイス確認 lsdev -Cc ipsec
評価順 ルール番号の昇順で評価(番号が小さいルールが優先)
デフォルト動作 PERMIT(Rule 0 による全許可)

適用する際は、運用に必要な通信(SSHや監視系のポートなど)を誤って遮断しないよう、事前の設計と十分な検証を行った上で適用することをおすすめします。


ネットワーク・インターフェースへの制御方法は下記をご参考ください。

以上です。

1
0
5

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
1
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?