In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to configure dual network cards and dual gateways in rhel6.5". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "how to configure dual network cards and dual gateways in rhel6.5".
The server environment is as follows:
System: RHEL6.5
Telecom 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 the Nic information
Vi / etc/sysconfig/network-scripts/ifcfg-eth22
DEVICE=eth22
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-eth24
DEVICE=eth24
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 is no gateway in the configuration file of the two network cards. If you add a gateway, only one default route will be displayed in route-n, and the other network segment will not be available.
[root@test 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 eth24
114.80.10.0 0.0.0.0 255.255.255.128 U 0 0 0 eth22
112.65.20.0 0.0.0.0 255.255.255.0 U 0 0 0 eth24
114.80.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth22
169.254.0.0 0.0.0.0 255.255.0.0 U 1016 0 0 eth24
169.254.0.0 0.0.0.0 255.255.0.0 U 1016 0 0 eth22
0.0.0.0 112.65.20.1 255.255.255.128 UG 0 0 0 eth24
2. Modify rc.local
These two routes can be added directly, but will be lost after restart.
Route add-net 114.80.10.0 dev eth22 25 gw 114.80.10.1
Route add-net 112.65.20.0 net 25 gw 112.65.20.1 dev eth24
So to take effect permanently, or to modify the rc.local
Vi / etc/rc.d/rc.local
[root@test network-scripts] # cat / etc/rc.d/rc.local
#! / bin/sh
#
# This script will be executed * after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
Touch / var/lock/subsys/local
Route add-net 114.80.10.0 dev eth22 25 gw 114.80.10.1
Route add-net 112.65.20.0 net 25 gw 112.65.20.1 dev eth24
Then route-n
[root@test 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 eth24
114.80.10.0 114.80.10.1 255.255.255.128 UG 0 0 0 eth22
112.65.20.0 0.0.0.0 255.255.255.0 U 0 0 0 eth24
114.80.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth22
169.254.0.0 0.0.0.0 255.255.0.0 U 1016 0 0 eth24
169.254.0.0 0.0.0.0 255.255.0.0 U 1016 0 0 eth22
(if you only need to add a default route, you can set it like this:
Route add default gw 112.65.20.1
Route del default gw 112.65.20.1 (you can delete the default route, which will take effect a few minutes after changing it in this way.)
Another way to do this is through the strategic routing configuration iproute2 toolkit. This package is developed by Alexey Kuznetsov and the main website of the package is ftp://ftp.inr.ac.ru/ip-routing/.
1. Add two routing tables: telecom: tel Unicom: cnc
# vi / etc/iproute2/rt_tables
252 tel
251 cnc
Save and launch
two。 Add routing rules
# ip route flush table tel
# ip route add default via 114.80.10.1 dev eth22 src 114.80.10.4 table tel
# ip ruleadd from 114.80.10.4 table tel
Here, the gateway of telecom is set up, and it can be realized that the resource access of telecom can only be accessed from the eth22 network card.
# ip route flush table cnc
# ip route add default via 112.65.20.1 dev eth24 src 112.65.20.2 table cnc
# ip rule add from 112.65.20.2 table cnc
Here, the gateway of China Unicom is set up, and it can be realized that the resource access of China Unicom can only be accessed from the eth24 network card.
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 eth22 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 eth24 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
If you test the machine network again at this time, you will find that the addresses of Telecom and China Unicom can be accessed normally. This method can also make the request from the telecom IP return according to the telecommunication route, and the request from the Netcom IP return from the Netcom route.
6. When the server restarts, the above routing rules will be invalid, so you need to write the above command into the system startup script
RedHat/CentOS, the system startup script is / etc/rc.d/rc.local
These are all the contents of the article "how to configure dual network cards and dual gateways in rhel6.5". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.