Use procfs
This is maybe the most used way, it is a temporary change, and you need to enable it after every reboot.
sudo echo 1 > /proc/sys/net/ipv4/ip_forwardYou can add this line to /etc/rc.local file, and that way, each time you reboot your computer it will be enabled again.
You can check if IP forwarding is enabled or disabled by checking the content of /proc/sys/net/ipv4/ip_forward file:
cat /proc/sys/net/ipv4/ip_forwardIf the output is 1, it is enabled if 0, then it is disabled.
Use sysctl
sysctl let’s you change Kernel values on the fly, so you can use it, to change the IP forward behaviour.
First, let’s check if it is enabled or disabled, as root run:
sysctl -a | grep net.ipv4.ip_forwardNow you can set its value to 1, to enable ip forwarding.
sysctl -w net.ipv4.ip_forward=1This is also temporary, if you want it to be permanent, you can edit the file /etc/sysctl.conf:
sudo vi /etc/sysctl.confAnd uncomment or add this line:
net.ipv4.ip_forward = 1To make it effective you have to use this command
sudo sysctl -p
No comments:
Post a Comment