How to enable IP Forwarding

“IP forwarding” is a synonym for “routing.” It is called “kernel IP forwarding” because it is a feature of the Linux kernel.

By default any modern Linux distributions will have IP Forwarding disabled.IP forwarding is a process used to determine which path a packet or datagram can be sent. The process uses routing information to make decisions and is designed to send a packet over multiple networks.

This forwarding of network traffic can become dangerous at times, especially with the availability of modern cracking tools that can spoof internal IP addresses and make the remote attacker’s machine act as a node on your LAN.
To prevent this, iptables provides routing and forwarding policies that can be implemented to prevent abnormal usage of network resources.

Check if IP forwarding is enabled:

Using sysctl:

~]# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0

or By Checking value in /proc/sys/net/ipv4/ip_forward

~]# cat /proc/sys/net/ipv4/ip_forward

Enable IP Forwarding:-

By default, the IPv4 policy in Red Hat Enterprise Linux kernels disables support for IP forwarding. This prevents machines that run Red Hat Enterprise Linux from functioning as dedicated edge routers. To enable IP forwarding, use the following command as the root user:-

~]# sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1

This configuration change is only valid for the current session; the result will not be preserved after rebooting the system.
.To permanently set IP forwarding, add the line in /etc/sysctl.conf file as follows:

~]# vim /etc/sysctl.conf
net.ipv4.ip_forward = 1

To enable the changes made in sysctl.conf you will need to run the command as the root user:

~]# sysctl -p /etc/sysctl.conf
net.ipv4.ip_forward = 1

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s