11.1.1. Using "cat" and "echo"
Using "cat" and "echo" is the simplest way to access the /proc filesystem, but some requirements are needed for that
# mount | grep "type proc"
none on /proc type proc (rw)
Normally, only entries in /proc/sys/* are writable, the others are readonly and for information retrieving only.
22.214.171.124. Retrieving a value
The value of an entry can be retrieved using "cat":
# cat /proc/sys/net/ipv6/conf/all/forwarding
126.96.36.199. Setting a value
A new value can be set (if entry is writable) using "echo":
# echo "1" >/proc/sys/net/ipv6/conf/all/forwarding
11.1.2. Using "sysctl"
Using the "sysctl" program to access the kernel switches is a modern method today. You can use it also, if the /proc-filesystem isn't mounted. But you have only access to /proc/sys/*!
The program "sysctl" is included in package "procps" (on Red Hat Linux systems).
188.8.131.52. Retrieving a value
The value of an entry can be retrieved now:
# sysctl net.ipv6.conf.all.forwarding
net.ipv6.conf.all.forwarding = 0
184.108.40.206. Setting a value
A new value can be set (if entry is writable):
# sysctl -w net.ipv6.conf.all.forwarding=1
net.ipv6.conf.all.forwarding = 1
Note: Don't use spaces around the "=" on setting values. Also on multiple values per line, quote them like e.g.
# sysctl -w net.ipv4.ip_local_port_range="32768 61000"
net.ipv4.ip_local_port_range = 32768 61000
Note: There are sysctl versions in the wild which displaying "/" instead of the "."
For more details take a look into sysctl's manpage.
Hint: for digging fast into the settings, use the option "-a" (display all entries) in conjunction with "grep".