LoginSignup
18

More than 5 years have passed since last update.

Catalyst等のコンフィグのACLを表形式に表示して検索する(Excel不要)

Posted at

やりたいこと

ルーターやL3スイッチに大量のACLが設定されていて、
ひょんなことから、表形式に表示、検索したくなったときのやり方です。
Excelがない環境でもPowerShellさえあればできます。

コード

# ACLをヒアドキュメントとして定義
$acl=@"
access-list 101 permit tcp host 10.1.1.2 host 172.16.1.1 eq telnet        
access-list 101 permit tcp host 10.1.1.2 host 172.16.1.1 eq ftp 
access-list 101 permit udp host 10.1.1.2 host 172.16.1.1 eq syslog        
access-list 101 permit udp host 10.1.1.2 host 172.16.1.1 eq tftp        
access-list 101 permit udp host 10.1.1.2 host 172.16.1.1 eq ntp
"@

# グリッドビューに表示  (1..10)の10はACLをスペース区切りしたときの項目数
$acl | ConvertFrom-Csv -Delimiter " "-Header @(1..10) | Out-GridView

ACLをファイルに保存した場合は

Get-Content "acl.txt" | ConvertFrom-Csv -Delimiter " "-Header @(1..10) | Out-GridView

表示

このように表示されます
Image1.png

検索もできる

検索もできます
Image2.png

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
18