2022年11月3日(木) HikVisionの NVRログを rsyslogで受ける設定メモ

HikVision NVRの syslogサーバー転送機能は、面倒なことに TLS証明書を設定して暗号化しないと動作しない。

gnutls-utils パッケージをインストール
# yum install gnutls-utils
証明書のフォルダを作成
# mkdir /etc/ssl/rsyslog
# cd /etc/ssl/rsyslog
プライベートCA秘密鍵を生成
# certtool --generate-privkey --outfile ca.key
プライベートCA証明書を生成
# certtool --generate-self-signed --load-privkey ca.key --outfile ca.crt
Common name: (受信ホスト名)
Country name(2 chars): JP
The certificate will expire in(days): 3650
Does the certificate belong to an authority? (y/N): y
(他はそのままENTER)
Is the above information ok? (y/N): y
サーバー秘密鍵の生成
# certtool --generate-privkey --outfile server.key
証明書要求の生成
# certtool --generate-request --load-privkey server.key --outfile server.csr
Common name: (サーバーの名前)
Country name(2 chars): JP
Is this a TLS web client certificate? (y/N): y
Is this also a TLS web server certificate? (y/N): y
(他はそのままENTER)
サーバー証明書を生成
# certtool --generate-certificate --load-request server.csr --outfile server.crt --load-ca-certificate ca.crt --load-ca-privkey ca.key

The certificate will expire in (days): 3649
Does the certificate belong to an authority?(y/N): n
Is this a TLS web client certificate? (y/N): y
Is this a TLS web server certificate? (y/N): y
Enter the dnsName of the subject of the certificate: (サーバーのホスト名)
Enter the IP address of the subject of the certificate: (IPアドレス)
Is the above information ok? (y/N): y
(他はそのままENTER)
[/etc/rsyslog.conf] 先頭部のモジュール設定を変更
global(
DefaultNetstreamDriver="gtls"
DefaultNetstreamDriverCAFile="/etc/ssl/rsyslog/ca.crt"
DefaultNetstreamDriverCertFile="/etc/ssl/rsyslog/server.crt"
DefaultNetstreamDriverKeyFile="/etc/ssl/rsyslog/server.key"
)
module(
load="imtcp"
StreamDriver.Name="gtls"
StreamDriver.Mode="1"
StreamDriver.Authmode="anon"
)
input(type="imtcp" port="514")
秘密鍵をroot以外アクセス不可に
# chmod 400 /etc/ssl/rsyslog/*.key
rsyslogを再起動
# service rsyslog restart
プライベートCA証明書 ca.crtを HikVision NVRの Log Server Settingsメニュー - CA Certificateから Browseして Install

ファイアーウォールの設定
# firewall-cmd --add-port=514/tcp --perm
# firewall-cmd --reload
# service fail2ban restart (もし使っている場合)

絶対位置 1120 - 1120

日記トップに戻る