根据以下测试,看起来net.ipv4.icmp_echo_ignore_all
和/proc/sys/net/ipv4/icmp_echo_ignore_all
完全相同。它们完全相同吗?如果是,哪种方法最好用?
$ sudo sysctl -w net.ipv4.icmp_echo_ignore_all=1
net.ipv4.icmp_echo_ignore_all = 1
$ cat /proc/sys/net/ipv4/icmp_echo_ignore_all
1
$ sudo tee /proc/sys/net/ipv4/icmp_echo_ignore_all <<< 0
0
$ sysctl net.ipv4.icmp_echo_ignore_all
net.ipv4.icmp_echo_ignore_all = 0
答案1
是的,明白man sysctl
(重点是我的):
sysctl is used to modify kernel parameters at runtime. The parameters available are those
listed under /proc/sys/. Procfs is required for sysctl support in Linux. You can use
sysctl to both read and write sysctl data.
这取决于你想做什么。对于一次性更改,我想没什么区别。对于维护配置,/etc/sysctl.conf
和/etc/sysctl.d
要方便得多。