[Previous] [Contents] [Index] [Next]

sysctl

Get or set the system state

Syntax:

sysctl [-n] name...

sysctl [-n] -w name=value...

sysctl [-n] -a|A

Options:

-a
List all the currently available string or integer values.
-A
List all the known MIB names including tables. Those with string or integer values are be printed with the -a flag; for the table values, the name of the utility to retrieve them is given.
-n
Suppress the printing of the field name and output only its value. This flag is also used for setting shell variables. For example, to save the IP TTL value in the variable ipttl:
set ipttl=`sysctl -n net.inet.ip.ttl`
      
-w
If just a MIB style name is given, the corresponding value is retrieved. To set a value specify: this flag, the MIB name followed by an equal sign, and the new value to be used.

Description:

The sysctl utility retrieves the system state and allows processes with appropriate privilege to set the system state. The state to be retrieved or set is described using a Management Information Base (MIB) stylename, described as a dotted set of components.

The information available from sysctl consists of integers and tables. The tabular information can only be retrieved by special purpose programs such as netstat and arp. The integer information is summarized below. For a detailed description of these variable see sysctl(). The changeable column indicates whether a process with appropriate privilege can change the value.

Name                             Type        Changeable

net.inet.ip.forwarding            integer    yes
net.inet.ip.redirect              integer    yes
net.inet.ip.ttl                   integer    yes
net.inet.ip.forwsrcrt             integer    yes
net.inet.ip.directed-broadcast    integer    yes
net.inet.ip.allowsrcrt            integer    yes
net.inet.ip.subnetsarelocal       integer    yes
net.inet.ip.mtudisc               integer    yes
net.inet.ip.maxfragpackets        integer    yes
net.inet.ip.sourcecheck           integer    yes
net.inet.ip.sourcecheck_logint    integer    yes
net.inet.icmp.maskrepl            integer    yes
net.inet.tcp.rfc1323              integer    yes
net.inet.tcp.sendspace            integer    yes
net.inet.tcp.recvspace            integer    yes
net.inet.tcp.mssdflt              integer    yes
net.inet.tcp.syn_cache_limit      integer    yes
net.inet.tcp.syn_bucket_limit     integer    yes
net.inet.tcp.syn_cache_interval   integer    yes
net.inet.udp.checksum             integer    yes
net.inet.udp.sendspace            integer    yes
net.inet.udp.recvspace            integer    yes

Examples:

Check to see if the UDP checksum is enabled:

sysctl net.inet.udp.checksum

Enable IP forwarding so that the host acts as a router:

sysctl -w net.inet.ip.forwarding=1

See also:

netstat

sysctl()


[Previous] [Contents] [Index] [Next]