akishin999の日記

調べた事などを書いて行きます。

VMware Player 上の CentOS で yum が使えない

VMware Player 上に CentOS 6.2 をインストールしたのですが(ネットワークは NAT)、yum を実行すると以下のようなエラーが発生してしまいました。

# yum update
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=i386&repo=os error was
14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"
Error: Cannot find a valid baseurl for repo: base

ホスト名 mirrorlist.centos.org が解決できないと言っているようですが、ping や nslookup では問題なく解決できています。
PYCRUL と出ていたので、試しに curl コマンドで同じ URL を指定してみると、以下のような似たエラーに。

# curl 'http://mirrorlist.centos.org/?release=6&arch=i386&repo=os'
curl: (6) Couldn't resolve host 'mirrorlist.centos.org'

これはもしや curl の問題?
と思い検索していると、以下の方がズバリ解決方法を書いてくれていました。

cURLのname lookup timed、Couldn't resolve hostエラーを解決 - 住宅購入と新米パパと、時々、IT - 楽天ブログ(Blog)
http://plaza.rakuten.co.jp/punpunchan2/diary/201001050000/

どうも VMware 上の CentOSIPv6 が有効になっていると発生する事象のようです。
記事内で紹介されていた、以下の方法の通りに IPv6 を無効にしたところ、無事 yum が使えるようになりました。

れぶろぐ - [CentOS] CentOS 5 で IPv6 を本当に無効にする
http://www.revulo.com/blog/20080514.html

毎度の事ながら、IPv6 周りの設定が原因で挙動がおかしくなる場合、エラーから原因がなかなか推測できないので調査に時間がかかってしまうのが難ですね・・・。