CentOS 7をインストール後に行う最低限の初期設定について解説したいと思います。
各環境によって必要な設定は変わってきますので、参考にしてみてください。
ファイアーウォールの設定
今回は自宅内でLinuxサーバーを構築するということですので、プロバイダのルーター機能付きモデムや市販のルーターを使っている場合を例にここでの設定を行います。
CentOSをインストール後にはファイアウォールが機能しています。
とりあえずこれからサーバーを構築するという段階なので、必要な通信を遮断してしまうという事態を避けるためにファイアーウォールの機能を無効にします。
※ルーター内にサーバーマシンがあるので、ファイアーウォールはルーターについているものを使うことで補えます。
CentOS7でのファイアーウォール機能はiptablesからfirewalldに変更されています。
systemctl stop firewalldsystemctl disable firewalld
SELinuxの設定
続いてはSELinuxの機能も無効化します。
SELinux(Security-Enhanced Linux)とは Linux システムのセキュリティー機能を高めるためのカーネルモジュールです。
SELinuxを扱うにためには高度な技術が必要なので、ファイアーウォールと同様にサーバーを構築する段階ではを無効にしておきましょう。
SELinuxを無効にするには以下のように実行します。
setenforce 0
サーバーが再起動したときもSELinuxが無効になるように以下のように設定します。
vi /etc/selinux/config
# This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. # enforcingをdisabledに変更 #SELINUX=enforcing SELINUX=disabled # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted
rootユーザー宛メールの設定
最後に以下の設定も済ましておきましょう。
サーバーからrootユーザー宛にシステムに関する重要なメールが送られてきます。
rootユーザー宛メールを常用しているメールアドレスに転送する設定を行います。
vi /etc/aliases
# # Aliases in this file will NOT be expanded in the header from # Mail, but WILL be visible over networks or from /bin/mail. # # >>>>>>>>>> The program "newaliases" must be run after # >> NOTE >> this file is updated for any changes to # >>>>>>>>>> show through to sendmail. # # Basic system aliases -- these MUST be present. mailer-daemon: postmaster postmaster: root # General redirections for pseudo accounts. bin: root daemon: root adm: root lp: root sync: root shutdown: root halt: root mail: root news: root uucp: root operator: root games: root gopher: root ftp: root nobody: root radiusd: root nut: root dbus: root vcsa: root canna: root wnn: root rpm: root nscd: root pcap: root apache: root webalizer: root dovecot: root fax: root quagga: root radvd: root pvm: root amanda: root privoxy: root ident: root named: root xfs: root gdm: root mailnull: root postgres: root sshd: root smmsp: root postfix: root netdump: root ldap: root squid: root ntp: root mysql: root desktop: root rpcuser: root rpc: root nfsnobody: root ingres: root system: root toor: root manager: root dumper: root abuse: root newsadm: news newsadmin: news usenet: news ftpadm: ftp ftpadmin: ftp ftp-adm: ftp ftp-admin: ftp www: webmaster webmaster: root noc: root security: root hostmaster: root info: postmaster marketing: postmaster sales: postmaster support: postmaster # trap decode to catch security attacks decode: root # Person who should get root's mail #root: marc # 一番最後の行に送信するメールアドレスを追加 root: admin@astermark.com
以下のコマンドを実行して設定を反映します。
newaliases
コメント