Centos dual-line dual-ip server route settings

Source: Internet
Author: User
In order to allow China Unicom and telecom users to quickly access the website, the company's server is hosted in a dual-line dual-ip data center. When the server uses dual-line dual-ip addresses, you need to configure the route table. the solution provided by the IDC is to enter the static route table. The method is to use the China Telecom gateway as the default route, and then manually enter the routing rules for all the IP address segments of the China Netcom. This method has many drawbacks: 1. it is too troublesome to add rules. if some network segments are missing, users of these network segments will not be able to access the website. 2. d. in order to allow China Unicom and telecom users to quickly access the website, the company's server is hosted in a dual-line dual-ip data center. When the server uses dual-line dual-ip addresses, you need to configure the route table. the solution provided by the IDC is to enter the static route table. The method is to use the China Telecom gateway as the default route, and then manually enter the routing rules for all the IP address segments of the China Netcom.
This method has many drawbacks:
1. adding rules is too complicated. if some network segments are missed, users of these network segments will not be able to access the website.
2. when the route of dns Intelligent Resolution is different from the static route CIDR block entered, users will not be able to access our website.
3. the distribution of CIDR blocks is constantly changing. the route table must be updated on a regular basis.
Solution:
Using dynamic routing, the server sets a dynamic route based on the path accessed by the user. if the user accesses the route through a telecom IP address, the gateway is used for routing and the returned content is sent to the telecom gateway; if you access the service through the China Unicom IP address, use the China Unicom gateway for routing and the returned content is sent to the China Unicom gateway.
After testing on the website backup server, using dynamic route tables can solve the disadvantages of static route tables.
The specific method is as follows:
Assume that the IP address assigned by the server is as follows:
China Telecom Gateway: 59.83.100.1; China Telecom ip: 59.83.100.10.
China Unicom Gateway: 221.214.100.1; China Unicom ip: 221.214.100.10.
1. edit the rt_tables file and add the China Unicom route table
# Vi/etc/iproute2/rt_tables # (two route tables of China Telecom and China Unicom are added)

Add China Unicom route table
252 tel
251 cnc
2. edit the rc. local file and set the content of the route table of China Telecom and China Netcom.
1
# Vi/etc/rc. d/rc. local # (set the content of the China Telecom and China Netcom route table)
Add the following content:

Ip route replace default via 59.83.100.1 dev eth0 # default route line ip route flush table tel # refresh tel route table ip route add default via 59.83.100.1 dev eth0 src 59.83.100.10 table tel # add Loop address ip rule add from 59.83.100.10 table tel # from 59.83.100.10, route through tel ip route flush table cnc # refresh the cnc route table ip route add default via 221.214.100.1 dev eth1 src 221.214.100.10 table cncip rule add from 221.214.100.10 table cnc # route through 221.214.100.10

Test the reboot server!
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.