I know that I can enable IP forward by echoing 1
to /proc/sys/net/ipv4/ip_forward
, but how can I make this permanent?
By the way I want another method rather than start up scripts, is there any?
I know that I can enable IP forward by echoing 1
to /proc/sys/net/ipv4/ip_forward
, but how can I make this permanent?
By the way I want another method rather than start up scripts, is there any?
Edit /etc/sysctl.conf and search for the following lines:
Uncomment
net.ipv4.ip_forward=1
:Or in one line command :
Permanent setting using
/etc/sysctl.conf
If we want to make this configuration permanent the best way to do it is using the file
/etc/sysctl.conf
where we can add a line containingnet.ipv4.ip_forward = 1
If you already have an entry
net.ipv4.ip_forward
with the value 0 you can change that to 1.To enable the changes made in
sysctl.conf
you will need to run the command:On RedHat based systems this is also enabled when restarting the network service:
and on Debian/Ubuntu systems this can be also done restarting the procps service:
Source: How to Enable IP Forwarding in Linux
If you need to enable it in script you can use commands below to enable
or disable: