0

I'm enabling IP forwarding on Ubuntu 12.04 for NAT setup, using the following command:

'echo 1 > /proc/sys/net/ipv4/ip_forward'

But everytime I restart the machine, I have to add it manually. How can I add it to the startup, so everytime Ubuntu starts, it will get 1 automatically? (I remember rc.local or something?!)

angel_30
  • 303

2 Answers2

1

There should be a file /etc/sysctl.conf where you can put these settings to be automatically applied on boot. In fact, looking at my generic version now, line 26 is the commented-out statement

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

I suggest you look for this line and uncomment it, or add it if you cannot find it. Then, this setting should apply on each boot. To make it apply for the current session, as you've already discovered, you'll need to use something like the command you mentioned in your question.

0

I'm new here so I'm not quite familiar with the rules and policies quite yet but I found a very helpful thread over at superuser[dot]com - link

In summary, to ensure that your settings are configured at system boot-up, create a bash script and save it to: /etc/init.d/your_script and make sure it is executable

$ chmod 700 your_script

Then add it to the init services:

$ sudo update-rc.d your_script defaults

Also, feel free to read the 'man' page for update-rc.d :)

$ man update-rc.d

To ensure that your settings are configured after logging into the system, here is some more information and instructions on it from another thread on askubuntu[.]com - link

Hope this helps!