Skip to content

[WSL2] Possible misconfigured IP address #4192

Closed

Description

  • Your Windows build number: Microsoft Windows [Version 10.0.18917.1000]

I initially configured WSL2 on this machine, and networking seemed to work fine (ip addr | grep eth0 gave me the IP address of the WSL2 VM, and that worked fine for a while).

Now, ipconfig on Windows returns 172.17.178.49 as the IP address of the WSL2 machine:

Ethernet adapter vEthernet (WSL):

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::99d2:6eaf:e153:d098%23
   IPv4 Address. . . . . . . . . . . : 172.17.178.49
   Subnet Mask . . . . . . . . . . . : 255.255.255.240
   Default Gateway . . . . . . . . . :

But ip addr | grep eth0 on WSL 2 returns 172.17.178.50:

4: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000                                                             link/ether 00:15:5d:dc:ee:2d brd ff:ff:ff:ff:ff:ff                                                                                                    inet 172.17.178.50/16 brd 172.17.255.255 scope global eth0                                                                                               valid_lft forever preferred_lft forever                                                                                                            inet6 fe80::215:5dff:fedc:ee2d/64 scope link                                                                                                             valid_lft forever preferred_lft forever 

Currently, I cannot access any ports of WSL from Windows (tried both the IP address returned by Windows, and the one returned by Linux), even though they are accessible on localhost from Linux:

$ curl -I localhost:8080                                                                                                                 HTTP/1.1 200 OK
PS C:\Users\root> curl 172.17.178.50:8080                                                                                                                                  curl : Unable to connect to the remote server                                                                                                                              At line:1 char:1                                                                                                                                                           + curl 172.17.178.50:8080                                                                                                                                                  + ~~~~~~~~~~~~~~~~~~~~~~~                                                                                                                                                      + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebException                                                   + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand                                                                                                                                                                                                                                     ```

Activity

  1. radu-matei commented on Jun 19, 2019

    @radu-matei
    Author

    Did another shutdown of WSL, then restarted the machine:

    Ethernet adapter vEthernet (WSL):
    
       Connection-specific DNS Suffix  . :
       Link-local IPv6 Address . . . . . : fe80::6c0a:1956:b0a6:6bb2%23
       IPv4 Address. . . . . . . . . . . : 172.18.72.145
       Subnet Mask . . . . . . . . . . . : 255.255.255.240
       Default Gateway . . . . . . . . . :
    

    (there is no default gateway configured - should there be one?)

    3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether 00:15:5d:05:88:23 brd ff:ff:ff:ff:ff:ff
        inet 172.18.72.147/16 brd 172.18.255.255 scope global eth0
           valid_lft forever preferred_lft forever
        inet6 fe80::215:5dff:fe05:8823/64 scope link
           valid_lft forever preferred_lft forever
    

    But /etc/resolv.config seems to have te correct address:

    ~$ 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.18.72.145
    
  2. jkasten2 commented on Jun 19, 2019

    @jkasten2

    Radu Matei (@radu-matei) Running ip addr | grep eth0 in WSL 2 will give you the IP of your linux vm when you run it in your Linux terminal. It should be accessible from your Windows 10 host machine as well, as long as you have whatever service you're hosting open to any IP.

    Example if you are hosting a node.js service make sure it is available for any IP with the following:

    var app = connect().use(connect.static('public')).listen(3000, "0.0.0.0");

    Source: Stackoverflow
    "0.0.0.0" is the important part!

    If you try accessing your WSL 2 ip on another system on your network it won't work due to issue #4150.

    Lastly I recommend rebooting your whole system completely, it seems WSL 2 will self heal any mis configured network setting when doing so. Example I messed with the "vEthernet (WSL)" ethernet adapter in "Control Panel\Network and Internet\Network Connections" and when rebooting my PC it restored the settings and my Ubuntu WSL 2 was working again. (It just give me a different IP but a working config at least)

    One last thing, I recommend trying to ping something from WSL 2. To make sure it can get a connection outbound, such as ping google.com. Also try ping your WSL 2 from the command line from Windows 10, these work both return success for me on my working setup.

  3. xtremeperf commented on Jun 20, 2019

    @xtremeperf

    Windows and WSL2 will have two different IP addresses and are connected via the vSwitch named 'WSL'. Just like a full blown VM would be setup. My understanding is that this networking scheme is likely to change in the near future, so that Windows and WSL2 share the same "localhost".

    I haven't had any problems connecting to WSL2 port from Windows.

    Actually... you're probably being blocked by the Windows firewall, as WSL2 is considered to be on a "Public Network". You'll need to open these ports manually on the Windows firewall because they are not yet automatically configured upon installation in this early beta release.

  4. radu-matei commented on Jun 20, 2019

    @radu-matei
    Author

    After several restarts and the new build, everything seems to be working fine.
    Thanks for your help, everyone, closing.

  5. mahmoudajawad commented on Jun 20, 2019

    @mahmoudajawad

    Radu Matei (@radu-matei) what do you mean by the new build? I'm still facing this issue. I'm unable to access any WSL daemon on any port from Windows. Could you mention all the aspects you took into consideration?

  6. scargill commented on Dec 13, 2019

    @scargill

    Cn anyone help? I'm new o wsl.... I turned it on and installed Debian command line - from the Windows App (bang up to date system) - I have a general script that installs stuff in BUSTER on Debian systems - so I put in Node-Red, nginx, Grafana etc. When done I could not figure out how to reboot WSL on its own so I rebooted the entire PC. If I go into WSL it looks like NGINX is in place on port 80, Node-Red etc. I cannot access any of this rom outside of WSL - and in Linux if I do NODE-RED-STOP - which should work (the setup for Node-Red usually works) I get:

    Use node-red-start to start Node-RED again
    System has not been booted with systemd as init system (PID 1). Can't operate.
    Failed to connect to bus: Host is down

    Ideally wtat I'd like is for WSL to have it;s own IP address..

    Currently "ip a" in WSL returns:

    15: eth0: <> mtu 1500 group default qlen 1
    link/ether 00:ff:87:45:5c:6b
    inet 169.254.94.147/16 brd 169.254.255.255 scope global dynamic
    valid_lft forever preferred_lft forever
    inet6 fe80::b895:a18c:b2c7:5e93/64 scope link dynamic
    valid_lft forever preferred_lft forever
    5: eth1: <BROADCAST,MULTICAST,UP> mtu 1500 group default qlen 1
    link/ether 02:00:4c:4f:4f:50
    inet 169.254.140.56/16 brd 169.254.255.255 scope global dynamic
    valid_lft forever preferred_lft forever
    inet6 fe80::802:8607:5c35:8c38/64 scope link dynamic
    valid_lft forever preferred_lft forever
    8: eth2: <BROADCAST,MULTICAST,UP> mtu 1500 group default qlen 1
    link/ether 00:25:64:eb:88:b5
    inet 192.168.14.111/24 brd 192.168.14.255 scope global dynamic
    valid_lft 86390sec preferred_lft 86390sec
    inet6 fe80::485c:9e23:9e7e:2bf1/64 scope link dynamic
    valid_lft forever preferred_lft forever
    1: lo: <LOOPBACK,UP> mtu 1500 group default qlen 1
    link/loopback 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope global dynamic
    valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host dynamic
    valid_lft forever preferred_lft forever
    pi@WillowPete:~$

    and ifconfg returns:

    eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet 169.254.140.56 netmask 255.255.0.0 broadcast 169.254.255.255
    inet6 fe80::802:8607:5c35:8c38 prefixlen 64 scopeid 0xfd<compat,link,site,host>
    ether 02:00:4c:4f:4f:50 (Ethernet)
    RX packets 0 bytes 0 (0.0 B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 0 bytes 0 (0.0 B)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet 192.168.14.111 netmask 255.255.255.0 broadcast 192.168.14.255
    inet6 fe80::485c:9e23:9e7e:2bf1 prefixlen 64 scopeid 0xfd<compat,link,site,host>
    ether 00:25:64:eb:88:b5 (Ethernet)
    RX packets 0 bytes 0 (0.0 B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 0 bytes 0 (0.0 B)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    lo: flags=73<UP,LOOPBACK,RUNNING> mtu 1500
    inet 127.0.0.1 netmask 255.0.0.0
    inet6 ::1 prefixlen 128 scopeid 0xfe<compat,link,site,host>
    loop (Local Loopback)
    RX packets 0 bytes 0 (0.0 B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 0 bytes 0 (0.0 B)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

  7. Calvin-Dong-007 commented on Jan 17, 2021

    @Calvin-Dong-007

    Cn anyone help? I'm new o wsl.... I turned it on and installed Debian command line - from the Windows App (bang up to date system) - I have a general script that installs stuff in BUSTER on Debian systems - so I put in Node-Red, nginx, Grafana etc. When done I could not figure out how to reboot WSL on its own so I rebooted the entire PC. If I go into WSL it looks like NGINX is in place on port 80, Node-Red etc. I cannot access any of this rom outside of WSL - and in Linux if I do NODE-RED-STOP - which should work (the setup for Node-Red usually works) I get:

    Use node-red-start to start Node-RED again
    System has not been booted with systemd as init system (PID 1). Can't operate.
    Failed to connect to bus: Host is down

    Ideally wtat I'd like is for WSL to have it;s own IP address..

    Currently "ip a" in WSL returns:

    15: eth0: <> mtu 1500 group default qlen 1
    link/ether 00:ff:87:45:5c:6b
    inet 169.254.94.147/16 brd 169.254.255.255 scope global dynamic
    valid_lft forever preferred_lft forever
    inet6 fe80::b895:a18c:b2c7:5e93/64 scope link dynamic
    valid_lft forever preferred_lft forever
    5: eth1: <BROADCAST,MULTICAST,UP> mtu 1500 group default qlen 1
    link/ether 02:00:4c:4f:4f:50
    inet 169.254.140.56/16 brd 169.254.255.255 scope global dynamic
    valid_lft forever preferred_lft forever
    inet6 fe80::802:8607:5c35:8c38/64 scope link dynamic
    valid_lft forever preferred_lft forever
    8: eth2: <BROADCAST,MULTICAST,UP> mtu 1500 group default qlen 1
    link/ether 00:25:64:eb:88:b5
    inet 192.168.14.111/24 brd 192.168.14.255 scope global dynamic
    valid_lft 86390sec preferred_lft 86390sec
    inet6 fe80::485c:9e23:9e7e:2bf1/64 scope link dynamic
    valid_lft forever preferred_lft forever
    1: lo: <LOOPBACK,UP> mtu 1500 group default qlen 1
    link/loopback 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope global dynamic
    valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host dynamic
    valid_lft forever preferred_lft forever
    pi@WillowPete:~$

    and ifconfg returns:

    eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet 169.254.140.56 netmask 255.255.0.0 broadcast 169.254.255.255
    inet6 fe80::802:8607:5c35:8c38 prefixlen 64 scopeid 0xfd<compat,link,site,host>
    ether 02:00:4c:4f:4f:50 (Ethernet)
    RX packets 0 bytes 0 (0.0 B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 0 bytes 0 (0.0 B)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
    inet 192.168.14.111 netmask 255.255.255.0 broadcast 192.168.14.255
    inet6 fe80::485c:9e23:9e7e:2bf1 prefixlen 64 scopeid 0xfd<compat,link,site,host>
    ether 00:25:64:eb:88:b5 (Ethernet)
    RX packets 0 bytes 0 (0.0 B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 0 bytes 0 (0.0 B)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    lo: flags=73<UP,LOOPBACK,RUNNING> mtu 1500
    inet 127.0.0.1 netmask 255.0.0.0
    inet6 ::1 prefixlen 128 scopeid 0xfe<compat,link,site,host>
    loop (Local Loopback)
    RX packets 0 bytes 0 (0.0 B)
    RX errors 0 dropped 0 overruns 0 frame 0
    TX packets 0 bytes 0 (0.0 B)
    TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

    I encounter the same problem, did you solve it?

  8. ColderCoder commented on Jan 24, 2021

    @ColderCoder

    Calvin Dong (@Calvin-Dong-007) Try to disable the Windows Defender Firewall for public network. See if it helps.
    If so, re-enable the firewall (for security reason) and run following command to add a exception for WSL:
    New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow

  9. relipse commented on Feb 11, 2021

    @relipse

    Windows and Networking Question: I have Ubuntu 20 with WSL2 on my Windows 10 laptop, I have elasticsearch running on the Windows side, but in order for wsl to access it, I need to disable the Public firewall, I tried adding an exception and turning the firewall back on, but no go, my exception command ran in Powershell as admin was: New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow, but it didn't work. Any ideas?

  10. achilsh commented on May 25, 2023

    @achilsh

    i run cmd: New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow

    result display like this:

    PS C:\WINDOWS\system32> New-NetFirewallRule -DisplayName "WSL" -Direction Inbound -InterfaceAlias "vEthernet (WSL)" -Action Allow

    Name : {db312add-d3ec-4cea-8bee-a907b558292f}
    DisplayName : WSL
    Description :
    DisplayGroup :
    Group :
    Enabled : True
    Profile : Any
    Platform : {}
    Direction : Inbound
    Action : Allow
    EdgeTraversalPolicy : Block
    LooseSourceMapping : False
    LocalOnlyMapping : False
    Owner :
    PrimaryStatus : OK
    Status : 已从存储区成功分析规则。 (65536)
    EnforcementStatus : NotApplicable
    PolicyStoreSource : PersistentStore
    PolicyStoreSourceType : Local
    RemoteDynamicKeywordAddresses : {}

    but ubuntu can't connet internet.

  11. ElectricRCAircraftGuy commented on Aug 9, 2023

    @ElectricRCAircraftGuy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions