Penguin

How to Edit Kernel Parameters During Runtime

List all available kernel parameters and their values:

Note : They are all listed under /proc/sys

  • sysctl -a

Modify the value of a kernel parameter:

  • sysctl -w variable=value

For example say I do not want my host to respond to pings (note that this is recommended): This can be done by telling the kernel to ignore all ICMP ECHO_REQUEST's

  • sysctl -w net.ipv4.icmp_echo_ignore_all=1

OR

  • sysctl -w net/ipv4/icmp_echo_ignore_all=1

Notes :

1. Setting this variable to 1 (or anything other than 0) will make the kernel ignore ICMP echo request's.

2. The 'net.ipv4.icmp_echo_ignore_all' part above specifies the path inside /proc/sys/ to the file corresponding to the kernel parameter. If you use cat to take a look inside this file you will see that all in contains is '1' (the value of the kernel variable)

If you want to save these in a file it's usually in /etc/sysctl.conf (see sysctl.conf(5))

There is also another filesystem full of kernel parameters in called SysFs, normally mounted at /sys. SysFs has more details.


CategoryNotes


See also sysctl(8), sysctl(2), SysControls, SysFs