هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
The quick answer
Step by step
- Read a value (line 1) — names map to files under
/proc/sys(net.ipv4.ip_forward=/proc/sys/net/ipv4/ip_forward).sysctl -a | grep somaxconnsearches all. - Change it now (line 2) — takes effect at once, but is lost at reboot.
- Make it permanent (lines 3–4) — one file per purpose in
/etc/sysctl.d/, with a comment why. Files are read in name order; a higher number wins.sysctl --systemloads all files now and prints what it applied. - Useful examples:
# busy web server: longer accept queue
net.core.somaxconn = 4096
net.ipv4.tcp_max_syn_backlog = 4096
# database server: swap only under real pressure
vm.swappiness = 10
# security hardening
kernel.dmesg_restrict = 1
kernel.kptr_restrict = 2
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.tcp_syncookies = 1- Kubernetes nodes need
net.ipv4.ip_forward = 1and, with thebr_netfiltermodule loaded,net.bridge.bridge-nf-call-iptables = 1. - Change one thing at a time and measure; copy-paste "tuning" lists from the internet often do nothing or harm. Note the old value before changing.
- Containers — some
net.*settings are per network namespace and can be set per Pod/container (securityContext.sysctls,docker run --sysctl); host-wide ones (vm.*) only on the node.
Check that it worked
sysctl net.ipv4.ip_forward prints = 1; after a reboot it still does; sysctl --system lists your file and its values without errors.
Common problems
| Problem | Cause | Fix |
|---|---|---|
| Value back to the old one after reboot | Only set with -w. | Put it in /etc/sysctl.d/*.conf. |
| Another file overrides yours | A file with a higher name order sets the same key. | grep -r KEY /etc/sysctl.d /usr/lib/sysctl.d /etc/sysctl.conf; rename yours (99-). |
cannot stat /proc/sys/net/bridge/… | Module br_netfilter not loaded. | Load it (and at boot), then apply again. |
permission denied in a container | Host-wide key. | Set it on the host/node. |
| No visible effect | The app has its own limit (for example listen backlog). | Raise the app setting too. |
sysctl: setting key …: Invalid argument | Wrong value or unit. | Check the kernel documentation for that key. |
Go further
- Command pages: sysctl, modprobe.
- Next how-tos: Load a kernel module at boot, Choose a performance profile with tuned, Add a network route, Add swap space.
- Learn it: RHCSA — sysctl.
1How do you make a sysctl change survive a reboot?
Put the setting in a file in /etc/sysctl.d/ and load it with sysctl --system.
2Where does sysctl read and write its values?
In the files under /proc/sys; the dots in the name are the folder levels.