CentOS7標準サーバ用設定

前回まとめたUbuntuの手順をベースにCentOS7用の手順もまとめた。
ConohaでUbuntuにするかCentOSにするかはまだ決めかねているけど
日本だと未だCentOSが強いので、まとめておいても損はない。
ちなみにCentOS7からコマンドが大きく変わっていた。
特にネットワークがらみのコマンドの改変はきつい。まぁいやなら
net-tools入れればいいんだけど非推奨なので新しいやり方に
慣れていかないとね。
とりあえずひな形は簡単に作れそうになったので、ここから色々と
やっていければと思います。

●参考サイト
https://centossrv.com/
http://www.server-world.info/query?os=CentOS_7&p=initial_conf
http://qiita.com/mtaniuchi/items/7022d7225d07f7298c81
http://www.server-memo.net/centos-settings/centos7/firewalld-stop.html
http://www.unix-power.net/centos7/firewalld.html
http://dev.classmethod.jp/cloud/aws/centos7-initial-settings/
http://jetbeaver.hatenablog.com/entry/2015/05/10/114915
http://www.websec-room.com/2014/02/09/1822
http://server-setting.info/blog/sakura_vps_centos7_first_setup.html
http://qiita.com/sion_cojp/items/115e1671fcbc8f214aee
http://yokensaka.com/centos/?p=296
http://www.mk-mode.com/octopress/2014/08/07/centos-7-0-installation-of-chrootkit/
http://smiyasaka.com/CentOS7.0_64_minimal_server.html
http://ohkubo.info/modules/xpress/?p=94
http://enakai00.hatenablog.com/entry/20140712/1405139841
http://www.ksknet.net/vi/post_42.html
https://www.jdbc.tokyo/2014/11/centos7-chkrootkit-install/
http://blog.cles.jp/item/7262
http://techblog.clara.jp/2014/11/how-to-fail2ban/
http://qiita.com/umchifre/items/68a2db0b711ff676bb8d
http://yokensaka.com/centos/?p=490
http://yokensaka.com/centos/?p=301
http://hikaku-server.com/linux/entry460.html
http://yokensaka.com/centos/
http://www.unix-power.net/centos7/chronyd.html
http://www.unix-power.net/centos7/network.html
http://www.server-world.info/query?os=CentOS_7&p=hostname
http://server.etutsplus.com/centos-7-network-configuration/


●大まかな手順
1.初期設定
(1)作業用ユーザ追加
(2)root昇格ユーザ制限

2.ssh設定
(1)設定ファイル編集
(2)FireWall設定
(3)ssh再起動

3.OS関連セキュリティ強化
(1)不要サービス停止
(2)SELinux無効化

4.ネットワーク関連防御設定
(1)host.allowとhosts.denyファイルの修正
(2)カーネル設定

5.セキュリティツール導入
(1)logwatchインストール
(2)chkrootkitインストール
(3)改ざん検知ツールインストール
(4)Fail2banインストール
(5)Clamvインストール

6.その他ツール類インストール
(1)時刻同期ツール(Chrony)インストール
(2)SNMPインストール

7.最新パッチ適用

8.ホスト名設定、IPアドレス固定化

9:再起動


●実際の作業
1.初期設定
(1)作業用ユーザ追加
[root@centossrv ~]# useradd sshloginuser
[root@centossrv ~]# passwd sshloginuser
ユーザー sshloginuser のパスワードを変更。
新しいパスワード:
新しいパスワードを再入力してください:
passwd: すべての認証トークンが正しく更新できました。

(2)root昇格ユーザ制限
・whellグループに管理用ユーザ追加
[root@centossrv ~]# usermod -G wheel sshloginuser

・pam.dファイルの編集
[root@centossrv ~]#  vi /etc/pam.d/su

※下記の行のコメント解除
auth            required        pam_wheel.so use_uid


2.ssh設定
(1)設定ファイル編集
[root@centossrv ~]# vi /etc/ssh/sshd_config

※ポート番号を変更(XXXXX) Port22の箇所を変更
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
#
#Port 22
Port XXXXX
#AddressFamily any

※接続プロトコルをSSH2に限定(コメントアウトを外す)
# The default requires explicit activation of protocol 1
Protocol 2

