Static route configuration in RHEL5.7

Source: Internet
Author: User
You may know that a router has a routing function, or a layer-3 Switch has a routing function. But few people know that our host also has the routing function, which can be used as a simple router, but is not enabled by default. It works on both Windows and Linux platforms. Now let's take a look at the static routing configuration in Linux. Let's look at a simple topology demand is very simple, as long as the RHEL-A can ping through the RHEL-C can be. First enable the routing forwarding feature for the RHEL-B server, that is,/pro

You may know that a router has a routing function, or a layer-3 Switch has a routing function. But few people know that our host also has the routing function, which can be used as a simple router, but is not enabled by default. It works on both Windows and Linux platforms. Now let's take a look at the static routing configuration in Linux.

Let's look at a simple topology.

Demand is very simple, as long as the RHEL-A can ping through the RHEL-C can be.

First turn on the routing forwarding feature for the RHEL-B server, changing the value of the/proc/sys/net/ipv4/ip_forward file from 0 to 1. 0 indicates that the routing function is disabled, and 1 indicates that the routing function is enabled. (Modify with echo. It is best not to use vi for editing)

Echo 1>/proc/sys/net/ipv4/ip_forward

To enable the routing function, modify the/etc/sysctl. conf file.

Vi/etc/sysctl. conf

Static Routing commands

Route add-net adds a default route. The destination of www.linuxidc.com is the peer network segment.

Route add-host adds a default route. The target of www.linuxidc.com is the peer host.

Route add default gw Set default Gateway

Delete A route

Configure Static Routing for the RHEL-A, Gateway points to the eth0 interface of the RHEL-B

Route add-net 192.168.20.0 netmask 255.255.255.0 gw 192.168.10.20

Configure a static route for the RHEL-C, the gateway points to the eth1 interface of the RHEL-B

Route add-net 192.168.10.0 netmask 255.255.255.0 gw 192.168.255.20

At this time using the RHEL-A to ping 192.168.20.1 and the RHEL-C to ping 192.168.10.1 is successful.

Let's take a look at the route table for the RHEL-A and RHEL-C, and the command for viewing the route table is route-n

RHEL-A

An extra route entry for the 192.168.20.0 CIDR block is found. The next hop points to 192.168.10.20. UG indicates that the next hop points to the Gateway and the outbound interface is eth0.

RHEL-C

**************************************** **************************************** ******

In addition, you can use the output interface as the next hop in the static routing configuration. For example

RHEL-A

Route add-net 192.168.20.0 netmask 255.255.255.0 dev eth0

RHEL-C

Route add-net 192.168.10.0 netmask 255.255.255.0 dev eth0

However, this is not recommended because the output interface does not match a fixed next hop in the Ethernet interface, which may cause too many ARP entries and cause communication failure.

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.