Static Routing configuration _ how to configure permanent Static Routing in Suse and Red Hat systems

Source: Internet
Author: User
When the host has only one Nic, the default route and static route are not involved. When the two NICs are used, you can configure a gateway (the default route uses this Nic), and configure only the IP address and mask for confirmation (the host can communicate with the network ).

When the host has only one Nic, the default route and static route are not involved. When the two NICs are used, you can configure a gateway (the default route uses this Nic), and configure only the IP address and mask for confirmation (the host can communicate with the network ). However, in a relatively large environment with multiple network segments, You need to configure the default route and static route separately.

I. Requirements

Currently, there is one of the following networks. The host has two NICs, which are the business address eth0 and management address eth1.

Business address segment: 192.168.3.0/24

Management address segment: 10.212.52.0/24

Firewall segment: 10.211.6.0/24

The current requirement is that the default route goes through the business address (192.168.3.0/24), the firewall segment goes through the 10.211.6.0/24 business address, and all the 10.0.0.0/8 addresses go through the management address segment.

Ii. redhat static route Configuration

There are three configuration methods in the redhat Environment

Method 1: Configure in the/etc/sysconfig/network configuration file:

The Code is as follows:

Default via 192.168.3.1 dev eth0 #192.168.3.1 is the gateway address of eth0 Nic 10.211.6.0/24 via 192.168.3.1 dev eth010.0.0.0/8 via 10.212.52.1 dev eth1 #10.212.52.1 is the gateway address of eth1 Nic

Note: This configuration method can also be written to the/etc/sysconfig/network-scripts/route-interferface configuration file.

For details, refer to the redhat official documentation.

Method 2: Configure in the/etc/sysconfig/network-scripts/route-interferface configuration file

Two configuration formats are supported.

A: The method mentioned in method 1

The Code is as follows:

# cat /etc/sysconfig/network-scripts/route-eth00.0.0.0/0 via 192.168.3.1 dev eth010.211.6.0/24 via 192.168.3.1 dev eth0# cat /etc/sysconfig/network-scripts/route-eth110.0.0.0/8 via 10.212.52.1 dev eth1

B: network mask method

The Code is as follows:

# cat /etc/sysconfig/network-scripts/route-eth0

 

ADDRESS0 = 0.0.0.0 NETMASK0 = 0.0.0.0 GATEWAY0 = 192.168.3.1 ADDRESS1 = 10.211.6.0 NETMASK1 = 255.255.255.0 GATEWAY1 = 192.168.3.1

The IP address and mask of the CIDR block are all 0, indicating all the CIDR blocks, that is, the default route.

# cat /etc/sysconfig/network-scripts/route-eth1ADDRESS0=10.0.0.0NETMASK0=255.0.0.0GATEWAY0=10.212.52.1

For more information about the network mask method, see the redhat official document.

Method 3:/etc/sysconfig/static-routes Configuration

The Code is as follows:

# cat /etc/sysconfig/static-routeany net any gw 192.168.3.1any net 10.211.6.0/24 gw 192.168.3.1any net 10.0.0.0 netmask 255.0.0.0 gw 10.212.52.1

Note: This file is not found in the host by default. This method is also possible because the/etc/init. d/network STARTUP script calls this file. The specific call code is as follows:

The Code is as follows:

# Add non interface-specific static-routes.if [ -f /etc/sysconfig/static-routes ]; thengrep "^any" /etc/sysconfig/static-routes | while read ignore args ; do/sbin/route add -$argsdonefi

Iii. suse static routing configuration

# cat routesdefault 192.168.3.1 - -10.0.0.0 10.212.52.1 255.0.0.0 eth110.211.6.0 192.168.3.1 255.255.255.0 eth0

Note: The first configuration is the default route. The default route mask and interface can be replaced. Note that non-default routes cannot do this.

Method 2: Use the/etc/sysconfig/network/ifroute-* configuration file

/Etc/sysconfig/network/ifroute-*. The asterisks represent the corresponding device number. For the above configuration, you can use the following Configuration:

The Code is as follows:

# cat /etc/sysconfig/network/ifroute-eth00.0.0.0 192.168.3.1 0.0.0.0 eth010.211.6.0 192.168.3.1 255.255.255.0 eth0# cat /etc/sysconfig/network/ifroute-eth110.0.0.0 10.212.52.1 255.0.0.0 eth1

For more information, see the novell website or suse official documentation. The novell website documents are described as follows:

The Code is as follows:

define an additional configuration file: /etc/sysconfig/network/ifroute-*. Replace * with the name of the interface.The entries in the routing configuration files look like this:DESTINATION GATEWAY NETMASK INTERFACE [ TYPE ] [ OPTIONS ]DESTINATION GATEWAY PREFIXLEN INTERFACE [ TYPE ] [ OPTIONS ]DESTINATION/PREFIXLEN GATEWAY - INTERFACE [ TYPE ] [ OPTIONS ]

You can see that the four options that must be configured are: target segment or host interface gateway address target segment mask Interface

4. view route tables

After the configuration is complete, you can restart the network service and use any of the followingCommandView route table information:

The Code is as follows:

# netstat -nr# route -n# ip route list# ip route show
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.