さくらVPS 1G/SSD プラン - CentOS7 追加設定
初期設定以降の設定内容です。
ホスト名やIPアドレス情報は例示です。
ネットワーク設定
従来(CentOS6まで)のNetwork InitscriptとNetworkManagerのどちらで管理するかによって、使用するコマンド/設定内容が変わってきます。
デバイス構成によっては選択の余地が無い場合もありますので、要件を確認しておく必要があります。
ここではNetworkManagerを使用します。
ホスト名設定
# hostnamectl set-hostname hostname.example.jp $ nmcli g hostname hostname.example.jp
nf_conntrack_max拡張
nf_conntrack_maxの値は明示的に設定しない限りメモリサイズによって決められます。
サーバの使用用途に応じて値を確認/拡張します。
設定値の確認。
# cat /sys/module/nf_conntrack/parameters/hashsize 7940 # sysctl -n net.nf_conntrack_max 31760
拡張後。
# cat /sys/module/nf_conntrack/parameters/hashsize 32768 # sysctl -n net.nf_conntrack_max 262144
IPv6有効化
カーネルパラメータを変更し、リブートします。
--- a/sysctl.conf
+++ b/sysctl.conf
@@ -8,5 +8,5 @@ net.ipv6.conf.default.accept_ra=0
net.ipv6.conf.all.accept_ra=0
net.ipv6.conf.eth0.accept_ra=0
# Do not use IPv6
-net.ipv6.conf.all.disable_ipv6 = 1
-net.ipv6.conf.default.disable_ipv6 = 1
+#net.ipv6.conf.all.disable_ipv6 = 1
+#net.ipv6.conf.default.disable_ipv6 = 1
# reboot
或いはリブートの代替としてsysctlによる値の設定(要NetworkManagerのリスタート)も可能です。
現在の設定を確認します。
# nmcli -p con show
===========================================================================
NetworkManager connection profiles
===========================================================================
NAME UUID TYPE DEVICE
---------------------------------------------------------------------------
System eth0 abcxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 802-3-ethernet eth0
System eth1 defxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 802-3-ethernet --
System eth2 012xxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 802-3-ethernet --# nmcli -p con show "System eth0"
===============================================================================
Connection profile details (System eth0)
===============================================================================
connection.id: System eth0
connection.uuid: abcxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
connection.stable-id: --
connection.interface-name: eth0
connection.type: 802-3-ethernet
connection.autoconnect: yes
connection.autoconnect-priority: 0
connection.timestamp: 1400000000
connection.read-only: no
connection.permissions:
connection.zone: --
connection.master: --
connection.slave-type: --
connection.autoconnect-slaves: -1 (default)
connection.secondaries:
connection.gateway-ping-timeout: 0
connection.metered: unknown
connection.lldp: -1 (default)
-------------------------------------------------------------------------------
802-3-ethernet.port: --
802-3-ethernet.speed: 0
802-3-ethernet.duplex: --
802-3-ethernet.auto-negotiate: yes
802-3-ethernet.mac-address: --
802-3-ethernet.cloned-mac-address: --
802-3-ethernet.generate-mac-address-mask:--
802-3-ethernet.mac-address-blacklist:
802-3-ethernet.mtu: auto
802-3-ethernet.s390-subchannels:
802-3-ethernet.s390-nettype: --
802-3-ethernet.s390-options:
802-3-ethernet.wake-on-lan: 1 (default)
802-3-ethernet.wake-on-lan-password: --
-------------------------------------------------------------------------------
ipv4.method: manual
ipv4.dns: 203.0.113.1,203.0.113.2
ipv4.dns-search:
ipv4.dns-options: (default)
ipv4.dns-priority: 0
ipv4.addresses: 192.0.2.2/24
ipv4.gateway: 192.0.2.1
ipv4.routes:
ipv4.route-metric: -1
ipv4.ignore-auto-routes: no
ipv4.ignore-auto-dns: no
ipv4.dhcp-client-id: --
ipv4.dhcp-timeout: 0
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.dhcp-fqdn: --
ipv4.never-default: no
ipv4.may-fail: yes
ipv4.dad-timeout: -1 (default)
-------------------------------------------------------------------------------
ipv6.method: ignore
ipv6.dns:
ipv6.dns-search:
ipv6.dns-options: (default)
ipv6.dns-priority: 0
ipv6.addresses:
ipv6.gateway: --
ipv6.routes:
ipv6.route-metric: -1
ipv6.ignore-auto-routes: no
ipv6.ignore-auto-dns: no
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: -1 (unknown)
ipv6.addr-gen-mode: stable-privacy
ipv6.dhcp-send-hostname: yes
ipv6.dhcp-hostname: --
ipv6.token: --
-------------------------------------------------------------------------------
===============================================================================
Activate connection details (abcxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
===============================================================================
GENERAL.NAME: System eth0
GENERAL.UUID: abcxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
GENERAL.DEVICES: eth0
GENERAL.STATE: activated
GENERAL.DEFAULT: yes
GENERAL.DEFAULT6: no
GENERAL.VPN: no
GENERAL.ZONE: --
GENERAL.DBUS-PATH: /org/freedesktop/NetworkManager/ActiveConnection/0
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/Settings/0
GENERAL.SPEC-OBJECT: /
GENERAL.MASTER-PATH: --
-------------------------------------------------------------------------------
IP4.ADDRESS[1]: 192.0.2.2/24
IP4.GATEWAY: 192.0.2.1
IP4.DNS[1]: 203.0.113.1
IP4.DNS[2]: 203.0.113.2
-------------------------------------------------------------------------------
IP6.GATEWAY:
-------------------------------------------------------------------------------IPv6設定を行います。
# nmcli con mod "System eth0" ipv6.method auto # nmcli con mod "System eth0" ipv6.address "2001:db8::2/64" # nmcli con mod "System eth0" ipv6.gateway "fe80::1" # nmcli con mod "System eth0" ipv6.dns "2001:db8::53" # nmcli con mod "System eth0" ipv6.method manual
IPv4/IPv6ともにDHCPを使用しないので、関連項目を明示的に無効化します。
# nmcli con mod "System eth0" ipv4.ignore-auto-routes yes # nmcli con mod "System eth0" ipv4.ignore-auto-dns yes # nmcli con mod "System eth0" ipv6.ignore-auto-routes yes # nmcli con mod "System eth0" ipv6.ignore-auto-dns yes
設定を反映します。
nmcli con up "System eth0"
設定内容を確認します。
# nmcli -p con show "System eth0"
===============================================================================
Connection profile details (System eth0)
===============================================================================
connection.id: System eth0
(...中略...)
ipv4.ignore-auto-routes: yes
ipv4.ignore-auto-dns: yes
ipv4.dhcp-client-id: --
ipv4.dhcp-timeout: 0
ipv4.dhcp-send-hostname: yes
ipv4.dhcp-hostname: --
ipv4.dhcp-fqdn: --
ipv4.never-default: no
ipv4.may-fail: yes
ipv4.dad-timeout: -1 (default)
-------------------------------------------------------------------------------
ipv6.method: manual
ipv6.dns: 2001:db8::53
ipv6.dns-search:
ipv6.dns-options: (default)
ipv6.dns-priority: 0
ipv6.addresses: 2001:db8::2/64
ipv6.gateway: fe80::1
ipv6.routes:
ipv6.route-metric: -1
ipv6.ignore-auto-routes: yes
ipv6.ignore-auto-dns: yes
ipv6.never-default: no
ipv6.may-fail: yes
ipv6.ip6-privacy: -1 (unknown)
ipv6.addr-gen-mode: stable-privacy
ipv6.dhcp-send-hostname: yes
ipv6.dhcp-hostname: --
ipv6.token: --
-------------------------------------------------------------------------------
===============================================================================
Activate connection details (abcxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)
===============================================================================
(...中略...)
-------------------------------------------------------------------------------
IP6.ADDRESS[1]: 2001:db8::2/64
IP6.ADDRESS[2]: fe80::2/64
IP6.GATEWAY: fe80::1
IP6.DNS[1]: 2001:db8::53
-------------------------------------------------------------------------------# cat /etc/resolv.conf # Generated by NetworkManager search example.jp nameserver 203.0.113.1 nameserver 203.0.113.2 nameserver 2001:db8::53
IPv6ネットワークに関するfirewalld設定は、特に明示的に指定していない限り、IPv4と同じ設定が施されています。
内容を確認し、必要に応じて加除修正します。
# ip6tables -L -nv ...
プライベートネットワーク構築
さくらのVPSでは、仮想スイッチを作成し、同一リージョン内の仮想マシン間でプライベートネットワークを構成することが可能です。
仮想スイッチの作成/適用には仮想マシンの停止が必要になるので、予め設定しておきます。
ここではeth1を使用したプライベートネットワークを構築します。
インターフェースアドレス設定。
# nmcli con mod "System eth1" ipv4.method auto # nmcli con mod "System eth1" ipv4.address "198.51.100.1/24" # nmcli con mod "System eth1" ipv4.method manual # nmcli con mod "System eth1" ipv4.never-default yes # nmcli con mod "System eth1" ipv4.ignore-auto-routes yes # nmcli con mod "System eth1" ipv4.ignore-auto-dns yes # nmcli con up "System eth1"
firewalldを設定します。
デフォルトではpublicが適用されているので、適切なフィルタに変更します。
# firewall-cmd --get-default-zone public # firewall-cmd --get-active-zones public interfaces: eth0 eth1
firewalldで使用可能なゾーン名/サービス名を確認。
$ firewall-cmd --list-all-zones $ firewall-cmd --get-services
仮想スイッチ下のサーバ間でもフィルタを適用したい場合はhome/work辺りのフィルタを適用/修正すると良いでしょう。
ここでは、信頼できるネットワークとしてtrustedを適用します。
# firewall-cmd --change-interface=eth1 --zone=trusted --permanent # firewall-cmd --reload
# firewall-cmd --get-active-zones public interfaces: eth0 trusted interfaces: eth1
yum-cron
自動的にパッケージ更新を行うようにします。
# yum install yum-cron ... ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: yum-cron noarch 3.4.3-150.el7.centos base 61 k Transaction Summary ================================================================================ Install 1 Package Total download size: 61 k Installed size: 51 k
--- a/yum/yum-cron.conf
+++ b/yum/yum-cron.conf
@@ -17,7 +17,7 @@ download_updates = yes
# Whether updates should be applied when they are available. Note
# that download_updates must also be yes for the update to be applied.
-apply_updates = no
+apply_updates = yes
# Maximum amout of time to randomly sleep, in minutes. The program
# will sleep for a random amount of time between 0 and random_sleep
# systemctl start yum-cron # systemctl enable yum-cron