Sub topic 10
Network Kernel Parameters and Unused Protocols
Prerequisites and working model
This chapter assumes that you can use sudo, edit configuration files, and understand basic IP networking. You should also have console access to a test server. A bad network setting can disconnect an active SSH session.
The Linux kernel exposes runtime settings through sysctl. These settings control packet forwarding, redirect handling, source routing, logging, and related network behavior. A setting changed with sysctl takes effect immediately, but it may disappear after reboot. A file under /etc/sysctl.d/ makes the setting persistent.
CIS recommendations depend on the server's role. A router, container host, or IPv6 service may need settings that a standalone application server does not. Record the reason before changing a value.
Apply and verify network settings
For a typical server that does not route traffic, create a drop-in file such as /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.accept_source_route = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.conf.all.log_martians = 1
net.ipv4.tcp_syncookies = 1
kernel.randomize_va_space = 2ip_forward controls whether the host routes packets between interfaces. send_redirects and accept_redirects affect ICMP routing advice. Source routing allows a sender to influence a packet's path and is normally unnecessary. Martian logging records packets with impossible or suspicious source addresses. TCP syncookies help protect the TCP connection handshake during resource exhaustion attacks. Address-space randomization makes memory locations less predictable.
Load the settings and inspect the effective values:
sudo sysctl --system
sysctl net.ipv4.ip_forward
sysctl net.ipv4.conf.all.accept_source_routeCheck both all and default settings where applicable. all affects current interfaces, while default supplies the initial value for interfaces created later.
Disable unused protocol modules
A protocol or filesystem module that the host never needs adds attack surface. For example, if the server does not use the dccp protocol, prevent its module from loading:
sudo tee /etc/modprobe.d/disable-unused-protocols.conf >/dev/null <<'EOF'
install dccp /bin/false
blacklist dccp
EOF
modprobe -n -v dccp
lsmod | grep '^dccp'The dry-run output should show an override using /bin/false. An empty lsmod result means the module is not currently loaded. Repeat this process only for protocols confirmed to be unused, such as SCTP, RDS, or TIPC. Kernel modules can have dependencies, so test the change after reboot or in a maintenance window.
Review the change
Exercise
Why should a server set both net.ipv4.conf.all.accept_redirects and net.ipv4.conf.default.accept_redirects to zero?
Show answer
all governs existing interfaces, while default applies the value when future interfaces are created. Setting both prevents inconsistent behavior.