Sub topic 10
Network kernel parameters and unused protocols
This chapter assumes you can edit files under /etc, run sysctl and modprobe, and read ip addr output. It also assumes you have a test server with a second SSH session open. The CIS network section has two parts. The first sets kernel parameters so a host does not behave like a router or trust forged packets. The second stops rarely used protocol modules from loading.
Why a server needs these settings
A general-purpose Linux kernel can forward packets, follow ICMP redirects, and honor source-routed packets. A server that is not a router should do none of these. An attacker on the same network segment can use them to redirect traffic, spoof addresses, or probe your network.
The settings live in two places:
/proc/sys/net/...holds runtime values. You read and write them withsysctl.- Files in
/etc/sysctl.d/hold the persistent values that are applied at boot.
Parameters CIS asks you to set
The table covers the usual IPv4 recommendations, plus the matching IPv6 settings when IPv6 is enabled.
| Parameter | Value | What it prevents |
|---|---|---|
| `net.ipv4.ip_forward` | 0 | The host routing traffic between interfaces |
| `net.ipv4.conf.*.send_redirects` | 0 | The host telling other hosts to change their routes |
| `net.ipv4.conf.*.accept_redirects` | 0 | Route changes injected by forged ICMP redirects |
| `net.ipv4.conf.*.secure_redirects` | 0 | Redirects accepted even from known gateways |
| `net.ipv4.conf.*.accept_source_route` | 0 | Senders choosing the route a packet takes |
| `net.ipv4.conf.*.log_martians` | 1 | Silent spoofed or impossible source addresses |
| `net.ipv4.icmp_echo_ignore_broadcasts` | 1 | Use of the host in smurf-style amplification |
| `net.ipv4.icmp_ignore_bogus_error_responses` | 1 | Log noise from malformed ICMP errors |
| `net.ipv4.tcp_syncookies` | 1 | Exhausting the SYN backlog during a SYN flood |
| `net.ipv6.conf.*.accept_ra` | 0 | Rogue router advertisements (static IPv6 setups) |
Apply the parameters
Put the settings in a drop-in file instead of editing /etc/sysctl.conf. The file name controls precedence, because files are read in lexical order and later values win.
# /etc/sysctl.d/60-cis-network.conf
net.ipv4.ip_forward = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.log_martians = 1
net.ipv4.conf.default.log_martians = 1
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.tcp_syncookies = 1Load every configuration file and check one value:
sudo sysctl --system
sysctl net.ipv4.ip_forwardsysctl --system prints each file as it applies it. If your file is not listed, or a later file sets the same key, you will see it here.
Why both `all` and `default` appear
The kernel keeps a copy of each setting per interface. conf.all is a switch that applies to every interface. conf.default is the template for interfaces created later, such as a VPN or bridge. For several redirect settings the kernel combines all with the per-interface value, so setting only all can leave an interface insecure. Setting both and then checking the real interface is the safe habit:
sysctl -a 2>/dev/null | grep -E 'conf\.(eth0|ens[0-9]+)\.(accept_redirects|send_redirects)'Substitute your interface name in the pattern. If an interface still shows 1, set it explicitly with a net.ipv4.conf.<interface>.<name> = 0 line.
Disable unused network protocols
CIS also recommends blocking kernel modules for protocols that most servers never use. The usual candidates are DCCP, SCTP, RDS, and TIPC. Old or rarely used protocol code has a poor security record, and a module that can autoload on demand is attack surface. Use the same pattern as the filesystem modules:
for mod in dccp sctp rds tipc; do
printf 'install %s /bin/false\nblacklist %s\n' "$mod" "$mod" | sudo tee "/etc/modprobe.d/${mod}.conf" >/dev/null
done
# Verify: no module loaded, and each dry run shows the override
lsmod | grep -E '^(dccp|sctp|rds|tipc)\b' || echo "none loaded"
modprobe -n -v sctpThe install line replaces the normal load command with /bin/false, so an attempt to load the module fails. The blacklist line stops alias-based autoloading. You need both.
Two limits apply:
- These files only affect future loads. A module that is already loaded stays until you unload it with
sudo modprobe -r sctpor reboot. - A module can still be built into the kernel. Then
modproberules have no effect, and/proc/moduleswill not list it.
IPv6 and wireless
CIS has a separate recommendation for IPv6. If you do not use it, you may disable it. If you use it, apply the IPv6 equivalents of the settings above and set accept_ra = 0 where addresses are static. Do not disable IPv6 only to pass a scan, because some software binds to ::1 and breaks.
On a server, also confirm that no wireless interface is active (nmcli radio all, or ip link). CIS recommends disabling wireless and Bluetooth on servers that do not need them.
Verify with a scan
Settings you applied by hand are not proven until a scanner agrees. Run the same OpenSCAP profile from the assessment chapter and filter the results:
sudo oscap xccdf eval \
--profile xccdf_org.ssgproject.content_profile_cis_server_l1 \
--results results.xml --report report.html \
/usr/share/xml/scap/ssg/content/ssg-rhel9-ds.xml
oscap xccdf generate report results.xml >/dev/null
grep -c 'sysctl_net' report.htmlOpen report.html and look at rule names that begin with sysctl_net_ipv4 or kernel_module_. A rule can fail even though sysctl shows the right value. The usual cause is a missing default entry or a value that has not yet been written to a persistent file.
Common errors
- A value reverts after reboot. A later file, such as
99-sysctl.conf, or a cloud-init or tuned profile, overrides yours. Rename your file with a higher number or remove the conflicting line. sysctl: cannot stat /proc/sys/net/ipv6/.... IPv6 is disabled on the kernel command line, so those keys do not exist. Remove the IPv6 lines or guard them.- Container networking breaks after hardening. The host needs
ip_forward = 1. Record the exception. modprobe -n -vshows a realinsmodpath. Theinstallline is missing, misspelled, or in a file that is not under/etc/modprobe.d/.
Exercise
You set net.ipv4.conf.all.accept_redirects = 0 in /etc/sysctl.d/60-cis-network.conf and ran sudo sysctl --system. The OpenSCAP scan still fails the accept_redirects rule for the default setting. What did you miss, and how do you confirm the fix?
Show answer
The file does not set net.ipv4.conf.default.accept_redirects = 0, which controls interfaces created later and is checked separately by the benchmark. Add that line, run sudo sysctl --system again, and confirm with sysctl net.ipv4.conf.default.accept_redirects. Then check an existing interface with sysctl -a | grep accept_redirects, and rescan with OpenSCAP.
Exercise
You created /etc/modprobe.d/sctp.conf with install sctp /bin/false and blacklist sctp, but lsmod still lists sctp. Why, and what do you do?
Show answer
The module was already loaded, and modprobe rules only affect future loads. Unload it with sudo modprobe -r sctp after stopping anything that uses it, or reboot. Then confirm with lsmod | grep sctp and modprobe -n -v sctp.