LoginSignup
13

More than 5 years have passed since last update.

CentOS 6 でも /etc/sysctl.d/ は使える(ipv6 無効化とか)

Last updated at Posted at 2015-02-22

CentOS 6 で ipv6 を無効にするときは /etc/sysctl.conf に下記を追記します。

/etc/sysctl.conf

# ipv6 disable
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

FAQ/CentOS6 - CentOS Wiki

一方、CentOS 7 なら /etc/sysctl.d/ というディレクトリがあるので、sysctl.conf を変更せずに、/etc/sysctl.d/ に変更分のファイルを作成する方が良いでしょう。

と、思ったら CentOS 6 でも /etc/sysctl.d/ は有効でした。

CentOS • View topic - [RESOLVED] Is /etc/sysctl.d/ supported in CentOS 6?

$ grep -A 10 apply_sysctl /etc/init.d/functions
apply_sysctl() {
    sysctl -e -p /etc/sysctl.conf >/dev/null 2>&1
    for file in /etc/sysctl.d/* ; do
        is_ignored_file "$file" && continue
        test -f "$file" && sysctl -e -p "$file" >/dev/null 2>&1
    done
}

というわけで、CentOS 6 でも /etc/sysctl.d/ に変更分だけ追加でファイルを作成する方が良いでしょう。

/etc/sysctl.d/ipv6-disable.conf

# ipv6 disable
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

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
13