URL に IPv6 の IP アドレスを指定して http で開きたいのだが、
普通に http://::1/ とかすると
普通に http://::1/ とかすると
$ curl http://::1/ curl: (3) URL using bad/illegal format or missing URL
$ wget -O- http://::1/ http://::1/: ホスト名が不正です.
$ LANG=C wget -O- http://::1/ http://::1/: Invalid host name.みたいなエラーになる。
「http IPv6」でググってみたところ
どうも IPv6 では URL 中の IP アドレスを大括弧 [] で囲むんだそうな。
どうも IPv6 では URL 中の IP アドレスを大括弧 [] で囲むんだそうな。
$ echo -e "HTTP/1.1 200 OK\nContent-Length: 6\n\nhello" | nc -6 -l 8888 GET / HTTP/1.1 Host: [::1]:8888 User-Agent: curl/7.68.0 Accept: */*
$ curl http://[::1]:8888/ hello
$ echo -e "HTTP/1.1 200 OK\nContent-Length: 6\n\nhello" | nc -6 -l 8888 GET / HTTP/1.1 User-Agent: Wget/1.20.3 (linux-gnu) Accept: */* Accept-Encoding: identity Host: [::1]:8888 Connection: Keep-Alive
$ wget -SqO- http://[::1]:8888/ HTTP/1.1 200 OK Content-Length: 6 hello
タグ
コメントをかく