hosts

先日PCをリカバリしたのですが、そしたらローカルにある外部公開用サーバにホスト名でアクセスできなくなってちょっと焦りました。万全にバックアップしていたつもりでも、結構忘れている設定などがあります。メモっときます。


これはhostsというファイルに書き加えることで解決できます。Vistaでは C:\Windows\System32\drivers\etc\hosts という場所にあります。これをテキストエディタで開くと、初期状態では以下のように書かれています。

# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

127.0.0.1       localhost
::1             localhost

これに、サーバに外部からアクセスするときのホスト名と、それに対応するローカルのIPアドレスを書き加えます。

127.0.0.1       localhost
::1             localhost
192.168.1.5	notiz.dyndns.org

pingを打ってみてチェックしましょう。

C:\Users\Owner>ping notiz.dyndns.org

notiz.dyndns.org [192.168.1.5]に ping を送信しています
192.168.1.5 からの応答: バイト数 =32 時間 =2ms TTL=64
192.168.1.5 からの応答: バイト数 =32 時間 =1ms TTL=64
192.168.1.5 からの応答: バイト数 =32 時間 =4ms TTL=64