【Paloalto】set形式でconfigを取得する方法

Paloalto Paloalto

Paloalto では webコンソールで config をエクスポートするときや、デフォルト設定の CLI で config を確認すると xml形式で取得できます。

しかしながら実際に CLI を利用して Paloalto に設定を入れる場合、set形式で入れることになるため、既存の設定内容を set形式で取得することができると config の編集や作成が楽になります。

今回はその set形式で config を取得する方法をまとめてみました。

広告

set形式でconfigを確認する方法

取得は CLI にて行います。
 ※webコンソールから set形式で出力できないようです。

1.以下のコマンドを入力して出力形式を「set」に変更します。
set cli config-output-format set

ちなみに「set cli config-output-format」の他の選択肢としては「json」があります

「set cli config-output-format」の他の選択肢
(任意)以下のコマンドを入力してページング機能を無効化する
set cli pager off

configの行数はほとんどの場合、CLIの表示行数を超える行数となるのでページング機能が働きます。
最終行までスクロールするのは時間がかかるため、私はよく無効化にしています。
ちなみにページング機能が働いた場合には「Shift + Q」で抜けることが可能です。

2.コンフィグレーションモードに入り「show」を実行します。

すると以下のようにset形式のcofnigが表示されます。

xxxxxx@paloalto-test# show
set deviceconfig system type dhcp-client send-hostname yes
set deviceconfig system type dhcp-client send-client-id no
set deviceconfig system type dhcp-client accept-dhcp-hostname no
set deviceconfig system type dhcp-client accept-dhcp-domain no
set deviceconfig system update-server updates.paloaltonetworks.com
set deviceconfig system update-schedule threats recurring weekly day-of-week wednesday
set deviceconfig system update-schedule threats recurring weekly at 01:02
set deviceconfig system update-schedule threats recurring weekly action download-only
set deviceconfig system timezone Japan

 ~~中略~~

set address-group address-group-01 static address-02
set address address-01 ip-netmask 11.11.11.11/32
set address address-01 tag tag1
set address address-02 ip-netmask 11.11.11.12/32
set address address-02 tag tag1
set mgt-config users xxxxxx phash xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
set mgt-config users xxxxxx permissions role-based superuser yes
set mgt-config password-complexity enabled yes
set mgt-config password-complexity minimum-length 8
[edit]
xxxxxx@paloalto-test#

ここで表示された set形式のコマンドはそのまま CLIコマンドとして palaolto に設定が可能です。

CLIコマンドを利用した設定方法については以下の記事にもまとめていますので参考にしてください。

【Paloalto】オブジェクトのCLIコマンド(アドレスとサービス)
paloalto に設定を投入する際によく利用する CLI コマンドをまとめてみました。アドレス、アドレスグループ、サービス、サービスグループの4つのオブジェクトのCLIコマンドについて追加と削除のコマンド例を記載しています。
【Paloalto】オブジェクトのCLIコマンド(URLカテゴリとURLフィルタリング)
paloalto に設定を投入する際によく利用する CLI コマンドをまとめてみました。URLカテゴリとURLフィルタリングの2つのオブジェクトのCLIコマンドについて追加と削除のコマンド例を記載しています。

【おすすめ】「match」を利用して特定の設定値だけ取り出す

「show」コマンドを実行するとすべてのconfigが取得できますが、例えばセキュリティポリシーの設定だけを取り出したいなど、特定の設定値だけを取り出したい場合もあるかと思います。

そのときには「match」を利用することで特定の設定値のみを取得することが可能です。

「match」は Linux の [grep] や Powershell の [Select-String] といったコマンドと同じように「|」の後に記載します。

以下では例としてセキュリティポリシーだけを set形式で抜き出します。

show | match 'rulebase security rules'

以下のような出力となり、セキュリティポリシーの設定だけを抜き出すことができます。

xxxxxx@paloalto-test# show | match 'rulebase security rules'
set rulebase security rules Allow-01 to Untrust
set rulebase security rules Allow-01 from Trust
set rulebase security rules Allow-01 source any
set rulebase security rules Allow-01 destination any
set rulebase security rules Allow-01 source-user any
set rulebase security rules Allow-01 category URL-yahoo
set rulebase security rules Allow-01 application any
set rulebase security rules Allow-01 service any
set rulebase security rules Allow-01 source-hip any
set rulebase security rules Allow-01 destination-hip any
set rulebase security rules Allow-01 action allow
set rulebase security rules Allow-01 log-start no
set rulebase security rules All-Deny to any
set rulebase security rules All-Deny from any
set rulebase security rules All-Deny source any
set rulebase security rules All-Deny destination any
set rulebase security rules All-Deny source-user any
set rulebase security rules All-Deny category any
set rulebase security rules All-Deny application any
set rulebase security rules All-Deny service any
set rulebase security rules All-Deny source-hip any
set rulebase security rules All-Deny destination-hip any
set rulebase security rules All-Deny action deny
[edit]
xxxxxx@paloalto-test#

ただし、デフォルトで設定されているポリシーについては出力されないので、その部分は覚えておいてください。

コメント

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