天天看點

CentOS 關閉IPv6及運作yum報錯解決辦法

問題一:關閉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

          RX packets:2336 errors:0 dropped:0 overruns:0 frame:0

          TX packets:839 errors:0 dropped:0 overruns:0 carrier:0

這個時候使用yum下載下傳東西就正常了。

問題二:運作yum報Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again

1、解決辦法:

vi /etc/yum.repos.d/epel.repo

編輯[epel]下的baseurl前的#号去掉,mirrorlist前添加#号。正确配置如下:

[epel]

name=Extra Packages for Enterprise Linux 6 - $basearch

baseurl=http://download.fedoraproject.org/pub/epel/6/$basearch

#mirrorlist=https://mirrors.fedoraproject.org/metalink?repo=epel-6&arch=$basearch

failovermethod=priority

enabled=1

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

注意:上面的說有的baseurl都放行

所有的mirrorlist都在用#登出掉

繼續閱讀