How do I connect to my IP in WSL from the internet?

Inhahe 1 Reputation point
2022-10-04T23:51:30.71+00:00

I'm running an IRC bouncer in Ubuntu in WSL on Windows 10. I want to connect to it from my IRC client automatically, but the problem is my WSL IP seems to be different every time I run WSL, or at least every time I boot Windows. So I guess I need either a fixed WSL IP somehow or an actual name I can put into my IRC client that resolves to the current IP. My WSL IP is currently 172.19.150.186. I don't know what kind of IP that is, I don't know why it's not a 192.168.x.x IP and it's not the IP I get when I put "what is my ip ipv4" into Google either. Also it doesn't seem to show up in the list of devices I can forward a port to in my router's NAT.

I also want to be able to connect to the bouncer over the internet, so I can use it on my mobile IRC client. But to do that I need to forward the port in my router, and, again, the WSL IP doesn't seem to show up in the list in the router's port forwarding.

Thanks for any help.

Windows for business | Windows Client for IT Pros | Networking | Network connectivity and file sharing
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 39,926 Reputation points
    2022-10-06T10:12:03.793+00:00

    Hello there,

    Can you temporarily take down the firewall and check the list?

    WSL2 comes by default in NAT mode. There the wsl2 system has another ip in another subnet than the host. The PC is from external peers only visible by the windows IP and the wsl2 ip/net is hidden/internal. So all traffic would need to be accepted by the windows IP and then forwarded to the wsl2 ip (port forwarding).

    There is another mode called bridge mode. In bridge mode your network interface card will be shared to the wsl2 system, and it will get its own IP/Net in wsl2. So in effect your network card is shared to both systems (windows / wsl2) and will have two IPs, as if you'd have two systems with its own network card each.

    Additional info here , Accessing Windows networking apps from Linux (host IP) https://learn.microsoft.com/en-us/windows/wsl/networking

    ------------------------------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments

  2. Inhahe 1 Reputation point
    2022-10-07T17:52:59.623+00:00

    Hi, I'm not sure what you mean by taking down the firewall and checking the list. How do I do that, and what list am I checking?

    So, I'd need to know how to forward the Windows IP on that port to the WSL2 IP, and there's the problem that the WSL2 IP is always changing..

    Or I could try bridge mode, if you tell me how to do that. If I do that, I guess my WSL2 system will show up in my router's port forwarding options?

    Thanks.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.