According to the following test, it seems that net.ipv4.icmp_echo_ignore_all
and /proc/sys/net/ipv4/icmp_echo_ignore_all
are exactly the same. Are they exactly the same? If so, which way is the best to use?
$ 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
Yes, see
man sysctl
(emphasis mine):It depends on what you want to do. For one-off changes, I suppose it makes no difference. For maintaining a configuration,
/etc/sysctl.conf
and/etc/sysctl.d
are much more convenient.