Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set up DNS polling in linux to achieve load balancing

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to set up DNS polling in linux to achieve load balancing". In daily operation, I believe many people have doubts about how to set up DNS polling in linux to achieve load balancing. The editor has consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to set DNS polling to achieve load balancing in linux". Next, please follow the editor to study!

However, there is one parameter you can try to see if you can adjust the effect of polling:

In named.conf, you can set the order in which the round-robin of bind gives the results:

Options {rrset-order {order random;};}

Rrset-order supports three parameters: fixed, random, and cyclic.

Fix will give multiple A records in the order of configuration files.

Random will randomly give

Cyclic loops to give

DNS polling means that the DNS server distributes domain name resolution requests to different IP one by one in the order of A records, and achieves simple load balancing to some extent.

Let's take a look at how to set up DNS polling under WINDOWS2003. For example, there are two WEB hosts, the A host ip is 192.168.1.1, and the B host ip is 192.168.1.4. There is a separate DNS server in the enterprise, and then two host A records are established in the forward area of the DNS server (domain name is haiquan.net). The first host record IP is 192.168.1.1, and the second host record IP is 192.168.1.4.

Transfer: linux to achieve DNS polling to achieve load balancing

Then right-click on the DNS host QINGYG and select Properties, and check "enable Loop" in the dialog box that appears, as shown in the figure:

Note: netmask sorting can determine whether the dns address and the client are on the same network segment or close to each other according to the subnet mask, and then give priority to returning the address of the closer server.

After setting up, let's take a look at the effect:

Note: WINDOWS caches DNS results. In order to observe polling, we need to use "ipconfig / flushdns" to clear the DNS cache.

Let's take a look at how to set DNS polling under LINUX, taking RHEL 5 as an example:

1. First, you need to install BIND and build a DNS server (for specific DNS building process, please refer to relevant materials)

# yum install-y bind* caching-nameserver*

Installing the DNS server generally requires the following three packages to be installed:

Bind-utils-9.3.3-7.el5

Query use

Bind-chroot-9.3.3-7.el5

Security mechanism

Caching-nameserver-9.3.3-7.el5

Configuration file

2. Modify the zone data configuration file (example.com.db). Here is a look at the DNS polling configuration.

IN MX 10 mail.example.com.... ... mail IN A 192.168.1.9IN A 192.168.1.10IN A 192.168.1.11

In the above configuration, mail.example.com corresponds to three IP addresses, and which A record is selected at this time is determined by the rrset-order statement. In addition, in the reverse parsing file, the three IP should also correspond to the mail host, so as to avoid problems when some mail servers do reverse queries for anti-spam.

This is an example of an options statement about rrset-order configuration in the / etc/named.conf file:

Rrset-order {class IN type A name "mail.example.com" order random;order cyclic;}

This setting causes the responses of the A records in the IN class to be returned in random order, with the IN class suffixed with "mail.example.com". Other records are returned as circular records.

Rrset-order supports three parameters: fixed, random, and cyclic.

Fixed gives multiple A records in the order of configuration files.

Random randomly gives

The cyclic loop gives

Note: the rrset-order statement is not supported by BIND9. BIND9 currently only supports "random-cyclic" sorting. The server randomly selects the starting point in the RRset set and sequentially returns the records starting at that point.

3. Test results:

[root@linux252:/] # host mail.example.commail.example.com has address 192.168.1.9mail.example.com has address 192.168.1.10mail.example.com has address 192.168.1.11

To sum up:

The configuration of DNS polling is relatively convenient. If the network is expanded, the newly added Web server only needs to add a public network IP. But relatively speaking, DNS polling also has its own shortcomings, this work is also what we need to pay attention to.

One: if a server goes down, the DNS server is unknowable and will still assign access to this server. It usually takes 1-3 hours or even longer to modify DNS records to take effect.

Second: if the hardware configuration of several Web servers is different, the pressure that can be withstood is also different, but DNS polling resolution can not be well distributed according to weight.

Third: if it is a Web site that requires authentication, DNS parsing cannot persistently assign the access of authenticated users to the same server. Although there is a certain local DNS cache, it is difficult to ensure that during the user visit, the local DNS is out of date, and the server is re-queried and pointed to the new server, then the user information saved by the original server cannot be brought to the new server, and may be required to re-authenticate the identity, and the switching time to and from each server saves different user information, which is also a waste of server resources.

At this point, the study on "how to set up DNS polling for load balancing in linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report