※rootログインを制限する PermitRootLogin no を追記
#LoginGraceTime 2m
#PermitRootLogin yes
PermitRootLogin no
#StrictModes yes

※接続許可ユーザをssh接続ユーザにのみ限定(追記)
AllowUsers sshloginuser


(2)FireWall設定
・サービス停止
[root@centossrv ~]# systemctl stop firewalld
・sshポート番号変更設定
[root@centossrv ~]#  vi /etc/firewalld/services/ssh-alt.xml

※下記の内容でファイルを新規作成
  SSH
  Secure Shell (SSH) is a protocol for logging into and executing commands on remote machines. It provides secure encrypted communications. If you plan on accessing your machine remotely via SSH over a firewalled interface, enable this option. You need the openssh-server package installed for this option to be useful.
  
・設定の反映
[root@centossrv ~]#  systemctl start firewalld
[root@centossrv ~]# firewall-cmd --add-service=ssh-alt --zone=public
success
[root@centossrv ~]# firewall-cmd --add-service=ssh-alt --zone=public --permanent
success

・設定の確認
[root@centossrv ~]# firewall-cmd --reload
success
[root@centossrv ~]# firewall-cmd --list-all
public (default, active)
  interfaces: eth0
  sources:
  services: dhcpv6-client ssh ssh-alt
  ports:
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:

(3)ssh再起動
[root@centossrv ~]# service sshd restart
Redirecting to /bin/systemctl restart  sshd.service


※TeraTermでrootログインできないことを確認
※TeraTermで22番ポートに接続できないことを確認


3.OS関連セキュリティ強化
(1)不要サービス停止
・起動サービス確認
[root@centossrv ~]# systemctl list-unit-files --type service | grep enabled
auditd.service                              enabled
crond.service                               enabled
dbus-org.fedoraproject.FirewallD1.service   enabled
dbus-org.freedesktop.NetworkManager.service enabled
dbus-org.freedesktop.nm-dispatcher.service  enabled
firewalld.service                           enabled
getty@.service                              enabled
irqbalance.service                          enabled
kdump.service                               enabled
lvm2-monitor.service                        enabled
microcode.service                           enabled
NetworkManager-dispatcher.service           enabled
NetworkManager.service                      enabled
postfix.service                             enabled
rsyslog.service                             enabled
sshd.service                                enabled
systemd-readahead-collect.service           enabled
systemd-readahead-drop.service              enabled
systemd-readahead-replay.service            enabled
tuned.service                               enabled

・postfix停止
[root@centossrv ~]# systemctl stop postfix.service
[root@centossrv ~]# systemctl disable postfix.service
rm '/etc/systemd/system/multi-user.target.wants/postfix.service'

・停止確認
[root@centossrv ~]# systemctl status postfix.servicepostfix.service - Postfix Mail Transport Agent
postfix.servicepostfix.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)


-.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)


Postfix.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)


Mail.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)


Transport.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)


Agent.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)


(2)SELinux無効化
・設定
[root@centossrv ~]# getenforce
Enforcing
[root@centossrv ~]# setenforce 0
[root@centossrv ~]# getenforce
Permissive

・起動時のSELinux無効化
[root@centossrv ~]# vi /etc/sysconfig/selinux

※disabledを指定
#     disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled


4.ネットワーク関連防御設定
(1)host.allowとhosts.denyファイルの修正
[root@centossrv ~]# echo "ALL:192.168.1." >> /etc/hosts.allow
[root@centossrv ~]# echo "sshd:ALL" >> /etc/hosts.deny

(2)カーネル設定
・設定ファイル編集
[root@centossrv ~]# vi /etc/sysctl.conf

※以下の内容を追記
# IPV4でのネットワーク転送(0:無効)
net.ipv4.ip_forward = 0

# IPv4 ネットワークに対してデフォルトの RPF フィルタ設定を制御
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1

# SSRオプションのついたパケットの受け入れを可否
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.accept_source_route = 0

# Ctrl+ALT+SysReq+h にて、カーネル デバッグ コマンドを設定可否
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1

# SYN flood攻撃から守るための設定
net.ipv4.tcp_syncookies = 1

# Disable netfilter on bridges.
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0

# Controls the default maxmimum size of a mesage queue
kernel.msgmnb = 65536

# Controls the maximum size of a message, in bytes
kernel.msgmax = 65536

# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736

# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296

# ブロードキャスト宛のICMPパケットを無視
net.ipv4.icmp_echo_ignore_broadcasts= 1

#ICMP Redirectパケットを拒否
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0

#defaut gatewayに指定されたgatewayのみ、ICMP redirectパケットを拒否する
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0

#nmapなどでuptime(システムの連続稼働時間)を探られるのを防ぐ
net.ipv4.tcp_timestamps = 0

# ICMPエラーメッセージを無視
net.ipv4.icmp_ignore_bogus_error_responses = 1

#listen中のソケット当たりいくつ保持数
net.ipv4.tcp_max_syn_backlog = 1280

#すべてのインターフェイスですべての IPv4 ICMP リダイレクトパケットの受信を無効
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0

#偽装、ソースルーティング、リダイレクトされたパケットに関して、全てのログを取得する
net.ipv4.conf.all.log_martians = 1

# IPv6 無効化
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

・設定内容確認
[root@centossrv ~]# sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.all.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.tcp_timestamps = 0
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.tcp_max_syn_backlog = 1280
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.log_martians = 1
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1


5.セキュリティツール導入
(1)logwatchインストール
[root@centossrv ~]# yum -y install logwatch
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
~略~
完了しました!
[root@centossrv ~]#

(2)chkrootkitインストール
・不足するパッケージインストール
[root@centossrv ~]# yum -y install glibc-static
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
~略~
完了しました!
[root@centossrv ~]#

・wgetインストール
[root@centossrv ~]# yum -y install wget
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
~略~
完了しました!
[root@centossrv ~]#

・chkrootkitダウンロード
[root@centossrv ~]# wget ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
--2015-11-28 15:58:53--  ftp://ftp.pangeia.com.br/pub/seg/pac/chkrootkit.tar.gz
~略~
2015-11-28 15:58:59 (41.6 KB/s) - `chkrootkit.tar.gz' へ保存終了 [38616]

[root@centossrv ~]#

・アーカイブの展開と不要ファイル削除
[root@centossrv ~]# tar zxvf chkrootkit.tar.gz
chkrootkit-0.50
chkrootkit-0.50/chkproc.c
~略~
chkrootkit-0.50/ACKNOWLEDGMENTS
chkrootkit-0.50/chkrootkit
[root@centossrv ~]# mkdir -p ~/bin && mv chkrootkit-0.50/chkrootkit ~/bin
[root@centossrv ~]# rm -rf chkrootkit-0.50/
[root@centossrv ~]# rm -f chkrootkit.tar.gz

・net-tools対策(netstatコマンドが非推奨なので書替)
[root@centossrv ~]# vi ~/bin/chkrootkit


※下記コマンドでnetstatを置換
%s/netstat/ss/g

※Suckit誤検知の修正(下記赤字箇所を追記)
  then
  if [ "`md5sum ${ROOTDIR}sbin/init | cut -d ' ' -f 1`" = "`grep 'sbin/init$' /sbin/init | cut -d ' ' -f 1`" ]
then
  echo "Warning: ${ROOTDIR}sbin/init INFECTED"
fi
else
   if [ -d ${ROOTDIR}/dev/.golf ]; then

・動作確認
[root@centossrv ~]# ~/bin/chkrootkit | grep INFECTED
[root@centossrv ~]#


・定期自動実行ファイル作成
[root@centossrv ~]# vi /etc/cron.daily/chkrootkit

※下記の内容で新規作成
#!/bin/bash
PATH=/usr/bin:/bin:/root/bin
TMPLOG=`mktemp`

# chkrootkit実行
chkrootkit > $TMPLOG

# ログ出力
cat $TMPLOG | logger -t chkrootkit

# SMTPSのbindshell誤検知対応
if [ ! -z "$(grep 465 $TMPLOG)" ] && \
   [ -z $(/usr/sbin/lsof -i:465|grep bindshell) ]; then
        sed -i '/465/d' $TMPLOG
fi

# rootkit検知時のみroot宛メール送信
[ ! -z "$(grep INFECTED $TMPLOG)" ] && \
grep INFECTED $TMPLOG | mail -s "chkrootkit report in `hostname`" root

rm -f $TMPLOG

・権限付与
[root@centossrv ~]# chmod 700 /etc/cron.daily/chkrootkit

・コマンド退避(SCPでダウンロードしてCD-R等に退避)

[root@centossrv ~]# mkdir chkrootkitcmd
[root@centossrv ~]# cp `which --skip-alias awk cut echo egrep find head id ls netstat ps strings sed ssh uname` chkrootkitcmd/
/usr/bin/which: no netstat in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)
[root@centossrv ~]# tar -cvf chkrootkit.tar chkrootkitcmd
chkrootkitcmd/
chkrootkitcmd/awk
~略~
chkrootkitcmd/ssh
chkrootkitcmd/uname
[root@centossrv ~]# rm -rf chkrootkitcmd

(3)改ざん検知ツールインストール
・インストール
[root@centossrv ~]# yum -y install aide
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
~略~
完了しました!
[root@centossrv ~]#

・データベース初期化
[root@centossrv ~]# aide --init

AIDE, version 0.15.1

### AIDE database at /var/lib/aide/aide.db.new.gz initialized.

・初期DBファイル退避(ファイルはSCPでダウンロードしてCD-R等に退避)
[root@centossrv ~]# cp -p /var/lib/aide/aide.db.new.gz /var/lib/aide/aide.db.gz

・動作確認
[root@centossrv ~]# aide --check

AIDE, version 0.15.1

### All files match AIDE database. Looks okay!

・アップデート(時間がかかる)
[root@centossrv ~]# aide --update

AIDE, version 0.15.1

### All files match AIDE database. Looks okay!

### New AIDE database written to /var/lib/aide/aide.db.new.gz

・定期実行設定
[root@centossrv ~]# vi /etc/cron.daily/aide

※下記の内容で新規作成する。
#!/bin/bash
MAILTO=root
LOGFILE=/var/log/aide/aide.log
AIDEDIR=/var/lib/aide
/usr/sbin/aide  -u > $LOGFILE
cp $AIDEDIR/aide.db.new.gz $AIDEDIR/aide.db.gz
x=$(grep "Looks okay" $LOGFILE | wc -l)
if [ $x -eq 1 ]
then
  echo "All Systems Look OK" | /bin/mail -s "AIDE OK" $MAILTO
else
  echo "$(egrep "added|changed|removed" $LOGFILE)" | /bin/mail -s "AIDE DETECTED CHANGES" $MAILTO
fi
exit

・ファイルに権限付与
[root@centossrv ~]# chmod +x /etc/cron.daily/aide
[root@centossrv ~]# ls -al /etc/cron.daily/aide
-rwxr-xr-x 1 root root 390 11月 28 17:00 /etc/cron.daily/aide

・ログローテーション設定
[root@centossrv ~]# vi /etc/logrotate.d/aide

※下記の内容に修正
/var/log/aide/*.log {
        daily
        missingok
        rotate 7
        compress
        delaycompress
}

(4)Fail2banインストール
・インストール
[root@centossrv ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm を取得中
~略~
[root@centossrv ~]# yum install -y fail2ban
読み込んだプラグイン:fastestmirror
~略~
完了しました!
[root@centossrv ~]#

・起動(設定はひとまずデフォルトのままで)
[root@centossrv ~]# systemctl start fail2ban.service
[root@centossrv ~]# systemctl enable fail2ban.service
ln -s '/usr/lib/systemd/system/fail2ban.service' '/etc/systemd/system/multi-user.target.wants/fail2ban.service'

(5)Clamvインストール
・インストール
[root@centossrv ~]# yum --enablerepo=epel -y install clamav clamav-update
読み込んだプラグイン:fastestmirror
~略~
完了しました!
[root@centossrv ~]#


・ウイルス定義ファイル設定ファイルの編集
[root@centossrv ~]# vi /etc/freshclam.conf

※以下の内容で編集
# Comment or remove the line below.
#Example ←コメントアウト

# Path to the database directory.
# WARNING: It must match clamd.conf's directive!
# Default: hardcoded (depends on installation options)
DatabaseDirectory /var/lib/clamav ← コメントを解除

# Path to the log file (make sure it has proper permissions)
# Default: disabled
UpdateLogFile /var/log/freshclam.log ←コメントを解除

# By default when started freshclam drops privileges and switches to the
# "clamav" user. This directive allows you to change the database owner.
# Default: clamav (may depend on installation options)
DatabaseOwner clamupdate ←コメントを解除

# Uncomment the following line and replace XY with your country
# code. See http://www.iana.org/cctld/cctld-whois.htm for the full list.
# You can use db.XY.ipv6.clamav.net for IPv6 connections.
#DatabaseMirror db.XY.clamav.net
DatabaseMirror db.jp.clamav.net ←追記、データベース取得先を日本に設定


・Clam AntiVirus 設定変更

※以下の内容で編集
### !!!!! REMOVE ME !!!!!!
### REMOVE ME: By default, the freshclam update is disabled to avoid
### REMOVE ME: network access without prior activation
#FRESHCLAM_DELAY=disabled-warn  # REMOVE ME ←コメントアウト

・パターンファイル更新
[root@centossrv ~]# freshclam
ClamAV update process started at Sat Nov 28 17:13:35 2015
~略~
Database updated (4128441 signatures) from database.clamav.net (IP: 27.96.54.66)
[root@centossrv ~]#


・動作確認
[root@centossrv ~]# clamscan --infected --remove --recursive /etc/passwd

----------- SCAN SUMMARY -----------
Known viruses: 4183114
Engine version: 0.98.7
Scanned directories: 0
Scanned files: 1
Infected files: 0
Data scanned: 0.00 MB
Data read: 0.00 MB (ratio 0.00:1)
Time: 7.432 sec (0 m 7 s)


・定義ファイル更新、スキャンスクリプト作成
[root@centossrv ~]# vi /etc/cron.daily/clamscan.sh

※下記の内容で新規作成
#!/bin/bash
PATH=/usr/bin:/bin

# ウイルススキャン除外リスト設定
excludelist=/root/clamscan.exclude
if [ -s $excludelist ]; then
 for i in `cat $excludelist`
 do
  if [ $(echo "$i"|grep \/$) ]; then
   i=`echo $i|sed -e 's/^\([^ ]*\)\/$/\1/p' -e d`
   excludeopt="${excludeopt} --exclude-dir=$i"
  else
   excludeopt="${excludeopt} --exclude=$i"
  fi
 done
fi
# clamavをアップデート
yum -y update clamav > /dev/null 2>&1
# ウィルス定義ファイルを最新化
freshclam > /dev/null
# ウイルスに関するメッセージを入れる変数作成
CLAMSCANTMP=`mktemp`
# スキャン実行、ウイルスが有ったら削除、mktempで作成したファイルにメッセージを入れる
clamscan --recursive --remove ${excludeopt} / > $CLAMSCANTMP 2>&1
# ウイルスが有った場合メッセージをメール送信
[ ! -z "$(grep FOUND$ $CLAMSCANTMP)" ] && \
grep FOUND$ $CLAMSCANTMP | mail -s "Virus Found" hoge@example.com
# ウイルスが無く正しく動作している場合もメール送信
[ -z "$(grep FOUND$ $CLAMSCANTMP)" ] && \
echo "clamscan normal end" | mail -s "Virus Not Found" hoge@example.com
# メールを送ったらmktempで作成したファイルは破棄
rm -f $CLAMSCANTMP

・権限追加
[root@centossrv ~]# chmod 700 /etc/cron.daily/clamscan.sh

・スキャン除外を設定する
[root@centossrv ~]# echo "/proc/" >> clamscan.exclude
[root@centossrv ~]# echo "/sys/" >> clamscan.exclude
[root@centossrv ~]# echo "/backup/" >> clamscan.exclude
[root@centossrv ~]# echo "/home/share/" >> clamscan.exclude

・デフォルトのウィルス定義ファイルの自動最新化スクリプトを削除
[root@centossrv ~]# rm -f /etc/cron.d/clamav-update


6.その他ツール類インストール
(1)時刻同期ツール(Chrony)インストール
・インストール
[root@centossrv ~]# yum install chrony
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
~略~
完了しました!
[root@centossrv ~]#

・設定ファイル編集
[root@centossrv ~]# vi /etc/chrony.conf

※下記の箇所を修正(server0~server3までをコメントアウトしてその下3行を追記)
 iburstは起動直後にサーバに4回連続的に問い合わせをし時刻同期が早くなる
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server ntp1.jst.mfeed.ad.jp iburst
server ntp2.jst.mfeed.ad.jp iburst
server ntp3.jst.mfeed.ad.jp iburst

※下記の箇所を修正
NTPアクセス許可
# Allow NTP client access from local network.
allow 192.168/16 ←コメント解除

・再起動後に動作確認
[root@centossrv ~]# systemctl restart chronyd.service
[root@centossrv ~]# chronyc sources
210 Number of sources = 3
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^- ntp1.jst.mfeed.ad.jp          2   6    17    17  +1006us[+1006us] +/-   90ms
^* ntp2.jst.mfeed.ad.jp          2   6    17    17   -344us[ -689us] +/-   84ms
^+ ntp3.jst.mfeed.ad.jp          2   6    17    17  +1352us[+1352us] +/-  138ms


(2)SNMPインストール
・インストール
[root@centossrv ~]# yum -y install net-snmp net-snmp-utils
読み込んだプラグイン:fastestmirror
~略~
完了しました!
[root@centossrv ~]#

・動作確認
[root@centossrv ~]# systemctl start snmpd
[root@centossrv ~]#  snmpwalk -v 2c -c public localhost
SNMPv2-MIB::sysDescr.0 = STRING: Linux centossrv.tohonokai.
~略~
HOST-RESOURCES-MIB::hrSystemUptime.0 = No more variables left in this MIB View (It is past the end of the MIB tree)
[root@centossrv ~]#


7.最新パッチ適用
・yumで最新パッチ適用
[root@centossrv ~]# yum -y update
読み込んだプラグイン:fastestmirror
Loading mirror speeds from cached hostfile
~略~
  yum-plugin-fastestmirror.noarch 0:1.1.31-34.el7
  zlib.x86_64 0:1.2.7-15.el7
完了しました!
[root@centossrv ~]#

※ホスト名、IPアドレス変更前にイメージバックアップしておいた方がいい。


8.ホスト名設定、IPアドレス設定
・インタフェース確認
[root@centossrv ~]# nmcli d
デバイス  タイプ    状態      接続
eth0      ethernet  接続済み  eth0
lo        loopback  管理無し  --

・IPアドレス設定
[root@centossrv ~]# nmcli c modify eth0 ipv4.addresses XXX.XXX.X.XXX/24
[root@centossrv ~]# nmcli c modify eth0 ipv4.gateway XXX.XXX.X.XXX
[root@centossrv ~]# nmcli c modify eth0 ipv4.dns XXX.XXX.X.XXX
[root@centossrv ~]#  nmcli c modify eth0 ipv4.method manual
[root@centossrv ~]# nmcli c down eth0; nmcli c up eth0
Connection 'eth0' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/0)
接続が正常にアクティベートされました (D-Bus アクティブパス: /org/freedesktop/NetworkManager/ActiveConnection/1)

・設定確認
[root@centossrv ~]# nmcli d show eth0
GENERAL.デバイス:                       eth0
GENERAL.タイプ:                         ethernet
GENERAL.ハードウェアアドレス:           XX:XX:XX:XX:XX:XX
GENERAL.MTU:                            1500
GENERAL.状態:                           100 (接続済み)
GENERAL.接続:                           eth0
GENERAL.CON パス:                       /org/freedesktop/NetworkManager/ActiveConnection/1
WIRED-PROPERTIES.キャリア:              オン
IP4.アドレス[1]:                        XXX.XXX.X.XXX/24
IP4.ゲートウェイ:                       XXX.XXX.X.XXX
IP4.DNS[1]:                             XXX.XXX.X.XXX
IP6.アドレス[1]:                        XXXX:XXXX:XXXX:XXXX:XXXX:XXXX/64
IP6.ゲートウェイ:

・ホスト名設定
[root@centossrv ~]# hostnamectl set-hostname XXXX.XXXX.com
[root@centossrv ~]# hostnamectl
   Static hostname: XXXXX.XXXX.com
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 
           Boot ID: 
    Virtualization: microsoft
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.3.1.el7.x86_64
      Architecture: x86-64

・IPV6無効化
[root@websrv02 ~]# nmcli c mod eth0 ipv6.method ignore


9:再起動
[root@centossrv ~]# reboot

コメント

このブログの人気の投稿

証券外務員1種勉強(計算式暗記用メモ)

GASでGoogleDriveのサブフォルダとファイル一覧を出力する

マクロ経済学(IS-LM分析)