#author("2026-04-07T13:30:28+00:00","default:t_take","t_take") #author("2026-04-07T13:31:00+00:00","default:t_take","t_take") [[仮想化]] 目次~ #contents *RockyLinux 9 [#ce27a341] -コンテナイメージ rockylinux-9-default **sshの有効化 [#gae9d723] -インストール dnf install openssh-server systemctl start sshd systemctl enable sshd -ユーザ作成 useradd [USER] passwd [USER] **ログインシェルにrbashを使う [#xc21eb1f] -rbash有効化 ln -s /bin/bash /bin/rbash useradd -g [GROUP] -s /bin/rbash [USER] -ユーザ作成 useradd -s /bin/rbash [USER] **fail2ban [#xfb3387a] -インストール dnf install epel-release dnf install -y fail2ban -/etc/fail2ban/jail.d/sshd.local [sshd] enabled = true bantime = 600 # 600秒 (10分) ブロック findtime = 600 # 600秒 (10分) の間に maxretry = 3 # 3回失敗したらブロック backend = systemd # systemdのログを監視 -サービス有効化 systemctl enable --now fail2ban -動作確認 fail2ban-client status sshd **fail2ban(複数ルール) [#u88baa97] fail2banにて1つのサービスに複数のルールを適用する方法。~ -/etc/fail2ban/jail.d/sshd.local [sshd-10min] enabled = true filter = sshd logpath = /var/log/secure bantime = 600 findtime = 600 maxretry = 3 backend = systemd [sshd-1min] enabled = true filter = sshd logpath = /var/log/secure bantime = 600 findtime = 60 maxretry = 3 backend = systemd -動作確認 # fail2ban-client status Status |- Number of jail: 2 **DNSサーバ構築(bind) [#le9ceb6f] -インストール dnf install bind -named.confの設定 --zoneファイルの作成 --zoneファイルのチェック /usr/sbin/named-checkconf -z /etc/named.conf -サービス起動 systemctl start named systemctl status named systemctl enable named **DNSキャッシュサーバ構築(bind) [#n042d085] -インストール dnf install bind -named.confの設定 --キャッシュサーバ options { directory "/var/named"; listen-on port 53 { 127.0.0.1; 【ホストアドレス】; }; listen-on-v6 { none; }; allow-query { localhost; 【許可アドレス帯】; }; allow-recursion { localhost; 【許可アドレス帯】; }; recursion yes; forward only; forwarders { 【上位DNS】; 【上位DNS】; }; dnssec-validation no; auth-nxdomain no; empty-zones-enable yes; }; logging { channel default_log { file "/var/log/named/named.log" versions 5 size 10m; severity info; print-time yes; print-severity yes; print-category yes; }; category default { default_log; }; category queries { default_log; }; }; -サービス起動 systemctl start named systemctl status named systemctl enable named **Zabbix Agent2 [#o64eaee9] -インストール rpm -Uvh https://repo.zabbix.com/zabbix/7.0/rocky/9/x86_64/zabbix-release-latest-7.0.el9.noarch.rpm dnf install zabbix-agent2 --/etc/zabbix/zabbix_agent2.conf ~ PidFile=/run/zabbix/zabbix_agent2.pid LogFile=/var/log/zabbix/zabbix_agent2.log LogFileSize=0 Server=127.0.0.1,[Zabbix Server] ServerActive=[Zabbix Server] HostMetadata=[META DATA] Include=/etc/zabbix/zabbix_agent2.d/*.conf PluginSocket=/run/zabbix/agent.plugin.sock ControlSocket=/run/zabbix/agent.sock AllowKey=system.run[*] Include=/etc/zabbix/zabbix_agent2.d/plugins.d/*.conf -サービス起動 systemctl start zabbix-agent2 systemctl enable zabbix-agent2 **NTPサーバ(chrony) [#fbd18762] -前提 NTPを動作させるためには、特権コンテナとして構築する必要がある。 -インストール dnf install chrony --/etc/chrony.conf server 192.168.1.220 iburst server 192.168.1.221 iburst server 【上位NTP】 iburst server 【上位NTP】 iburst driftfile /var/lib/chrony/drift makestep 1.0 3 rtcsync allow 【許可アドレス帯】 # bindaddress 【ホストアドレス】 # logdir /var/log/chrony # log measurements statistics tracking -サービス起動 systemctl enable --now chronyd systemctl restart chronyd **NFS Client [#zd445087] -インストール dnf install nfs-utils -マウント mount -t nfs [NFS SERVER]:[PATH] [MOUNT POINT] **Web Server関連 [#icd3a2c1] ***httpd [#u09eae8c] ***perl [#h0ddfdae] ***ImageMagick [#oab783b5] dnf groupinstall "Development Tools" dnf install epel-release dnf clean all dnf install ImageMagick ImageMagick-devel *コンテナ設定関連 [#o5123319] **権限付与 [#bf81445c] 一般ユーザの権限に通常は付与されない権限を追加する手順。~ ***生ソケット権限(CAP_NET_RAW)の付与 [#n0c8eb3c] コンテナ内から外部に対してPingを打つ際には以下の権限付与が必要。 setcap cap_net_raw+ep /usr/bin/ping