centos6彻底禁止ipv6

在centos6.x上 wget很慢 yum很慢 ping dig nslookup解析很慢 ssh很慢的解决办法.

无论在wget yum dig等操作下,tcpdump抓包就能看到向dns 8.8.8.8查询的时候带有一堆的AAAA请求

  1. 06:59:49.576542 IP My_Server_IP.19386 > google-public-dns-a.google.com.domain: 52066+ AAAA? mirrors.hust.edu.cn. (37)
  2. 06:59:54.581342 IP My_Server_IP.19386 > google-public-dns-a.google.com.domain: 52066+ AAAA? mirrors.hust.edu.cn. (37)
  3. 06:59:59.581265 IP My_Server_IP.7213 > google-public-dns-a.google.com.domain: 52066+ AAAA? mirrors.hust.edu.cn. (37)
  4. 07:00:04.617841 IP My_Server_IP.18852 > google-public-dns-a.google.com.domain: 31615+ AAAA? ftp.riken.jp. (30)
  5. 07:00:09.618578 IP My_Server_IP.18852 > google-public-dns-a.google.com.domain: 31615+ AAAA? ftp.riken.jp. (30)
  6. 07:00:14.618085 IP My_Server_IP.44953 > google-public-dns-a.google.com.domain: 31615+ AAAA? ftp.riken.jp. (30)
  7. 07:00:19.741115 IP My_Server_IP.7737 > google-public-dns-a.google.com.domain: 42754+ AAAA? ftp.jaist.ac.jp. (33)
  8. 07:00:24.742248 IP My_Server_IP.7737 > google-public-dns-a.google.com.domain: 42754+ AAAA? ftp.jaist.ac.jp. (33)
  9. 07:00:29.742465 IP My_Server_IP.14624 > google-public-dns-a.google.com.domain: 42754+ AAAA? ftp.jaist.ac.jp. (33)
  10. 07:00:34.881076 IP My_Server_IP.29094 > google-public-dns-a.google.com.domain: 16330+ AAAA? mirrors.neusoft.edu.cn. (40)
  11. 07:00:39.886034 IP My_Server_IP.29094 > google-public-dns-a.google.com.domain: 16330+ AAAA? mirrors.neusoft.edu.cn. (40)
  12. 07:00:44.890210 IP My_Server_IP.44688 > google-public-dns-a.google.com.domain: 16330+ AAAA? mirrors.neusoft.edu.cn. (40)
  13.  
  14. 1)
  15. 增加 /etc/sysctl.conf
  16. net.ipv6.conf.all.disable_ipv6 = 1
  17. net.ipv6.conf.default.disable_ipv6 = 1
  18.  
  19. 2)
  20. 修改 /etc/sysconfig/network
  21. 增加 NETWORKING_IPV6=no
  22.  
  23. 3)
  24. 新建 /etc/modprobe.d/ipv6.conf
  25. alias net-pf-10 off
  26. alias ipv6 off
  27.  
  28. 4)
  29. 打开 /etc/wgetrc
  30. 增加 inet4_only=on
  31.  
  32. 5)
  33. 打开 /etc/yum.conf
  34. 修改 keepcache=1
  35.  
  36. 6)
  37. 打开 /etc/resolv.conf
  38. options single-request
  39. nameserver     8.8.8.8
  40.  
  41. 7)
  42. 重启
1 1