WSL2でhostsの書き換え
やりたいこと
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\hosts
172.21.160.1 kuchitama.com
172.21.160.1 test1.kuchitama.com
-
WSL2を再起動
wsl --shutdown
完了
参考記事
cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 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
WSL2を再起動
wsl --shutdown
完了
how to associate windows hosts file entry with process running on WSL
Author And Source
この問題について(WSL2でhostsの書き換え), 我々は、より多くの情報をここで見つけました https://qiita.com/Kuchitama/items/26b75740323dc0dc6a94著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .