[Ubuntu] 解決 apt-get 更新時因為 IPv6 卡住問題

本篇文章更新時間:2019/02/16
如有資訊過時或語誤之處,歡迎使用 Contact 功能通知。
一介資男的 LINE 社群開站囉!歡迎入群聊聊~
如果本站內容對你有幫助,歡迎使用 BFX Pay 加密貨幣新台幣 贊助支持。


這問題時不時會出現在安裝新機器的時候,之前好像是「反正就放給他timeout」的消極做法,剛剛居然谷歌到神方法!

參考:apt-get update stuck: Connecting to security.ubuntu.com

一堆解法說:「乾脆你就把 IPv6 給關了吧! 」這種又血腥又暴力的做法我實在不是很想用~

這次的解法是針對請求內容時「IPv4 的權重為先」,如此而已!方法如下:


vi /etc/gai.conf

找到 #precedence ::ffff:0:0/96 100 然後解註解,存擋,搞定!

#技術相關 -get

- Powered by Mxp.TW -FB2WP-


Share:

作者: Chun

資訊愛好人士。主張「人人都該為了偷懶而進步」。期許自己成為斜槓到變進度條 100% 的年輕人。[///////////____36%_________]

參與討論

  1. fashionshow0
  2. im
  3. leon0824
  4. Chun
  5. meghakhateekmk1

5 則留言

  1. 印象中不用這麼麻煩 apt-get 有直接可以用 Ipv4 的選項

    1. 是這篇(http://unix.stackexchange.com/questions/9940/convince-apt-get-not-to-use-ipv6-method)

      提到的方式? 似乎程序沒差多少啊XD

  2. Encountering installation issues while setting up a new server can be frustrating. I recently faced a similar problem when trying to run `apt-get update`, where it would freeze when connecting to security.ubuntu.com. After reading numerous guides, the advice to “just turn off IPv6” was a common suggestion. However, I didn’t want to disable it entirely.

    I found a more elegant solution that involves simply prioritizing IPv4 over IPv6. By editing the `/etc/gai.conf` file and uncommenting the line `#precedence ::ffff:0:0/96 100`, I was able to resolve the issue and continue with the update process smoothly.

    During my troubleshooting journey, I also found a helpful guide on install python ubuntu, which provided valuable insights for other aspects of my server configuration. Happy to share this solution in case it helps someone else.

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *


文章
Filter
Apply Filters
Mastodon