Linux Command Encyclopedia

Source: Internet
Author: User

First, the environment:

Three directly connected computer mainframe as shown in

pc1<------>PC2<------>PC3

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

PC1:192.168.2.0/24 192.168.2.2/24 192.168.2.1

PC2:192.168.2.0/24 192.168.2.1/24 ' configuration of the NIC connected to the PC1 ' eth1

192.168.1.0/24 192.168.1.1/24 ' configuration of the NIC connected to the PC3 ' eth0

PC3:192.168.1.0/24 192.168.1.2/24 192.168.1.1

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

Command:

#more/proc/sys/net/ipv4/ip_forward

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 192.168.1.0 netmask 255.255.255.0 Dev eth0

#route add-net 192.168.2.0 netmask 255.255.255.0 Dev eth1

Four, verify:

PC1:

Ping Gateway

#ping 192.168.2.1

#ping 192.168.1.1

Ping PC3:

#ping 192.168.1.2

PC3:

Ping Gateway

#ping 192.168.1.1

#ping 192.168.2.1

Pint PC1

#ping 192.168.2.2

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: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.