Saturday, October 4, 2014



           IP forwarding also known as Internet routing 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.
                     Defaultly any UNIX/Linux distributions will have IP Forwarding is disabled.  As most of the peoples will not need IP Forwarding, but if we are setting up a Linux router/gateway, when you want your system to act as VPN server, and for sharing the internet connection. See the below steps for enable or disable IP forwarding in linux.

Step1: Check the IP forwarding is enable or disable
   

               In this step we have to check the IP forwarding using sysctl command
 [root@bsrtech ~]# sysctl net.ipv4.ip_forward
 
  Sample Output:
  

             net.ipv4.ip_forward = 0

Step2: To Enable IP Forwarding Temporarily
    
     To enable IP Forwarding temporarily,you can use any of the following commands

   [root@bsrtech ~]# echo 1 > /proc/sys/net/ipv4/ip_forward

     (or)
   
   [root@bsrtech ~]# sysctl -w net.ipv4.ip_forward=1 

  To check the IP Forwarding is enabled or not , execute the following command

   [root@bsrtech ~]# sysctl net.ipv4.ip_forward

Step3: To Enable IP Forwarding Permanently
  To enable IP forwarding permanently, you can change value in configuration file /etc/sysctl.conf

  [root@bsrtech ~]# vim /etc/sysctl.conf

   you can find the line "net.ipv4.ip_forward" and Set net.ipv4.ip_forward to 1
  
      

    net.ipv4.ip_forward = 0
    
    to

    net.ipv4.ip_forward = 1

  :wq (Save and close the file)
                                                          

Step4:  Reload the changes 
  To load the settings that we made to /etc/sysctl.conf file, run the following command

 [root@bsrtech ~]# sysctl -p

  Sample Output:

                                   


 Step5: To Disable IP forwarding Permanently

     you can find the line in /etc/sysctl.conf "net.ipv4.ip_forward" and Set net.ipv4.ip_forward to 0 

    net.ipv4.ip_forward = 1
    
    to

    net.ipv4.ip_forward = 0
  
   :wq (save and close the file)
 
  Reload the changes using sysctl command

  [root@bsrtech ~]# sysctl -p

  Sample Output:

                                         

0 comments:

Post a Comment