Slow-DNS-lookup problem: ipv6-dns-lookup is enabled by default so that you have to wait for timeout

Source: Internet
Author: User
@ Zheng yu Summary

 

I. symptom: Java httpclient initiates an HTTP request to the WebService interface under the x××× open. x××. com domain name from the master station data center, which is extremely slow. Troubleshooting: 1.1. wget test results No Specify the IP protocol and the interface for wget to access it. The time is 4.163 seconds, which is basically a waste of host parsing. If the IP protocol of the specified wget is IPv4, The wget test takes only 0.096 seconds. 1.2. WGEt Comparison test: NoSpecify the IP protocol. The time for wget to access another e-commerce interface is 0.798 seconds. 1.3. Dig  Analysis Open. ×××. com : It is found that when resolving open. ×××. com, cname will be added to a global variable, and then the global variable will select the optimal line for access. Ii. possible causes of slow-DNS-Resolution: 1) The browser browses the xxx interface quickly and cannot prove anything. . For example, Firefox disables IPv6 DNS lookup by default: 2) Ubuntu introduces a problem starting from 10.4: IPv6 is enabled by default in the operating system, leading to some applications Program When an HTTP request is sent, the IPv6 DNS lookup always times out before IPv4 intervention (usually reported to take about 30 seconds), which is also a common cause of slow DNS lookup process. 3) Some people reported: "One day, the O & M Department declared that the company's network had all enable IPv6. After that, when using the PHP curl function or using wget in Linux to access an internal domain name, it takes about five seconds to get the results. The reason is that an IPv6 address is not bound to this domain name. During wget, IPv6 DNS lookup times out. Many servers now enable IPv6 without routing and cannot work, which leads to unexpected problems .』 In short, this should be related to the ipv6-dns-lookup. Iii. Reasons: ×××× Adjusted the network access device to solve the problem. Cause: 1) ××××f5 GTM device (gslb, global load balancing) is what we often call intelligent DNS. 2)   Domain names requiring users in different regions to access different IDC nodes   Use F5 GTM for parsing. 3) its device may have IPv6 enabled by default, but IPv6 addresses are not configured for different domain names. 4. background knowledge of ipv6-dns-lookup: 4.1. How does IPv6 work on the Java platform? Not all operating systems support the IPv6 protocol. Even if Java networking stack tries to detect it first and uses it transparently when it discovers it is available, it can also be disabled by using system attributes. When IPv6 is unavailable or explicitly disabled, inet6address   Most network connection operations are no longer valid parameters. Reference   Javase IPv6 Guide   Document: "Step 1, Java networking stack   Check whether the underlying operating system supports IPv6. If IPv6 is supported, Java will try to use   IPv6 Stack . Step 2: Double stack An IPv6 socket will be created on an IPv4 stack + IPv6 stack system. In   Separate-Stack   In the system, things are much more complicated. Java will create two sockets, one for IPv4 and the other for IPv6. Step 3: for client TCP applications, once the socket is connected Internet-protocol family type   It's fixed, and the extra socket is closed. For TCP applications on the server, the two sockets will be retained because they do not know the IP family type used for the next client request. For UDP applications, both sockets always need to be retained .』 4.2. IPv6-related system parameters The system has two parameters: 1) preferred Protocol Stack : IPv4 or IPv6; 2) preferred Address Family (Address family type): inet4 or inet6. 4.2.1. Protocol Stack In a dual-stack system, IPv6 socket can interact with IPv4 and IPv6 peer.  IPv6 stack is the default preference . You can modify the configuration using the following system parameters: Java.net. preferipv4stack = <true | false> Corresponding Java Code Yes: Java. Lang. system. setproperty ("java.net. preferipv4stack", "true "); 4.2.2. Address Family By default, we prefer the IPv4 address family. You can modify the configuration using the following system parameters: Java.net. preferipv6addresses = <true | false> The corresponding Java code is: Java. Lang. system. setproperty ("java.net. preferipv6addresses", "false "); 4.3. How to disable IPv6 on Linux:

Edit/etc/sysconfig/network. (A reboot will be required)
# Vi/etc/sysconfig/Network

Change:
Networking_ipv6 = Yes

To:
Networking_ipv6 = No
Disable IPv6 protocol stack for Kernel
DisableIPv6Kernel module

Edit/etc/modprobe. conf.
# Vi/etc/modprobe. conf

Add the following 2 lines: (A reboot will be required)
Alias net-pf-10 off
Alias IPv6 off

 

4.4. IPv6 settings on F5: It is said that the following command can be used to set the BIG-IP to disable IPv6: Bigpipe dB defaults 6.enabled false Bigpipe save all   The BIG-IP has IPv6-related parameter defaults as follows: ipv6.enabled = true
Limit 6.nbr. delaytime = 1
Required 6.nbr. incompletetimeout = 5
6.nbr. maxentries = 2048
20176.nbr. reachabletimeout = 30
Listen 6.nbr. reaptimeout = 3600
6.nbr. retries = 2 Appendix: The IPv4 and IPv6 input options of wget :' -4 '' Inet4-only '' -6 '' Inet6-only 'Force ing to IPv4 or IPv6 ses SSEs.' Inet4-only 'Or' -4 ', Wget will only connect to IPv4 hosts, ignoring AAAA records in DNS, and refusing to connect to IPv6 addresses specified in URLs. Conversely,' Inet6-only 'Or' -6 ', Wget will only connect to IPv6 hosts and ignore a Records and IPv4 addresses.
Reference resources: (1) 2012, Curl_exec and wget are too slow to execute, which is caused by IPv6.

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.