はじめに
Check Point 管理サーバにおいて、アクセスコントロールポリシー、NAT、脅威対策ポリシー、HTTP インスペクションの設定をエクスポートしたり、エクスポートしたデータをインポートしたりする方法について記載します。
作業環境
CP81-MNG> ver
Product version Check Point Gaia R81
OS build 392
OS kernel version 3.10.0-957.21.3cpx86_64
OS edition 64-bit
ツールの準備
SmartConsole の標準機能では、ポリシー設定のエクスポートやインポートは実質的にはできません。
※「エクスポート」はできますが CSV 形式の非常に簡素なファイルとしてエクスポートされ、インポートはできません(インポート機能がありません)
その代わり、ExportImportPolicyPackage
という Python ベースのツールが GitHub で公開されているため、これを使います。
また、ExportImportPolicyPackage
を使用するためには cp_mgmt_api_python_sdk
というライブラリが必要です。これも GitHub で公開されています。
それぞれ GitHub リポジトリから zip ファイルでダウンロードし、Check Point 管理サーバへ格納します。格納先は管理ユーザのホームディレクトリで良いかと思います。
cp_mgmt_api_python_sdk 内の cpapi
ディレクトリは ExportImportPolicyPackage ディレクトリの中に移動させます。
ExportImportPolicyPackage ディレクトリの中身は以下のようになります。
[Expert@CP81-MNG:0]# ls -l ExportImportPolicyPackage-master/
total 92
-rwxrwxrwx 1 admin root 11558 Jun 16 03:07 LICENSE
-rwxrwxrwx 1 admin root 2283 Jun 16 03:07 README.md
-rwxrwxrwx 1 admin root 14 Jun 16 03:07 __init__.py
drwxrwxrwx 2 admin root 122 Jun 17 16:10 cpapi
drwxrwxrwx 2 admin root 282 Jun 17 13:34 exporting
-rwxrwxrwx 1 admin root 2897 Jun 16 03:07 import_export_package.py
drwxrwxrwx 2 admin root 75 Jun 17 13:34 importing
-rwxrwxrwx 1 admin root 24930 Jun 16 03:07 lists_and_dictionaries.py
-rwxrwxrwx 1 admin root 13533 Jun 16 03:07 menu.py
-rwxrwxrwx 1 admin root 23732 Jun 16 03:07 utils.py
ポリシーのエクスポート
カレントディレクトリを ExportImportPolicyPackage ディレクトリとし、以下のコマンドを実行します。
python import_export_package.py
[Expert@CP81-MNG:0]# python import_export_package.py
Welcome to the Policy Package Import/Export Tool.
What would you like to do?
1. Import a package
2. Export a package
99. Exit
2 (Export a package) を押下します。
2
Please enter a Policy Package name to export:
エクスポートするポリシーパッケージ名を聞かれるため、入力します。
Standard
Please select a login method:
1. Enter user credentials manually
2. Login as Root
3. Use an existing session file
4. Use an existing session UID
99. Back
ログイン方法を聞かれるため、2 (Login as Root) を押下します。
2
The script will run with the following parameters:
Export Access-Control layers = True
Export NAT layers = False
Export Threat-Prevention layers = False
Export HTTPS Inspection layers = False
Output-file name = None
Management Server IP = 127.0.0.1
Management Server Port = 443
Management Server Domain = None
1. Change Settings
2. Run
99. Back
パラメータが表示されるため、必要に応じて変更します。
デフォルトではエクスポート対象がアクセスコントロールポリシーのみになっているため、必要に応じて NAT、脅威対策、HTTPS インスペクションについて設定変更します。
1
Please select a setting to change:
1. Disable export of Access-Control Rulebases
2. Enable export of Threat-Prevention Rulebases
3. Enable export of NAT Rulebases
4. Enable export of HTTPS Inspection Rulebases
5. Output file name
6. Change Management Server IP
7. Change Management Server Port
8. Change the domain name
99. Back
2
Exporting of Threat-Prevention layers enabled
The script will run with the following parameters:
Export Access-Control layers = True
Export NAT layers = False
Export Threat-Prevention layers = True
Export HTTPS Inspection layers = False
Output-file name = None
Management Server IP = 127.0.0.1
Management Server Port = 443
Management Server Domain = None
1. Change Settings
2. Run
99. Back
1
Please select a setting to change:
1. Disable export of Access-Control Rulebases
2. Disable export of Threat-Prevention Rulebases
3. Enable export of NAT Rulebases
4. Enable export of HTTPS Inspection Rulebases
5. Output file name
6. Change Management Server IP
7. Change Management Server Port
8. Change the domain name
99. Back
3
Exporting of NAT layers enabled
The script will run with the following parameters:
Export Access-Control layers = True
Export NAT layers = True
Export Threat-Prevention layers = True
Export HTTPS Inspection layers = False
Output-file name = None
Management Server IP = 127.0.0.1
Management Server Port = 443
Management Server Domain = None
1. Change Settings
2. Run
99. Back
1
Please select a setting to change:
1. Disable export of Access-Control Rulebases
2. Disable export of Threat-Prevention Rulebases
3. Disable export of NAT Rulebases
4. Enable export of HTTPS Inspection Rulebases
5. Output file name
6. Change Management Server IP
7. Change Management Server Port
8. Change the domain name
99. Back
4
Exporting of HTTPS Inspection layers enabled
The script will run with the following parameters:
Export Access-Control layers = True
Export NAT layers = True
Export Threat-Prevention layers = True
Export HTTPS Inspection layers = True
Output-file name = None
Management Server IP = 127.0.0.1
Management Server Port = 443
Management Server Domain = None
1. Change Settings
2. Run
99. Back
設定ができたら、2 (Run) を押下し、実行します。
2
You currently do not have a record of this server's fingerprint.
Server's fingerprint: AA1A9243A19BE4485963F7B0692B47DE20DC835E
Do you accept this fingerprint? [y/n] y
Fingerprint saved.
No package named 'Standard' found. Cannot export.
以下のようなログが流れます。
2
You currently do not have a record of this server's fingerprint.
Server's fingerprint: AA1A9243A19BE4485963F7B0692B47DE20DC835E
Do you accept this fingerprint? [y/n] y
Fingerprint saved.
Exporting Access Control layers
Exporting Access Layer [IMPORTED LAYER Network]
Retrieved 2 out of 2 rules (100%)
Processing rules and sections
Exporting access rules from layer [IMPORTED LAYER Network]
Exporting access sections from layer [IMPORTED LAYER Network]
Exporting placeholders for unexportable objects from layer [IMPORTED LAYER Network]
Exporting layer settings of layer [IMPORTED LAYER Network]
Done exporting layer 'IMPORTED LAYER Network'.
Exporting Access Layer [Network]
Retrieved 1 out of 1 rules (100%)
Processing rules and sections
Exporting access rules from layer [Network]
Exporting access sections from layer [Network]
Exporting placeholders for unexportable objects from layer [Network]
Exporting layer settings of layer [Network]
Done exporting layer 'Network'.
Exporting NAT policy
#以下略
エクスポートに成功すると以下のようなパッケージファイルが作成されます。
exported__package__Standard__2021_06_17_16_27.tar.gz
このパッケージファイルをインポートで使用します。
ポリシーのインポート
パッケージをインストールしたい管理サーバの ExportImportPolicyPackage ディレクトリ内にインポートしたいパッケージファイルを格納します。
カレントディレクトリを ExportImportPolicyPackage ディレクトリとし、以下のコマンドを実行します。
python import_export_package.py
[Expert@CP81-MNG:0]# python import_export_package.py
Welcome to the Policy Package Import/Export Tool.
What would you like to do?
1. Import a package
2. Export a package
99. Exit
1 (Import a package) を押下します。
インポートしたいファイルのパスを聞かれるため、パスを入力します。
1
Please specify the path to the file you wish to import:
exported__package__Standard__2021_06_17_16_27.tar.gz
ログイン方法を聞かれるため、2 (Login as Root) を押下します。
exported__package__Standard__2021_06_17_16_27.tar.gz
Please select a login method:
1. Enter user credentials manually
2. Login as Root
3. Use an existing session file
4. Use an existing session UID
99. Back
パラメータが表示されるため、問題無ければ 2 (Run) を押下します。
2
The script will run with the following parameters:
Custom name for imported package (optional) = None
Management Server IP = 127.0.0.1
Management Server Port = 443
Management Server Domain = None
1. Change Settings
2. Run
99. Back
同じ名前のパッケージが存在する場合は以下のように確認が出ます。問題無ければ 1 (Yes) を押下します。
2
A package named Standard already exists. Are you sure you want to import?
1.Yes
2.No
以下のようなログが流れます。
1
Importing general objects
Adding https-layers
Imported 1 out of 1 https-layers (100%)
Adding access-layers
Imported 2 out of 2 access-layers (100%)
Adding networks
#中略
Imported 10 out of 10 networks (100%)
Importing Access_Layer [IMPORTED LAYER IMPORTED LAYER 6 Network]
Adding access-rules
Imported 3 out of 3 access-rules (100%)
Importing Access_Layer [IMPORTED LAYER 7 Network]
Adding access-rules
Imported 1 out of 1 access-rules (100%)
Importing Nat_Layer [Standard]
Nothing to import...
Importing Https_Layer [IMPORTED LAYER 5 Default Layer]
Adding https-rules
Imported 1 out of 1 https-rules (100%)
SmartConsole でポリシーがインポートされたことを確認します。