7
4

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 3 years have passed since last update.

WSL2でhostsの書き換え

Posted at

やりたいこと

LinuxやMacみたいに、Windows + WSL2 でも hostsファイルを書き換えて、色んなドメイン名をローカルで使いたい

How to

  1. WSL2からWindowsのIPを確認

    • cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 2
  2. C:\Windows\System32\drivers\etc\hosts を編集

    \Windows\System32\drivers\etc\hosts

172.21.160.1 kuchitama.com
172.21.160.1 test1.kuchitama.com
```
3. WSL2を再起動
- wsl --shutdown
4. 完了

参考記事

how to associate windows hosts file entry with process running on WSL

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?