rhel6.5 dual-NIC dual gateway Configuration

Source: Internet
Author: User

As the user needs are two-wire, so the use of one network adapter to configure the telecommunications address, another network card configuration Unicom address, Install the rhel6.5 system after the configuration of IP, found that Unicom address and telecommunications address can only have a ping, if the telecommunications address configuration gateway, Unicom address does not match the gateway, you can only ping the address of the telecommunications, the other hand can only ping through the Unicom addresses, if the simultaneous configuration of Unicom and the telecommunications address two are not through. So how to implement dual-NIC dual-gateway in rhel6.5?

The server environment is as follows:

System: RHEL6.5

Telco IP (TEL): 114.80.10.79 netmask 255.255.255.128 Gateway 114.80.10.1

Unicom IP (CNC): 112.65.20.23 netmask 255.255.255.128 Gateway 112.65.20.1

1. Configure Network card information

Vi/etc/sysconfig/network-scripts/ifcfg-eth12

Device=eth12

Hwaddr=00:90:fa:76:a5:bc

Type=ethernet

uuid=ebd54026-4412-4cc3-9f74-e065d4328072

Onboot=yes

Nm_controlled=no

Bootproto=static

ipaddr=114.80.10.79

netmask=255.255.255.128


Vi/etc/sysconfig/network-scripts/ifcfg-eth14

Device=eth14

Hwaddr=00:90:fa:76:a5:98

Type=ethernet

uuid=ebd54026-4412-4cc3-9f74-e065d4328479

Onboot=yes

Nm_controlled=no

Bootproto=static

ipaddr=112.65.20.23

netmask=255.255.255.128


Note: There are no gateways in the two NIC configuration file. If you add a gateway, only one default route will be displayed in Route-n, and the other network segment is not.

[Email protected] network-scripts]# route-n

Kernel IP Routing Table

Destination Gateway genmask Flags Metric Ref use Iface

112.65.20.0 0.0.0.0 255.255.255.128 U 0 0 0 eth14

114.80.10.0 0.0.0.0 255.255.255.128 U 0 0 0 Eth12

112.65.20.0 0.0.0.0 255.255.255.0 U 0 0 0 eth14

114.80.10.0 0.0.0.0 255.255.255.0 U 0 0 0 Eth12

169.254.0.0 0.0.0.0 255.255.0.0 U 1016 0 0 eth14

169.254.0.0 0.0.0.0 255.255.0.0 U 1016 0 0 Eth12

0.0.0.0 112.65.20.1 255.255.255.128 UG 0 0 0 eth14


2, modify the Rc.local

These two routes can be added directly, but are lost after a reboot.

Route add-net 114.80.10.0/25 GW 114.80.10.1 Dev Eth12

Route add-net 112.65.20.0/25 GW 112.65.20.1 Dev eth14

So to be permanent, or to modify rc.local

Vi/etc/rc.d/rc.local

[Email protected] network-scripts]# cat/etc/rc.d/rc.local

#!/bin/sh

#

# This script is executed *after* all and the other init scripts.

# can put your own initialization stuff in here if you don ' t

# want to does the full Sys V style init stuff.

Touch/var/lock/subsys/local

Route add-net 114.80.10.0/25 GW 114.80.10.1 Dev Eth12

Route add-net 112.65.20.0/25 GW 112.65.20.1 Dev eth14

Then Route-n

[Email protected] network-scripts]# route-n

Kernel IP Routing Table

Destination Gateway genmask Flags Metric Ref use Iface

112.65.20.0 112.65.20.1 255.255.255.128 UG 0 0 0 eth14

114.80.10.0 114.80.10.1 255.255.255.128 UG 0 0 0 Eth12

112.65.20.0 0.0.0.0 255.255.255.0 U 0 0 0 eth14

114.80.10.0 0.0.0.0 255.255.255.0 U 0 0 0 Eth12

169.254.0.0 0.0.0.0 255.255.0.0 U 1016 0 0 eth14

169.254.0.0 0.0.0.0 255.255.0.0 U 1016 0 0 Eth12


(You can set this only if you need to add a default route:
Route add default GW 112.65.20.1
Route del default GW 112.65.20.1 (you can delete the default route, which can be changed after a few minutes.)


Another way to do this is through a strategic routing configuration Iproute2 Toolkit. This package was developed by Alexey Kuznetsov and the main URL for the package is ftp://ftp.inr.ac.ru/ip-routing/.

1.2 Additional routing tables are telecom: Tel Unicom: CNC

# Vi/etc/iproute2/rt_tables
252 Tel
251 CNC

Save and launch

2. Add Routing Rules
# IP Route Flush Table Tel
# IP route add default via 114.80.10.1 dev eth12 src 114.80.10.4 table Tel
# IP Ruleadd from 114.80.10.4 table Tel

Here is the gateway to set up telecommunications, and to enable the access of telecommunications resources only from the ETH12 network card out

# IP route flush Table CNC
# IP route add default via 112.65.20.1 dev eth14 src 112.65.20.2 table cnc
# IP rule add from 112.65.20.2 table CNC

Here is the gateway to set up the Unicom, and to enable access to the resources of the Unicom only from the ETH14 network card out

3. Configure the Network startup script file to add the following before the end

# vi/etc/rc.d/init.d/network

IP Route Flush Table Tel
IP route add default via 114.80.10.1 dev eth12 src 114.80.10.4 table Tel
IP rule Add from 114.80.10.4 table Tel

IP route flush Table CNC
IP route add default via 112.65.20.1 dev eth14 src 112.65.20.2 table cnc
IP rule add from 112.65.20.2 table CNC

Exit 0

5. Exit and restart the network

#/etc/rc.d/init.d/network Restart

At this time, testing the network situation, you will find the telecommunications and Unicom's address can be normal access. This method can also be implemented to let the request from the telecommunications IP in accordance with the telecommunications routes returned, from the Netcom IP request from the Netcom route back.

6, the server restarts, the above routing rules are invalidated, so you need to write the above command to the system startup script


Redhat/centos, the system startup script is/etc/rc.d/rc.local


This article is from the "Hollows Jie Sun" blog, be sure to keep this source http://xjsunjie.blog.51cto.com/999372/1604759

rhel6.5 dual-NIC dual gateway Configuration

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.