Information
Routers periodically multicast Router Advertisement messages to announce their availability and convey information to neighboring nodes that enable them to be automatically configured on the network.
net.ipv6.conf.all.accept_ra controls accepting any IPv6 RA messages on any network device.
More information about the kernel parameter configuration files, their location, and load preference is available in the "Configure Network Kernel Parameters" section overview.
Note: If IPv6 has been disabled, this recommendation is not applicable.
It is recommended that systems do not accept router advertisements as they could be tricked into routing traffic to compromised machines. Setting hard routes within the system (usually a single default route to a trusted router) protects the system from bad routes.
Solution
- Review all files being used by systemd sysctl and comment out or remove all net.ipv6.conf.all.accept_ra lines that are not net.ipv6.conf.all.accept_ra=0.
Example script:
#!/usr/bin/env bash
{
l_option="net.ipv6.conf.all.accept_ra" l_value="0"
l_grep="${l_option//./(\\.|\\/)}" a_files=()
l_systemdsysctl="$(readlink -e /lib/systemd/systemd-sysctl \
|| readlink -e /usr/lib/systemd/systemd-sysctl)"
a_files+=("/etc/sysctl.conf")
while IFS= read -r l_fname; do
l_file="$(readlink -e "${l_fname//# /}")"
[ -n "$l_file" ] && ! grep -Psiq -- '(^|\h+)'"$l_file"'\b' \
<<< "${a_files[*]}" && a_files+=("$l_file")
done < <("$l_systemdsysctl" --cat-config | tac | \
grep -Psio -- '^\h*#\h*\/[^#\n\r\h]+\.conf\b')
for l_file in "${a_files[@]}"; do
grep -Psio -- '\h*'"$l_grep"'\h*=\h*\H+\b' "$l_file" \
| grep -Psivq -- '^\h*'"$l_grep"'\h*=\h*'"$l_value"'\b' && \
sed -ri '/^\s*'"$l_grep"'\s*=\s*(1[0-9]*)/s/^/# /' "$l_file"
done
}
- Create or edit a file in the /etc/sysctl.d/ directory ending in .conf and edit or add the following line:
net.ipv6.conf.all.accept_ra = 0
Example:
# [ ! -d "/etc/sysctl.d/" ] && mkdir -p /etc/sysctl.d/
# printf '%s\n' "" "net.ipv6.conf.all.accept_ra = 0" >> /etc/sysctl.d/60-ipv6_sysctl.conf
- Run the following command to load all sysctl configuration filles:
# sysctl --system
Impact:
On networks that rely on IPv6 Router Advertisements (SLAAC) for autoconfiguration, no longer accepting Router Advertisements will prevent the system from automatically configuring its IPv6 address, default route, and gateway. Such systems must instead use static IPv6 addressing or DHCPv6.