1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

CentOS7のシステムログの収集(journald)とファイヤーウォール(firewalld)

Last updated at Posted at 2019-11-23

はじめに

CentOS7のシステムログの収集(journald)とファイヤーウォール(firewalld)についてまとめてみました

systemd-journald

journaldとは

systemdの環境で、標準的に提供されるログ管理のサービスです。正式名称は、下記の「systemd-journald.service」です。

参照
http://enakai00.hatenablog.com/entry/20141130/1417310904

journal使い方

システムログの収集

/var/log以下にアプリケーションからのログが出力されていますが、これはアプリケーションから直接出力されているものと、アプリケーション内でsyslog()関数を使ってrsyslogdプロセスに渡して出力している(syslogメッセージ)ものがあります

rsyslogdとは?

  • もともとsyslog(rsyslogdの前バージョン)が各アプリケーションからログを受け取りファイルに書き込んでいた。ログを他のサーバーに送信することもできる。
  • CentOS6からsyslogの後継で高機能なrsyslogが採用されている。役割は同じ

CentOS7でのシステムログの収集

journaldの登場

  • アプリケーション → jornald → jornaldDB
    • デフォルトの場所はvar/run/log/jounralなのでOS再起動でなくなる。場所は変えられる
  • プロセスの標準出力/エラー出力もjournaldが受け取るようになった
  • アプリケーション → jornald → rsyslogd
    • rsyslogdが今まで通りログファイルに書き込む

Firewalledによるパケットフィルタリング

  • firewalledコマンドはINPUTチェインのパケットフィルタリングルールを制御する。
  • NATやフォワードの設定は別途
  • firewalledが内部でnetfilterを使用している
    • netfileterがチェイン(チェック箇所、input,forwardなど7箇所)でパケットフィルタリングする

CentOS 7システム管理ガイド systemd/NetworkManager/Firewalld徹底攻略よりチェイン

image.png

ゾーンとは

  • ネットワークインターフェースを用途などによってグループ化したもの。
  • 各ゾーンには役割を決めていて、その役割にあったサービスなどが最初っから許可されている
  • デフォルトではすべてのインターフェースはpublicゾーンに所属している

ICMP

デフォルトで許可

現在アクティブなゾーンの確認

デフォルトはpublicに所属


firewall-cmd --get-active-zones
public
  interfaces: ens192

firewall-cmd --get-default-zone
public

firewall-cmd

firewall-cmd コマンドを利用して行います

永続とランタイム

firewall-cmd --add-service=http
firewall-cmd --permanent --add-service=http
firewall-cmd --runtime-to-permanent

ゾーンを指定しなければデフォルトのゾーンに対して設定される

サービス

利用可能なサービス一覧

# firewall-cmd --get-service
RH-Satellite-6 amanda-client amanda-k5-client amqp amqps apcupsd audit bacula bacula-client bgp bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc ceph ceph-mon cfengine condor-collector ctdb dhcp dhcpv6 dhcpv6-client distcc dns docker-registry docker-swarm dropbox-lansync elasticsearch etcd-client etcd-server finger freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp ganglia-client ganglia-master git gre high-availability http https imap imaps ipp ipp-client ipsec irc ircs iscsi-target isns jenkins kadmin kerberos kibana klogin kpasswd kprop kshell ldap ldaps libvirt libvirt-tls lightning-network llmnr managesieve matrix mdns minidlna mongodb mosh mountd mqtt mqtt-tls ms-wbt mssql murmur mysql nfs nfs3 nmea-0183 nrpe ntp nut openvpn ovirt-imageio ovirt-storageconsole ovirt-vmconsole plex pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy proxy-dhcp ptp pulseaudio puppetmaster quassel radius redis rpc-bind rsh rsyncd rtsp salt-master samba samba-client samba-dc sane sip sips slp smtp smtp-submission smtps snmp snmptrap spideroak-lansync squid ssh steam-streaming svdrp svn syncthing syncthing-gui synergy syslog syslog-tls telnet tftp tftp-client tinc tor-socks transmission-client upnp-client vdsm vnc-server wbem-http wbem-https wsman wsmans xdmcp xmpp-bosh xmpp-client xmpp-local xmpp-server zabbix-agent zabbix-server

サービス定義

ポートとプロトコルが指定されている

# cat /usr/lib/firewalld/services/http.xml
<?xml version="1.0" encoding="utf-8"?>
<service>
  <short>WWW (HTTP)</short>
  <description>HTTP is the protocol used to serve Web pages. If you plan to make your Web server publicly available, enable this option. This option is not required for viewing pages locally or developing Web pages.</description>
  <port protocol="tcp" port="80"/>
</service>

追加

# firewall-cmd --add-service=http --permanent
success

確認

# firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: enp0s25
  sources:
  services: dhcpv6-client http ssh

ポート

サービスに登録されていないサービス(ポート)

1
1
0

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?