How do I use Linux to implement router functionality? Linux operation and Maintenance

Source: Internet
Author: User
Tags iptables

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

Related Article

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.