curl で host 指定する


host 指定したい

冗長構成のサーバーを IP 指定したいなー、という時は DNS サーバー(仮) の hosts ファイルでルーティングの設定入れると思います。

$ cat /etc/hosts

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##

172.16.1.1 example.qiita.com # example.qiita.com にアクセスしたらこの IP ですよという設定

hosts ファイルは即時反映されます。

curl でどうやるか?

--resolve オプション付ければできました。

$ curl --resolve example.qiita.com:443:172.16.1.1 https://example.qiita.com