From 1b07dadfb9eb15adb058c43fd284d179e7ed7bae Mon Sep 17 00:00:00 2001 From: Kuzz007 Date: Wed, 29 Jul 2026 23:18:41 +0300 Subject: [PATCH] fix(install.sh): check the live sysctl value, not sysctl.conf text Same fix as the upstream PR (#6105) review round: grepping /etc/sysctl.conf for the setting name is unreliable -- many distros split sysctl config across /etc/sysctl.d/*.conf, and /etc/sysctl.conf can be a symlink into that directory, so the check can miss an already-active setting or match a disabled/commented line, leaving forwarding silently off either way. Query the live value via `sysctl -n` instead. Applied to both the IPv6 and IPv4 checks. --- install.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 9d2eb8fed..c9c94f657 100644 --- a/install.sh +++ b/install.sh @@ -188,10 +188,17 @@ install_ndppd() { # internal/amneziawg/manager.go's defaultPostUpDown), so this is a belt-and- # suspenders persistence step, not the only place it's set. enable_ipv6_forwarding() { - if ! grep -q "net.ipv6.conf.all.forwarding" /etc/sysctl.conf 2>/dev/null; then + # Checking /etc/sysctl.conf by name is not reliable: many distros split + # sysctl settings across /etc/sysctl.d/*.conf, and /etc/sysctl.conf is + # sometimes just a symlink into that directory, so grep can miss an + # already-active setting (false negative -> harmless duplicate line) or + # match a disabled/commented one (false positive -> forwarding silently + # stays off). Querying the live value directly is accurate regardless of + # which file actually set it. + if [ "$(sysctl -n net.ipv6.conf.all.forwarding 2>/dev/null)" != "1" ]; then echo "net.ipv6.conf.all.forwarding = 1" >> /etc/sysctl.conf fi - if ! grep -q "net.ipv4.ip_forward" /etc/sysctl.conf 2>/dev/null; then + if [ "$(sysctl -n net.ipv4.ip_forward 2>/dev/null)" != "1" ]; then echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf fi sysctl -p >/dev/null 2>&1 || true