web-dev-qa-db-ja.com

sysctl -p /etc/sysctl.confは、1分後に元の設定に戻ります

Ubuntuの最小インストールは256MBのRAMを搭載したマシン用に作成されており、サーバーには32 GBがあるため、カーネルパラメーターを微調整する必要があります。私が抱えている問題は、コマンドsysctl -p /etc/sysctl.confを実行すると、サーバーが1分以内に元の設定に戻ることです。

root@mino /scripts/crons/tweaks # sysctl -p /etc/sysctl.conf
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.core.rmem_max = 12582912
net.core.rmem_default = 31457280
net.core.wmem_default = 31457280
net.core.wmem_max = 12582912
net.core.somaxconn = 4096
net.core.netdev_max_backlog = 65536
net.core.optmem_max = 25165824
net.ipv4.tcp_rfc1337 = 1
net.ipv4.ip_local_port_range = 2000 65535
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 65535
net.ipv4.tcp_sack = 0
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_max_tw_buckets = 1440000
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_challenge_ack_limit = 999999999
net.nf_conntrack_max = 10000000
net.netfilter.nf_conntrack_tcp_loose = 0
net.netfilter.nf_conntrack_max = 10000000
net.netfilter.nf_conntrack_tcp_timeout_close = 10
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 10
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 10
net.netfilter.nf_conntrack_tcp_timeout_last_ack = 10
net.netfilter.nf_conntrack_tcp_timeout_syn_recv = 10
net.netfilter.nf_conntrack_tcp_timeout_syn_sent = 10
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 10
net.netfilter.nf_conntrack_tcp_timeout_established = 10
net.ipv4.tcp_mem = 65536 131072 262144
net.ipv4.udp_mem = 65536 131072 262144
net.ipv4.tcp_rmem = 8192 87380 16777216
net.ipv4.udp_rmem_min = 16384
net.ipv4.tcp_wmem = 8192 65536 16777216
net.ipv4.udp_wmem_min = 16384
fs.file-max = 3500000

root@mino /scripts/crons/tweaks # /sbin/sysctl -a|grep -i nf_conntrack_max
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.em1.stable_secret"
sysctl: reading key "net.ipv6.conf.em2.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
net.netfilter.nf_conntrack_max = 10000000
net.nf_conntrack_max = 10000000

root@mino /scripts/crons/tweaks # date
Sat Jan 27 08:30:50 PST 2018

root@mino /scripts/crons/tweaks # date
Sat Jan 27 08:30:57 PST 2018

root@mino /scripts/crons/tweaks # date
Sat Jan 27 08:31:02 PST 2018

root@mino /scripts/crons/tweaks # /sbin/sysctl -a|grep -i nf_conntrack_max
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.em1.stable_secret"
sysctl: reading key "net.ipv6.conf.em2.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
net.netfilter.nf_conntrack_max = 10000000
net.nf_conntrack_max = 10000000

root@mino /scripts/crons/tweaks # date
Sat Jan 27 08:31:20 PST 2018

root@mino /scripts/crons/tweaks # /sbin/sysctl -a|grep -i nf_conntrack_max
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.em1.stable_secret"
sysctl: reading key "net.ipv6.conf.em2.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
net.netfilter.nf_conntrack_max = 65536
net.nf_conntrack_max = 65536

65536に設定されたnet.nf_conntrack_maxが低すぎるため、単純なsyn攻撃がファイアウォールをトリップし、すべてのパケットがドロップされます。かなり迷惑です。 /etc/rc.local fdileにも同じコマンドがあり、他のスレッドのdebian/ubuntuバグについて読んでいます。

Ubuntu 14.04 4.4.0-112の実行-ジェネリック#135-UbuntuSMP金1月19日11:48:36UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

私は次のサイトから調査を行いました。

sysctl.conf-高い同時性とセキュリティのための調整

多数の同時クライアントのLinuxカーネルチューニング設定

チューニングTCP Webプレゼンテーション用.pdf

1
Curious Sam

システムとその/etc/sysctl.confPuppetSaltStackAnsibleまたは他の同様の自動化ツールの制御下にあるファイル?

その場合、指定された構成を維持するために手動の変更を元に戻し続けるため、そのソフトウェアを使用して変更を加える必要があります。

1
telcoM

あなたの返事は私が答えを見つけるのを助けました。

APFファイアウォールとファイルを使用しています

/etc/apf/sysctl.rulesおよび/etc/apf/conf.apf

sYSCTL_CONNTRACKへの参照があります。これらが調整されると、すべてが魅力のように機能しました。

0
Curious Sam