centos6彻底禁止ipv6
在centos6.x上 wget很慢 yum很慢 ping dig nslookup解析很慢 ssh很慢的解决办法.
无论在wget yum dig等操作下,tcpdump抓包就能看到向dns 8.8.8.8查询的时候带有一堆的AAAA请求
- 06:59:49.576542 IP My_Server_IP.19386 > google-public-dns-a.google.com.domain: 52066+ AAAA? mirrors.hust.edu.cn. (37)
- 06:59:54.581342 IP My_Server_IP.19386 > google-public-dns-a.google.com.domain: 52066+ AAAA? mirrors.hust.edu.cn. (37)
- 06:59:59.581265 IP My_Server_IP.7213 > google-public-dns-a.google.com.domain: 52066+ AAAA? mirrors.hust.edu.cn. (37)
- 07:00:04.617841 IP My_Server_IP.18852 > google-public-dns-a.google.com.domain: 31615+ AAAA? ftp.riken.jp. (30)
- 07:00:09.618578 IP My_Server_IP.18852 > google-public-dns-a.google.com.domain: 31615+ AAAA? ftp.riken.jp. (30)
- 07:00:14.618085 IP My_Server_IP.44953 > google-public-dns-a.google.com.domain: 31615+ AAAA? ftp.riken.jp. (30)
- 07:00:19.741115 IP My_Server_IP.7737 > google-public-dns-a.google.com.domain: 42754+ AAAA? ftp.jaist.ac.jp. (33)
- 07:00:24.742248 IP My_Server_IP.7737 > google-public-dns-a.google.com.domain: 42754+ AAAA? ftp.jaist.ac.jp. (33)
- 07:00:29.742465 IP My_Server_IP.14624 > google-public-dns-a.google.com.domain: 42754+ AAAA? ftp.jaist.ac.jp. (33)
- 07:00:34.881076 IP My_Server_IP.29094 > google-public-dns-a.google.com.domain: 16330+ AAAA? mirrors.neusoft.edu.cn. (40)
- 07:00:39.886034 IP My_Server_IP.29094 > google-public-dns-a.google.com.domain: 16330+ AAAA? mirrors.neusoft.edu.cn. (40)
- 07:00:44.890210 IP My_Server_IP.44688 > google-public-dns-a.google.com.domain: 16330+ AAAA? mirrors.neusoft.edu.cn. (40)
- 1)
- 增加 /etc/sysctl.conf
- net.ipv6.conf.all.disable_ipv6 = 1
- net.ipv6.conf.default.disable_ipv6 = 1
- 2)
- 修改 /etc/sysconfig/network
- 增加 NETWORKING_IPV6=no
- 3)
- 新建 /etc/modprobe.d/ipv6.conf
- alias net-pf-10 off
- alias ipv6 off
- 4)
- 打开 /etc/wgetrc
- 增加 inet4_only=on
- 5)
- 打开 /etc/yum.conf
- 修改 keepcache=1
- 6)
- 打开 /etc/resolv.conf
- options single-request
- nameserver 8.8.8.8
- 7)
- 重启