In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to add static routes to CentOS6.5". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to add static routes to CentOS6.5.
CentOS add permanent static rout
When using dual network cards and two gateways at the same time, you need to add a static route. Of course, there are many times when it needs to be routed.
Operating system version centos-6.4 64bit
One: use the route command to add
1. The route added using the route command becomes invalid after the machine is rebooted or the network card is restarted. Method:
/ / routes added to the host
# route add-host 192.168.1.11 dev eth0
# route add-host 192.168.1.12 gw 192.168.1.1
/ / routes added to the network
# route add-net 192.168.1.11 netmask 255.255.255.0 dev eth0
# route add-net 192.168.1.11 netmask 255.255.255.0 gw 192.168.1.1
# route add-net 192.168.1.0 take 24 dev eth2
/ / add a default gateway
# route add default gw 192.168.2.1
/ / Delete a route
# route del-host 192.168.1.11 dev eth0
2. You can also use the ip command to add or delete routes
Ip route add default via 172.16.10.2 dev eth0
Ip route add 172.16.1.0/24 via 172.16.10.2 dev eth0
The format is as follows:
Ip route
Default via gateway dev interface
Ip/netmask via gateway dev interface
Second: the method of setting permanent route under linux:
1. Add to / etc/rc.local
Methods:
Route add-net 192.168.3.0 ax 24 dev eth0
Route add-net 192.168.2.0ax 24 gw 192.168.2.254
two。 Add to the end in / etc/sysconfig/network
Methods:
GATEWAY=gw-ip
Or
GATEWAY=gw-dev
3./etc/sysconfig/static-routes:
Any net 192.168.3.0/24 gw 192.168.3.254
Any net 10.250.228.128 netmask 255.255.255.192 gw 10.250.228.129
Adding routes to rc.local will cause the NFS not to mount automatically, so the method of using static-routes is the best. Both the restart of the system and service network restart will take effect.
Description of resolving NFS issues:
According to the order in which the linux starts, the contents of the rc.local are executed only after all the services of the linux are started, that is to say, the contents are executed after the netfs, that is, when the netfs starts, the static routes on the server are not added, so the netfs mount cannot succeed.
4. Add a route under / etc/sysconfig/network-script/route-interface (one file for each interface. If not, you can only add a route for that interface)
The format is as follows:
Network/prefix via gateway dev intf
For example, add a default gateway to eth0:
Vim / etc/sysconfig/network-scripts/route-eth0
# add the following (dev eth0 can be omitted)
0.0.0.0/0 via 172.16.10.2 dev eth0
Ps: notice that the mask here is 0 instead of 32, because this is a network segment, not a route.
After saving exit, service network restart.
Use route-n or netstat-r to view the routing table.
[root@localhost ~] # route-n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.16.10.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
169.254.0.0 0.0.0.0 255.255.0.0 U 1002 00 eth0
0.0.0.0 172.16.10.2 0.0.0.0 UG 0 0 0 eth0
The default route has been added to the routing table.
Note that if you have two network cards, you need to set a default route to access the internet.
All methods of adding static routes have been verified on centos6.4 and are correct.
At this point, I believe you have a deeper understanding of "how to add static routes to CentOS6.5". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.