communication between the network mainly relies on routers, in addition to the daily use of the router device, Linux system can also be configured to the router, simply add some simple routing entries on the Linux host, these Linux hosts can act as a simple router function, The following is an example of implementing router functions in a CentOS6 environment:
1. Set all IP addresses as shown
2. Configure routing for different Machines
Aubin-centos1
Route add default GW 10.4.1.1
Centos-r1
Route add-net 10.4.3.0/24 GW 10.4.2.2
Route add-net 10.4.4.0/24 GW 10.4.2.2
Echo 1 >/proc/sys/net/ipv4/ip_forward
Iptables-f
Centos-r2
Route add-net 10.4.1.0/24 GW 10.4.2.1
Route add-net 10.4.4.0/21 GW 10.4.3.1
Echo 1 >/proc/sys/net/ipv4/ip_forward
Iptables-f
Centos-r3
Route add-net 10.4.2.0/24 GW 10.4.3.2
Route add-net 10.4.1.0/24 GW 10.4.3.2
Echo 1 >/proc/sys/net/ipv4/ip_forward
Iptables-f
Aubin-centos1
Route add default GW 10.4.4.1
3.ping CentOS2 IP Address, if you can ping the router function has been implemented, if not ping, you can follow the following steps to check:
(1) Use Route-n to see if the route is in effect.
(2) Cat/proc/sys/net/ipv4/ip_forward to see if the output is 1, if the 0 description does not have the forwarding function turned on.
Check to see if echo 1 >/proc/sys/net/ipv4/ip_forward is performing successfully.
(3) Check the IP and mask is configured correctly, because there are more than one IP address confusing, so good check.
(4) Check whether to shut down the firewall and execute the iptables-f.
(5) If you are experimenting in a virtual machine environment, check the MAC address for conflicts
How do I use Linux to implement router functionality? Linux operation and Maintenance