sysctl.conf 在重启后失效

sysctl.conf 在重启后失效

我的 /etc/sysctl.conf 中列出了几个选项,但由于某种原因,它们在重启后无法继续使用。我主要通过每次启动时网络接口上的 ipv6 是否处于活动状态来衡量这一点,尽管我在 sysctl.conf 中的所有接口上都禁用了它。我检查了 sysctl.d 中的其他配置,但其中的文件似乎没有做任何事情来改变我在 sysctl.conf 中的设置。

/etc/sysctl.d/*

-rw-r--r-- 1 root root   77 Feb 27  2020 10-console-messages.conf
-rw-r--r-- 1 root root  761 Nov 16 16:54 10-kernel-hardening.conf
-rw-r--r-- 1 root root  257 Feb 27  2020 10-link-restrictions.conf
-rw-r--r-- 1 root root 1184 Feb 27  2020 10-magic-sysrq.conf
-rw-r--r-- 1 root root 1292 Feb 27  2020 10-ptrace.conf
-rw-r--r-- 1 root root  506 Feb 27  2020 10-zeropage.conf
lrwxrwxrwx 1 root root   14 Oct  8 15:14 99-sysctl.conf -> ../sysctl.conf
-rw-r--r-- 1 root root  792 Feb 13  2020 README.sysctl

/etc/sysctl.conf

#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
#

# Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1

# Spoof protection (reverse-path filter). Source Address Verification in all interfaces
net.ipv4.conf.default.rp_filter=1
net.ipv4.conf.all.rp_filter=1
net.ipv4.tcp_max_syn_backlog = 2048
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 5

# Do not accept ICMP redirects (prevent MITM attacks)
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1

# Do not send ICMP redirects (we are not a router)
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.icmp_echo_ignore_all = 1

# Do not accept IP source route packets (we are not a router)
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0

# Log Martian Packets
net.ipv4.conf.all.log_martians = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1

$ cat /etc/sysctl.d/10-*.conf | egrep -v #

kernel.printk = 4 4 1 7
kernel.kptr_restrict = 1
fs.protected_hardlinks = 1
fs.protected_symlinks = 1
kernel.sysrq = 176
kernel.yama.ptrace_scope = 1
vm.mmap_min_addr = 65536

答案1

我不确定这里的问题是什么,但我禁用并删除了网络管理器,现在 sysctl 设置已正确应用。

相关内容