sysctl设置和显示在/proc/sys目录中的内核参数.能用sysctl来设置或重新设置连网功能,如IP转发、IP碎片去除及源路由检查等。用户只需要编辑/etc/sysctl.conf文件,即可手工或自动执行由sysctl控制的功能。
命令格式:
Shell代码
1.sysctl [-n] [-e] -w variable=value
2.sysctl [-n] [-e] -p (default /etc/sysctl.conf)
3.sysctl [-n] [-e] -a
sysctl [-n] [-e] -w variable=value
sysctl [-n] [-e] -p (default /etc/sysctl.conf)
sysctl [-n] [-e] -a
常用参数的意义:
-w 临时改动某个指定参数的值,如
sysctl -w net.ipv4.ip_forward=1
-a 显示所有的系统参数
-p 从指定的文件加载系统参数,如不指定即从/etc/sysctl.conf中加载
如果仅仅是想临时改动某个系统参数的值,能用两种方法来实现,例如想启用IP路由转发功能:
1) #echo 1 > /proc/sys/net/ipv4/ip_forward
2) #sysctl -w net.ipv4.ip_forward=1
以上两种方法都可能即时开启路由功能,但如果系统重启,或执行了
# service network restart
命令,所设置的值即会丢失,如果想永久保留设置,能修改/etc/sysctl.conf文件
将 net.ipv4.ip_forward=0改为net.ipv4.ip_forward=1
Shell代码
1.**********************
2.sysctl man page
3.NAME
4.sysctl - configure kernel parameters at runtime
5.SYNOPSIS
6.sysctl [-n] [-e] variable ...
7.sysctl [-n] [-e] [-q] -w variable=value ...
8.sysctl [-n] [-e] [-q] -p
9.sysctl [-n] [-e] -a
10.sysctl [-n] [-e] -A
11.DESCRIPTION
12.sysctl is used to modify kernel parameters at runtime. The parameters
13.available are those listed under /proc/sys/. Procfs is required for
14.sysctl(8) support in Linux. You can use sysctl(8) to both read and
15.write sysctl data.
16.PARAMETERS
17.variable
18.The name of a key to read from. An example is kernel.ostype.
19.The ’/’ separator is also accepted in place of a ’.’.
20.variable=value
21.To set a key, use the form variable=value, where variable is the
22.key and value is the value to set it to. If the value contains
23.quotes or characters which are parsed by the shell, you may need
24.to enclose the value in double quotes. This requires the -w
25.parameter to use.
26.-n Use this option to disable printing of the key name when print-
27.ing values.
28.-e Use this option to ignore errors about unknown keys.
29.-N Use this option to only print the names. It may be useful with
30.shells that have programmable completion.
31.-q Use this option to not display the values set to stdout.
32.-w Use this option when you want to change a sysctl setting.
33.-p Load in sysctl settings from the file specified or
34./etc/sysctl.conf if none given. Specifying - as filename means
35.reading data from standard input.
36.-a Display all values currently available.
37.-A Display all values currently available in table form.
38.EXAMPLES
39./sbin/sysctl -a
40./sbin/sysctl -n kernel.hostname
41./sbin/sysctl -w kernel.domainname="example.com"
42./sbin/sysctl -p /etc/sysctl.conf
43.FILES
44./proc/sys /etc/sysctl.conf
45.SEE ALSO
46.sysctl.conf(5)
47.BUGS
48.The -A parameter behaves just as -a does.
49.AUTHOR
50.George Staikos,
51.21 Sep 1999 SYSCTL(8)
命令格式:
Shell代码
1.sysctl [-n] [-e] -w variable=value
2.sysctl [-n] [-e] -p (default /etc/sysctl.conf)
3.sysctl [-n] [-e] -a
sysctl [-n] [-e] -w variable=value
sysctl [-n] [-e] -p (default /etc/sysctl.conf)
sysctl [-n] [-e] -a
常用参数的意义:
-w 临时改动某个指定参数的值,如
sysctl -w net.ipv4.ip_forward=1
-a 显示所有的系统参数
-p 从指定的文件加载系统参数,如不指定即从/etc/sysctl.conf中加载
如果仅仅是想临时改动某个系统参数的值,能用两种方法来实现,例如想启用IP路由转发功能:
1) #echo 1 > /proc/sys/net/ipv4/ip_forward
2) #sysctl -w net.ipv4.ip_forward=1
以上两种方法都可能即时开启路由功能,但如果系统重启,或执行了
# service network restart
命令,所设置的值即会丢失,如果想永久保留设置,能修改/etc/sysctl.conf文件
将 net.ipv4.ip_forward=0改为net.ipv4.ip_forward=1
Shell代码
1.**********************
2.sysctl man page
3.NAME
4.sysctl - configure kernel parameters at runtime
5.SYNOPSIS
6.sysctl [-n] [-e] variable ...
7.sysctl [-n] [-e] [-q] -w variable=value ...
8.sysctl [-n] [-e] [-q] -p
9.sysctl [-n] [-e] -a
10.sysctl [-n] [-e] -A
11.DESCRIPTION
12.sysctl is used to modify kernel parameters at runtime. The parameters
13.available are those listed under /proc/sys/. Procfs is required for
14.sysctl(8) support in Linux. You can use sysctl(8) to both read and
15.write sysctl data.
16.PARAMETERS
17.variable
18.The name of a key to read from. An example is kernel.ostype.
19.The ’/’ separator is also accepted in place of a ’.’.
20.variable=value
21.To set a key, use the form variable=value, where variable is the
22.key and value is the value to set it to. If the value contains
23.quotes or characters which are parsed by the shell, you may need
24.to enclose the value in double quotes. This requires the -w
25.parameter to use.
26.-n Use this option to disable printing of the key name when print-
27.ing values.
28.-e Use this option to ignore errors about unknown keys.
29.-N Use this option to only print the names. It may be useful with
30.shells that have programmable completion.
31.-q Use this option to not display the values set to stdout.
32.-w Use this option when you want to change a sysctl setting.
33.-p Load in sysctl settings from the file specified or
34./etc/sysctl.conf if none given. Specifying - as filename means
35.reading data from standard input.
36.-a Display all values currently available.
37.-A Display all values currently available in table form.
38.EXAMPLES
39./sbin/sysctl -a
40./sbin/sysctl -n kernel.hostname
41./sbin/sysctl -w kernel.domainname="example.com"
42./sbin/sysctl -p /etc/sysctl.conf
43.FILES
44./proc/sys /etc/sysctl.conf
45.SEE ALSO
46.sysctl.conf(5)
47.BUGS
48.The -A parameter behaves just as -a does.
49.AUTHOR
50.George Staikos,
51.21 Sep 1999 SYSCTL(8)