0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Linux】/etc/hostsでローカルのDNS設定

Last updated at Posted at 2023-10-16

状況

ローカル環境において、ホスト名(VIP)とIPアドレスの紐付けを行いたい

手順

$ sudo vim /etc/hosts

[紐付けたいIP] [VIP]

を追加するだけ。

具体例

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
123.456.789.000 qiita.com

これだけ

あとは

$ ping [ホスト名]

を実行して

PING [ホスト名] ([紐付けたIPアドレス]): 56 data bytes

64 bytes from [紐付けたIPアドレス]: icmp_seq=0 ttl=55 time=37.822 ms

64 bytes from [紐付けたIPアドレス]: icmp_seq=1 ttl=55 time=33.661 ms

64 bytes from [紐付けたIPアドレス]: icmp_seq=2 ttl=55 time=29.932 ms

64 bytes from [紐付けたIPアドレス]: icmp_seq=3 ttl=55 time=30.933 ms

のような出力を得られればグッド👍疎通確認成功。

最後にホスト名を含んだURLを叩いてページが開けるのを確認しておしまい。

ローカル確認後、/etc/hostsの変更を元に戻すのをお忘れなく。

参考 https://wa3.i-3-i.info/word11760.html

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?