Bash /proc/sys/net/ipv4/ip_forward: Permission denied
The permission bits for the file
root can write to the file.
When you do:
echo 1 > /proc/sys/net/ipv4/ip_forward
as a normal user, you won't be able to write to the file due to insufficient permission.
You can do:
sudo bash -c 'echo 1 > /proc/sys/net/ipv4/ip_forward'
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
Note that, you should use
/etc/sysctl.conf for persistent operations on the
In a nutshell, to enable IP forwarding, you can just put the following in
net.ipv4.ip_forward = 1
sudo sysctl -p
to have immediate effect.
This has the same effect as editing the file
/proc/sys/net/ipv4/ip_forward directly, and not to mention far cleaner and of course persistent.