How to Make IP Forwarding Permanent

routing

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?

Best Answer

Edit /etc/sysctl.conf and search for the following lines:

# Uncomment the next line to enable packet forwarding for IPv4
#net.ipv4.ip_forward=1

Uncomment net.ipv4.ip_forward=1:

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

Or in one line command :

sudo sysctl -w net.ipv4.ip_forward=1