Linux IP Forwarding

In this lab, we will use Linux IP Forwarding to connect 02 different subnets together.

We need 03 Linux VMWare machines with the model as below:

1. Linux 1: 01 NIC eth0, connect to VMNet2: 192.168.2.0/24

2. Linux 2: 02 NIC

– eth0 connect to VMNet2 192.168.2.0/24

– eth1 connect to VMNet3 192.168.3.0/24

3. Linux 3: 01 NIC eth0, connect to VMNet3: 192.168.3.0/24

After configuring, Linux 1 will ping Linux 3 successfully.

1. Configure Linux 1

All we need is set up eth0 of Linux 1 as below:

2. Configure Linux 3

All we need is set up eth0 of Linux 3 as below:

3. Configure Linux 2

This is the most important machine because it’s the bridge between 2 subnets. First, we need to set up eth0 and eth1 of Linux 2 as below:

Second, we need to enable ip forwarding function.

Edit file sysctl.conf as below:

vi /etc/sysctl.conf

Goto the line

net.ipv4.ip_forward = 0

Change it to

net.ipv4.ip_forward = 1

Save, exit, then restart network service:

service network restart

4. Test:

Ping Linux 3 from Linux 2 successfully.

This lab is done on:

[root@centos ~]# lsb_release -a | grep Description ; echo “Linux kernel: `uname -r`”
Description: CentOS release 5.7 (Final)
Linux kernel: 2.6.18-274.18.1.el5

dongthao

Advertisements

About dongthao

"Man does not simply exist but always decides what his existence will be, what he will become the next moment"
This entry was posted in Linux, Linux Tutorial and tagged , , . Bookmark the permalink.

One Response to Linux IP Forwarding

  1. phong says:

    Phần test phải là “Ping Linux 3 from Linux 1 successfully” chứ ạ,chứ em tưởng mặc định Linux 2 nó đã ping đc 3 rồi

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

w

Connecting to %s