How to implement ip forwarding in Linux


IP forwarding is a concept to make Linux machine to forward data from one network to another, this is same as a router(A router is a device which is used to forward packets from one point to other point depending on the packet destination/rules etc).

Why we require IP forwarding on a Linux machine?

Ans : We require IP forwarding on a Linux machine because to make it as a router or proxy server to share one internet connection to many client machines.

Let me explain how this will work with small example.

You have 2 machines which are in different network(PC1 in network and PC2 in network) and connected with a Linux machine(which is having two network interfaces). The IP address is as follows..

PC1: default gateway:

PC2: default gateway:

Linuxbox eth0 :

eth1 :

and Linux machine is having two LAN cards which are connected to both the

machines as shown below
So do you think PC1 is capable of communicating with PC2?
Ans :
The answer to this question is No.

How to make PC1 to communicate with PC2?
Ans :
The answer is enable ip forwarding on Linux machine. Some times this is called as bridging two networks.

To achieve IP forwarding we have to edit /etc/sysctl.conf as shown below. Open sysctl.conf and change the value of “net.ipv4.ip-forard” from 0 to 1 and save the file

#vi /etc/sysctl.conf

net.ipv4.ip-forard = 0


net.ipv4.ip-forard = 1

Once its done still you are not able to ping from PC1 to PC2. We have to restart the linuxbox to take this update to kernel.

Why to restart if its a production machine try below command to make your linuxbox aware of IP forwarding with out a restart.

echo 1 > /proc/sys/net/ipv4/ip-forward

Now try to ping from PC1 to PC2 which will ping successfully.

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Equivalent Tool For WINscp in Linux


    Is there any tool which is equivalent to do what WINscp does in Windows?

    Winscp is widely used tool in windows to access any Linux/Nix machine to transfer data(files/folders). Its look similar to FTP client such as filezilla client.
    Suppose you are in Linux machine and want to mount(connect) a folder similar to WinSCP with SSH protocol, then this post is for you. This tool will work to connect http, https, ftp, samba share protocols etc.

    In Linux we have one utility called nautilus to do this work.
    Install natutilus


    #yum install nautilus


    #apt-get install nautilus

    Try to access Nautilus as shown below in screen by screen shot manner

    Go to places and the slect connect to server.

    Now you can see a pop-up window which shows the service type.

    Then select the protocol as ssh.

    Then specify the server ip, port where ssh service is running, user name to connect, then press connect

    Now it will ask for the user’s password, enter the password and connect it.

    This screen shot show the remote server content.

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Hello Readers


    Hello dear readers,

    First we would like to wish you all that happy VIJAYADASHAMI. From today onwards we would assure you that we will write posts frequently. Why we have selected this day because if we start whatever work on Vijayadashami, we will get success on that work. Once again Happy Vijayadashami to all.


  • Like the post? Please Subscribe to free RSS feed to get updates
  • Archive

    Translate this page


    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here