> CentOS > CentOS故障 >

CentOS关闭IPv6报错解决办法

关闭IPv6

1、问题:使用yum下载东西的时候提示有一个IPv6的地址不可达,如下
http://download.fedoraproject.org/pub/epel/6/x86_64/repodata/924f970f6436162727781050e63524af37f891ba57c8a374cdd0a87e53d89180-filelists.sqlite.bz2: [Errno 14] PYCURL ERROR 7 - "Failed to connect to 2001:da8:8000:6023::230: Network is unreachable"
Trying other mirror.
Error: failure: repodata/924f970f6436162727781050e63524af37f891ba57c8a374cdd0a87e53d89180-filelists.sqlite.bz2 from epel: [Errno 256] No more mirrors to try.
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest



2、查看本机网卡配置,eth2上的确开了ipv6 inet6
[root@lvs05091 ~]# ifconfig -a
eth2      Link encap:Ethernet  HWaddr 00:50:56:A5:2F:9D 
          inet addr:192.168.5.91  Bcast:192.168.5.255  Mask:255.255.255.0
          inet6 addr: fe80::250:56ff:fea5:2f9d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:522 errors:0 dropped:0 overruns:0 frame:0
          TX packets:138 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:42263 (41.2 KiB)  TX bytes:19212 (18.7 KiB)
[root@lvs05091 modprobe.d]# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address               Foreign Address             State     
tcp        0      0 :::111                      :::*                        LISTEN     
tcp        0      0 :::22                       :::*                        LISTEN     
tcp        0      0 ::1:25                      :::*                        LISTEN     
tcp        0      0 :::37256                    :::*                        LISTEN     
::代表IPv6



3、关闭IPv6
修改sysctl.conf配置文件,加入如下内容
[root@lvs05091 etc]# vi sysctl.conf
#shutdown IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
是修改配置生效
[root@lvs05091 etc]# sysctl -p
重启网卡:service network restart
备注:上面是永久关闭IPv6
也可以零时关闭,下次开机IPv6还会开启
echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6



4、再来查看接口配置,可以看到ipv6地址不在了
[root@lvs05091 etc]# ifconfig -a
eth2      Link encap:Ethernet  HWaddr 00:50:56:A5:2F:9D 
          inet addr:192.168.5.91  Bcast:192.168.5.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2336 errors:0 dropped:0 overruns:0 frame:0
          TX packets:839 errors:0 dropped:0 overruns:0 carrier:0

这个时候使用yum下载东西就正常了。
(责任编辑:IT)