Linux Command Encyclopedia

Source: Internet
Author: User

First, the environment:

Three directly connected computer mainframe as shown in


The PC2 has two network card eth0, eth1, respectively with PC3, PC1 connected

------represents a network cable

Second, the demand:

Configure PC2 as router mode to forward messages between PC1 and PC3

Third, the method:

Three hosts in accordance with the requirements of the environment by the intersection line directly connected, for the three host allocation network segment and configure IP address.

Network segment and IP address are assigned as follows:

IP gateways are assigned to the network segment where the host name resides


PC2: ' configuration of the NIC connected to the PC1 ' eth1 ' configuration of the NIC connected to the PC3 ' eth0


According to the table above, the host IP address is configured well, which should be noted that to make PC2 have message forwarding function, in the PC2

Check to see if the value in/proc/sys/net/ipv4/ip_forward is 1



If you display a value of not 1 instead of 0, enter the following command:

#echo ' 1 ' >/proc/sys/net/ipv4/ip_forward

Turn on the IP forwarding feature

Other configurations in the PC2:

To add a route for PC2, command:

#route add-net netmask Dev eth0

#route add-net netmask Dev eth1

Four, verify:


Ping Gateway



Ping PC3:



Ping Gateway



Pint PC1


Five, bug debugging:

The cause of the error is mainly in PC2 two places

1. Check PC2 to allow IP message forwarding (/proc/sys/net/ipv4/ip_forward value is 1)

2. Routing settings are correct (#route carriage return view)

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.