やりたいこと
LinuxやMacみたいに、Windows + WSL2 でも hostsファイルを書き換えて、色んなドメイン名をローカルで使いたい
How to
- WSL2からWindowsのIPを確認
cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 2
-
C:\Windows\System32\drivers\etc\hosts
を編集\Windows\System32\drivers\etc\hosts172.21.160.1 kuchitama.com 172.21.160.1 test1.kuchitama.com
-
WSL2を再起動
wsl --shutdown
完了
参考記事
how to associate windows hosts file entry with process running on WSL