sysctl.conf的配置

本文详细介绍了sysctl.conf文件中的各项参数设置,包括网络配置、内存管理、文件系统等核心内容,为系统管理员提供了深入理解并优化Linux系统性能的基础。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

sysctl.conf 是由/etc/rc.d/rc.sysinit在系统初始化是调用的参数列表。
下面的参数列表可以通过sysctl -a输出


abi.fake_utsname = 0
abi.trace = 0
abi.defhandler_libcso = 68157441
abi.defhandler_lcall7 = 68157441
abi.defhandler_elf = 0
abi.defhandler_coff = 117440515
dev.raid.speed_limit_max = 100000
dev.raid.speed_limit_min = 100
net.unix.max_dgram_qlen = 10
net.token-ring.rif_timeout = 60000
net.ipv4.conf.eth0.arp_filter = 0
net.ipv4.conf.eth0.tag = 0
net.ipv4.conf.eth0.log_martians = 0
net.ipv4.conf.eth0.bootp_relay = 0
net.ipv4.conf.eth0.proxy_arp = 0
net.ipv4.conf.eth0.accept_source_route = 1
net.ipv4.conf.eth0.send_redirects = 1
net.ipv4.conf.eth0.rp_filter = 1
net.ipv4.conf.eth0.shared_media = 1
net.ipv4.conf.eth0.secure_redirects = 1
net.ipv4.conf.eth0.accept_redirects = 1
net.ipv4.conf.eth0.mc_forwarding = 0
net.ipv4.conf.eth0.forwarding = 0
net.ipv4.conf.lo.arp_filter = 0
net.ipv4.conf.lo.tag = 0
net.ipv4.conf.lo.log_martians = 0
net.ipv4.conf.lo.bootp_relay = 0
net.ipv4.conf.lo.proxy_arp = 0
net.ipv4.conf.lo.accept_source_route = 1
net.ipv4.conf.lo.send_redirects = 1
net.ipv4.conf.lo.rp_filter = 1
net.ipv4.conf.lo.shared_media = 1
net.ipv4.conf.lo.secure_redirects = 1
net.ipv4.conf.lo.accept_redirects = 1
net.ipv4.conf.lo.mc_forwarding = 0
net.ipv4.conf.lo.forwarding = 0
net.ipv4.conf.default.arp_filter = 0
net.ipv4.conf.default.tag = 0
net.ipv4.conf.default.log_martians = 0
net.ipv4.conf.default.bootp_relay = 0
net.ipv4.conf.default.proxy_arp = 0
net.ipv4.conf.default.accept_source_route = 1
net.ipv4.conf.default.send_redirects = 1
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.shared_media = 1
net.ipv4.conf.default.secure_redirects = 1
net.ipv4.conf.default.accept_redirects = 1
net.ipv4.conf.default.mc_forwarding = 0
net.ipv4.conf.default.forwarding = 0
net.ipv4.conf.all.arp_filter = 0
net.ipv4.conf.all.tag = 0
net.ipv4.conf.all.log_martians = 0
net.ipv4.conf.all.bootp_relay = 0
net.ipv4.conf.all.proxy_arp = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.all.send_redirects = 1
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.all.shared_media = 1
net.ipv4.conf.all.secure_redirects = 1
net.ipv4.conf.all.accept_redirects = 1
net.ipv4.conf.all.mc_forwarding = 0
net.ipv4.conf.all.forwarding = 0
net.ipv4.neigh.eth0.locktime = 100
net.ipv4.neigh.eth0.proxy_delay = 80
net.ipv4.neigh.eth0.anycast_delay = 100
net.ipv4.neigh.eth0.proxy_qlen = 64
net.ipv4.neigh.eth0.unres_qlen = 3
net.ipv4.neigh.eth0.gc_stale_time = 60
net.ipv4.neigh.eth0.delay_first_probe_time = 5
net.ipv4.neigh.eth0.base_reachable_time = 30
net.ipv4.neigh.eth0.retrans_time = 100
net.ipv4.neigh.eth0.app_solicit = 0
net.ipv4.neigh.eth0.ucast_solicit = 3
net.ipv4.neigh.eth0.mcast_solicit = 3
net.ipv4.neigh.lo.locktime = 100
net.ipv4.neigh.lo.proxy_delay = 80
net.ipv4.neigh.lo.anycast_delay = 100
net.ipv4.neigh.lo.proxy_qlen = 64
net.ipv4.neigh.lo.unres_qlen = 3
net.ipv4.neigh.lo.gc_stale_time = 60
net.ipv4.neigh.lo.delay_first_probe_time = 5
net.ipv4.neigh.lo.base_reachable_time = 30
net.ipv4.neigh.lo.retrans_time = 100
net.ipv4.neigh.lo.app_solicit = 0
net.ipv4.neigh.lo.ucast_solicit = 3
net.ipv4.neigh.lo.mcast_solicit = 3
net.ipv4.neigh.default.gc_thresh3 = 1024
net.ipv4.neigh.default.gc_thresh2 = 512
net.ipv4.neigh.default.gc_thresh1 = 128
net.ipv4.neigh.default.gc_interval = 30
net.ipv4.neigh.default.locktime = 100
net.ipv4.neigh.default.proxy_delay = 80
net.ipv4.neigh.default.anycast_delay = 100
net.ipv4.neigh.default.proxy_qlen = 64
net.ipv4.neigh.default.unres_qlen = 3
net.ipv4.neigh.default.gc_stale_time = 60
net.ipv4.neigh.default.delay_first_probe_time = 5
net.ipv4.neigh.default.base_reachable_time = 30
net.ipv4.neigh.default.retrans_time = 100
net.ipv4.neigh.default.app_solicit = 0
net.ipv4.neigh.default.ucast_solicit = 3
net.ipv4.neigh.default.mcast_solicit = 3
net.ipv4.icmp_ratemask = 6168
net.ipv4.icmp_ratelimit = 100
net.ipv4.tcp_adv_win_scale = 2
net.ipv4.tcp_app_win = 31
net.ipv4.tcp_rmem = 4096    87380    174760
net.ipv4.tcp_wmem = 4096    16384    131072
net.ipv4.tcp_mem = 48128    48640    49152
net.ipv4.tcp_dsack = 1
net.ipv4.tcp_ecn = 0
net.ipv4.tcp_reordering = 3
net.ipv4.tcp_fack = 1
net.ipv4.tcp_orphan_retries = 0
net.ipv4.inet_peer_gc_maxtime = 120
net.ipv4.inet_peer_gc_mintime = 10
net.ipv4.inet_peer_maxttl = 600
net.ipv4.inet_peer_minttl = 120
net.ipv4.inet_peer_threshold = 65664
net.ipv4.igmp_max_memberships = 20
net.ipv4.route.min_adv_mss = 256
net.ipv4.route.min_pmtu = 552
net.ipv4.route.mtu_expires = 600
net.ipv4.route.gc_elasticity = 8
net.ipv4.route.error_burst = 500
net.ipv4.route.error_cost = 100
net.ipv4.route.redirect_silence = 2048
net.ipv4.route.redirect_number = 9
net.ipv4.route.redirect_load = 2
net.ipv4.route.gc_interval = 60
net.ipv4.route.gc_timeout = 300
net.ipv4.route.gc_min_interval = 5
net.ipv4.route.max_size = 32768
net.ipv4.route.gc_thresh = 2048
net.ipv4.route.max_delay = 10
net.ipv4.route.min_delay = 2
net.ipv4.icmp_ignore_bogus_error_responses = 0
net.ipv4.icmp_echo_ignore_broadcasts = 0
net.ipv4.icmp_echo_ignore_all = 0
net.ipv4.ip_local_port_range = 32768    61000
net.ipv4.tcp_max_syn_backlog = 1024
net.ipv4.tcp_rfc1337 = 0
net.ipv4.tcp_stdurg = 0
net.ipv4.tcp_abort_on_overflow = 0
net.ipv4.tcp_tw_recycle = 0
net.ipv4.tcp_syncookies = 0
net.ipv4.tcp_fin_timeout = 60
net.ipv4.tcp_retries2 = 15
net.ipv4.tcp_retries1 = 3
net.ipv4.tcp_keepalive_intvl = 75
net.ipv4.tcp_keepalive_probes = 9
net.ipv4.tcp_keepalive_time = 7200
net.ipv4.ipfrag_time = 30
net.ipv4.ip_dynaddr = 0
net.ipv4.ipfrag_low_thresh = 196608
net.ipv4.ipfrag_high_thresh = 262144
net.ipv4.tcp_max_tw_buckets = 180000
net.ipv4.tcp_max_orphans = 8192
net.ipv4.tcp_synack_retries = 5
net.ipv4.tcp_syn_retries = 5
net.ipv4.ip_nonlocal_bind = 0
net.ipv4.ip_no_pmtu_disc = 0
net.ipv4.ip_autoconfig = 0
net.ipv4.ip_default_ttl = 64
net.ipv4.ip_forward = 0
net.ipv4.tcp_retrans_collapse = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
net.core.hot_list_length = 128
net.core.optmem_max = 10240
net.core.message_burst = 50
net.core.message_cost = 5
net.core.mod_cong = 290
net.core.lo_cong = 100
net.core.no_cong = 20
net.core.no_cong_thresh = 20
net.core.netdev_max_backlog = 300
net.core.rmem_default = 65535
net.core.wmem_default = 65535
net.core.rmem_max = 65535
net.core.wmem_max = 65535
vm.static_inactive_target = 0
vm.max-readahead = 31
vm.min-readahead = 3
vm.max_map_count = 65536
vm.page-cluster = 4
vm.kswapd = 512    32    8
vm.pagecache = 2    50    75
vm.buffermem = 2    10    60
vm.overcommit_memory = 0
vm.bdflush = 30    64    64    256    500    3000    60    0    0
vm.freepages = 383    766    1149
kernel.prof_pid = -1
kernel.overflowgid = 65534
kernel.overflowuid = 65534
kernel.random.uuid = 19187435-92a2-41c2-8b0e-cc9c93f8d658
kernel.random.boot_id = eefd5f18-5534-4ed9-b6cc-16a1407f1cf8
kernel.random.write_wakeup_threshold = 128
kernel.random.read_wakeup_threshold = 8
kernel.random.entropy_avail = 0
kernel.random.poolsize = 512
kernel.threads-max = 2048
kernel.cad_pid = 1
kernel.sysrq-sticky = 0
kernel.sysrq-key = 84
kernel.sysrq = 0
kernel.sem = 250    32000    32    128
kernel.msgmnb = 16384
kernel.msgmni = 16
kernel.msgmax = 8192
kernel.shmmni = 4096
kernel.shmall = 2097152
kernel.shmmax = 1000000000
kernel.shm-use-bigpages = 0
kernel.rtsig-max = 1024
kernel.rtsig-nr = 0
kernel.acct = 4    2    30
kernel.hotplug = /sbin/hotplug
kernel.modprobe = /sbin/modprobe
kernel.printk = 1    4    1    7
kernel.ctrl-alt-del = 0
kernel.real-root-dev = 256
kernel.cap-bound = -257
kernel.tainted = 0
kernel.core_uses_pid = 0
kernel.child-runs-first = 1
kernel.panic = 0
kernel.domainname = (none)
kernel.hostname = 1688quan-chen1
kernel.version = #1 Fri May 3 17:02:43 EDT 2002
kernel.osrelease = 2.4.9-e.3
kernel.ostype = Linux
fs.aio-max-pinned = 16384
fs.aio-max-size = 131072
fs.aio-max-nr = 65536
fs.aio-nr = 0
fs.jbd-oom-retry = 1
fs.lease-break-time = 45
fs.dir-notify-enable = 1
fs.leases-enable = 1
fs.overflowgid = 65534
fs.overflowuid = 65534
fs.dentry-state = 2655    2284    45    0    0    0
fs.dquot-nr = 0    0
fs.file-max = 8192
fs.file-nr = 505    13    8192
fs.inode-state = 3855    1755    0    0    0    0    0
fs.inode-nr = 3855    1755
 
### 回答1: /etc/sysctl.conf 是一个系统配置文件,用于设置内核参数。它包含了一系列的键值对,每个键值对都代表一个内核参数和其对应的值。这些参数可以影响系统的性能、安全性、网络连接等方面。 在 /etc/sysctl.conf 中,每个键值对的格式如下: key = value 其中,key 代表内核参数的名称,value 代表内核参数的值。例如: net.ipv4.tcp_syncookies = 1 这个键值对设置了 TCP SYN cookies 的开启状态。当 value 为 1 时,表示开启;当 value 为 0 时,表示关闭。 除了上述的 TCP SYN cookies,还有很多其他的内核参数可以在 /etc/sysctl.conf 中进行配置,例如: - 网络参数:如 TCP/IP 协议栈的参数、网络连接数限制等。 - 安全参数:如内核安全、文件系统安全等。 - 性能参数:如内存管理、磁盘 I/O 等。 在 /etc/sysctl.conf配置这些参数可以优化系统的性能、提高安全性、改善网络连接等方面。但需要注意的是,修改这些参数可能会对系统产生不良影响,因此在修改之前需要仔细考虑和测试。 ### 回答2: /etc/sysctl.confLinux系统中的一个配置文件,用于配置系统内核参数,以调整系统的性能和安全性能。通常情况下,所有的运行在Linux系统上的软件和服务都需要依赖于Linux内核的支持,因此对内核的参数进行调优,可以提高系统的稳定性和性能。 在/etc/sysctl.conf文件中,每一行都是一项内核参数的配置,每一行的格式为:参数名 = 参数值,其中参数名和参数值之间用等号隔开。下面是一些常用的内核参数及其说明: 1. net.ipv4.tcp_syncookies:表示是否开启TCP SYN Cookie防护。当值为1时代表开启,该功能可以有效防止TCP SYN攻击。 2. vm.swappiness:表示内存使用率达到多少时开始启动交换分区。值越小表示尽可能地使用物理内存,值越大则表示更倾向于使用交换分区。 3. kernel.sysrq:按下ALT+SysRq时的行为。其中0表示禁止,1表示允许SysRq输出,2表示Silently continues等等。 4. fs.file-max:表示系统中最多能打开多少个文件句柄。 5. net.ipv4.ip_forward:表示是否开启IP转发功能。当值为1时代表开启,在路由器或网关中需要开启此功能。 6. net.ipv4.conf.all.accept_redirects:表示是否允许接收重定向数据包,默认为1,建议关闭。 在修改完/etc/sysctl.conf文件之后,需要执行以下命令使其生效: sysctl -p 此命令会读取修改后的/etc/sysctl.conf文件并且使其生效。需要注意的是,不能随意修改内核参数,否则可能会导致系统崩溃或出现其他严重问题。建议在修改之前,先进行系统备份,并且谨慎地调整参数。 ### 回答3: /etc/sysctl.confLinux系统中一个非常重要的配置文件,它可以控制系统的一些参数和设置,可以帮助我们优化系统的性能,提高系统的安全性和稳定性。下面就是/etc/sysctl.conf配置文件的详解。 1. 参数说明 # 最大端口范围 net.ipv4.ip_local_port_range = 1024 65535 # 允许本机IP伪装 net.ipv4.conf.all.accept_source_route = 0 # 禁止ICMP重定向 net.ipv4.conf.all.accept_redirects = 0 net.ipv4.conf.all.send_redirects = 0 # 开启SYN Cookies,防止TCP SYN攻击 net.ipv4.tcp_syncookies = 1 # 禁止IP源路由 net.ipv4.conf.all.rp_filter = 1 # 增加系统最大文件打开数 fs.file-max = 65535 # 增加网络最大连接数 net.ipv4.tcp_max_syn_backlog = 1024 net.core.somaxconn = 1024 # 改善网络吞吐量 net.core.netdev_max_backlog = 5000 net.ipv4.tcp_wmem = 4096 65536 131072 net.ipv4.tcp_rmem = 4096 87380 174760 net.core.optmem_max = 81920 2. 参数解释 以上是一些常用的在/etc/sysctl.conf里面设置的参数,下面逐个进行解释: (1). net.ipv4.ip_local_port_range 这个参数表示本地TCP/UDP端口的范围,如设置1024 65535,则本地TCP/UDP端口可以从1024开始,到65535结束,大约有64000个端口可以使用。 (2). net.ipv4.conf.all.accept_source_route 该参数表示是否允许本机接收IP伪装的数据包,设置为0则关闭。 (3). net.ipv4.conf.all.accept_redirects 该参数表示是否接收ICMP重定向数据包,设置为0防止被攻击者通过ICMP重定向攻击来伪造路由表。 (4). net.ipv4.tcp_syncookies 该参数表示是否开启TCP SYN Cookies,开启此选项可以帮助防止SYN攻击。 (5). net.ipv4.conf.all.rp_filter 该参数表示是否允许IP源路由,设置为1则关闭。 (6). fs.file-max 该参数表示系统可以打开的最大文件数量,通常调整到65535。 (7). net.ipv4.tcp_max_syn_backlog和net.core.somaxconn 这两个参数用于调整系统的最大连接数,net.ipv4.tcp_max_syn_backlog代表TCP连接请求的队列长度,net.core.somaxconn用来设定最大积压的连接数,通常设置为1024。 (8). net.core.netdev_max_backlog 该参数用于增加网络中队列的最大长度,使得网络中的吞吐量更高。 (9). net.ipv4.tcp_wmem和net.ipv4.tcp_rmem 这两个参数用于调节TCP连接的发送缓存和接收缓存,默认缓存值分别为87380和174760,通常使用较大值来优化网络吞吐量。 (10). net.core.optmem_max 该参数用于调整内核和用户空间交互的最大缓存空间,通常设置为适当的值可以提高网络吞吐量。 3. 总结 /etc/sysctl.conf是一个非常重要的系统配置文件,它能够帮助我们优化系统的性能,提高系统的安全性和稳定性。因此,我们需要适当地调整一些参数来满足我们的需求,提高系统的运行效率。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值