6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

hosts ファイルを編集せずに curl で名前解決する

Last updated at Posted at 2019-09-10

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
6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?