https://docs.microsoft.com/en-us/windows/wsl/install

 

Install WSL

Install Windows Subsystem for Linux with the command, wsl --install. Use a Bash terminal on your Windows machine run by your preferred Linux distribution - Ubuntu, Debian, SUSE, Kali, Fedora, Pengwin, Alpine, and more are available.

docs.microsoft.com

윈도우즈 10 부터 wsl 이라고 linux 를 윈도우즈에서 가상머신으로 실행할 수 있게 되었다.

$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.26.0.1

wsl 내에서 host 윈도우즈의 mysql 과 같은 서비스에 접근하려면 host os 의 ip 를 알아야 하는데 고정된 ip 가 아니다. host 윈도우즈의 ipconfig 명령에서 WSL 목록이나 etc/resolv.conf 의 nameserver 항목을 통해 ip를 확인할 수 있다.

export WSL_WINDOWS_HOST=`cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 2`

고정시킬 수도 있지만 위와 같은 스크립트를 통해 host os 의 ip 를 확인할 수 있다. .profile, .bash_profile, .bashrc, .zshrc, .zprofile 과 같은 사용하는 쉘 초기화 스크립트에 넣어두면 유용하게 쓸 수 있다.

출처 : https://github.com/Microsoft/WSL/issues/1032

 

How to access host ip and port? · Issue #1032 · microsoft/WSL

I am using bash on windows 10. i want to access host ip:port there be service listen on 0.0.0.0:80 of host windows 10. how do i access to host windows 10 port?

github.com

 

728x90

+ Recent posts