WGetを使用して何かをダウンロードしようとすると、ドメイン名がIPv6アドレスに変換されると通常失敗します。
これはリンクリダイレクトがある場合より一般的です。
たとえば、
$ wget --inet6-only https://raw.githubusercontent.com/walkxcode/Dashboard-Icons/main/png/ebay.png
--2022-11-13 10:27:05-- https://raw.githubusercontent.com/walkxcode/Dashboard-Icons/main/png/ebay.png
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 2606:50c0:8001::154, 2606:50c0:8000::154, 2606:50c0:8003::154, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|2606:50c0:8001::154|:443...
$ wget --inet6-only https://download.docker.com/linux/centos/9/x86_64/stable/Packages/docker-ce-20.10.21-3.el9.x86_64.rpm
--2022-11-13 10:32:52-- https://download.docker.com/linux/centos/9/x86_64/stable/Packages/docker-ce-20.10.21-3.el9.x86_64.rpm
Resolving download.docker.com (download.docker.com)... 2600:9000:21ed:e000:3:db06:4200:93a1, 2600:9000:21ed:2e00:3:db06:4200:93a1, 2600:9000:21ed:7000:3:db06:4200:93a1, ...
Connecting to download.docker.com (download.docker.com)|2600:9000:21ed:e000:3:db06:4200:93a1|:443...
最初の例では、raw.githubusercontent.com
名前はで解決されます2606:50c0:8001::154, 2606:50c0:8000::154, 2606:50c0:8003::154
。その後、WGgetはそのIPに接続しようとしますが、何も起こらずに停止します。ダウンロードは進行しません。 2番目の例でも同じことが起こりますdownload.docker.com
。
IPv4接続を強制的に実行すると、コンテンツは正常にダウンロードされます。
$ wget --inet4-only https://raw.githubusercontent.com/walkxcode/Dashboard-Icons/main/png/ebay.png
--2022-11-13 10:28:16-- https://raw.githubusercontent.com/walkxcode/Dashboard-Icons/main/png/ebay.png
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.108.133, 185.199.110.133, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 24872 (24K) [image/png]
Saving to: ‘ebay.png’
ebay.png 100%[==================================================================================>] 24.29K --.-KB/s in 0.005s
2022-11-13 10:28:16 (4.48 MB/s) - ‘ebay.png’ saved [24872/24872]
$ wget --inet4-only https://download.docker.com/linux/centos/9/x86_64/stable/Packages/docker-ce-20.10.21-3.el9.x86_64.rpm
--2022-11-13 10:34:35-- https://download.docker.com/linux/centos/9/x86_64/stable/Packages/docker-ce-20.10.21-3.el9.x86_64.rpm
Resolving download.docker.com (download.docker.com)... 52.84.83.27, 52.84.83.65, 52.84.83.79, ...
Connecting to download.docker.com (download.docker.com)|52.84.83.27|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 21654080 (21M) [binary/octet-stream]
Saving to: ‘docker-ce-20.10.21-3.el9.x86_64.rpm’
docker-ce-20.10.21-3.el9.x86_64.rpm 100%[==================================================================================>] 20.65M 27.3MB/s in 0.8s
2022-11-13 10:34:36 (27.3 MB/s) - ‘docker-ce-20.10.21-3.el9.x86_64.rpm’ saved [21654080/21654080]
IPv6を使用するとWGetが失敗するのはなぜですか?