2

Currently i'm setting up a new Debian 11 Bullseye machine to act as a Wireguard gateway. Everything as usual, and simple. Unfortunately i am having a heavy issue regarding the IPV4 packet forwarding. It's a well known fact, that i have to uncomment #net.ipv4.ip_forward in the /etc/sysctl.conf file, to enable packet forwarding. Unfortunately,even when it's uncommented, the setting is not being applied automatically after reboot. I have to manually process the sysctl file using "sysctl -p" every time after reboot. What's wrong here? There is also no further sysctl.conf in sysctl.conf.d which may override this setting. I have also tried on a fresh Debian 11 system, with the same issue.

root@wireguard:~# /sbin/sysctl --system
* Applying /etc/sysctl.d/1-sysctl.conf ...
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1
* Applying /usr/lib/sysctl.d/50-pid-max.conf ...
kernel.pid_max = 4194304
* Applying /usr/lib/sysctl.d/protect-links.conf ...
fs.protected_fifos = 1
fs.protected_hardlinks = 1
fs.protected_regular = 2
fs.protected_symlinks = 1
* Applying /etc/sysctl.conf ...
net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1

After reboot:

root@wireguard:~# cat /proc/sys/net/ipv4/ip_forward
0
root@wireguard:~# cat /proc/sys/net/ipv6/conf/all/forwarding
1

I hope someone can help me, it looks like, it's being partially applied only, i don't know if it has something to do with the IPv6 setting. Everything apart from the sysctl.conf and the Wireguard install is set to default.

1
  • Are you using ufw? If yes, see if there is such an option inside /etc/ufw/sysctl.conf . Also, leave net.ipv4.ip_forward = 1 only in sysctl.conf
    – Alex
    Sep 22, 2021 at 11:25

1 Answer 1

2

Create a /etc/sysctl.d/99-ipv.conf with the following lines:

net.ipv4.ip_forward = 1
net.ipv6.conf.all.forwarding = 1

Then run:

sudo systemctl restart  procps
sudo sysctl -p
1
  • perfect answer, thanks!
    – Frank
    Mar 11 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.