To check whether IP forwarding is enabled or not, you can run the following command. The output "1" means that IP forwarding is enabled, and "0" means that it's not.
If you want to enable IP forwarding on the fly, you can use sysctl command as follows. IP forwarding will be activated immediately without rebooting.
Note that IP forwarding enabled by sysctl command does not remain active across reboots, which means that IP forwarding becomes disabled after rebooting.
If you want to enable IP forwarding permanently, edit /etc/sysctl.conf as follows.
net.ipv4.ip_forward = 1
Then reload sysctl.conf.
Finally, restart networking to activate the change:
On CentOS, RHEL or Fedora:
On Debian or Ubuntu:
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!
Latest posts by Dan Nanni (see all)
- How to back up a WordPress website to remote cloud storage from the Linux command line - November 24, 2015
- How to access Dropbox from the command line in Linux - November 22, 2015
- How to send email notifications using Gmail SMTP server on Linux - November 9, 2015