Static IP for Linux Under WSL?


  1. Posts : 7
    Windows 10 x64
       #1

    Static IP for Linux Under WSL?


    Is it possible to set a static ip for linux distros(Manjaro in this case) running under WSL?
      My Computer


  2. Posts : 4,224
    Windows 10
       #2

    This docs file says a lot of useful stuff about networking in WSL1 and 2. Looks like you should be able to do what you need at the command line to assign the same IP address each time the VM runs. It's not exactly the same thing as a static IP assignment, but hopefully it's "close enough."
    HTH,
    --Ed--

    https://docs.microsoft.com/en-us/win...mpare-versions
      My Computers


  3. Posts : 7
    Windows 10 x64
    Thread Starter
       #3

    Am I understanding this correctly?

    Code:
    netsh interface portproxy add v4tov4 listenport=2244 listenaddress=0.0.0.0 connectport=2244 connectaddress=192.168.1.110
    Should open up port 2244 on both windows and manjaro and forward this port through to my static ip on Windows to Manjaro?
      My Computer


  4. Posts : 4,224
    Windows 10
       #4

    Might work: give it a try and see what happens.
    HTH,
    --Ed--
      My Computers


  5. Posts : 7
    Windows 10 x64
    Thread Starter
       #5

    So far I haven't had any success with that command and trying some variations of it.
      My Computer


  6. Posts : 2,068
    Windows 10 Pro
       #6

    The question is what do you need a static IP address for?

    For example, you can connect to your default WSL distro by just typing wsl and hitting enter

    You can get the IP address with wsl -d "DistroNamne" hostname -I
    Static IP for Linux Under WSL?-image.png
      My Computers


  7. Posts : 7
    Windows 10 x64
    Thread Starter
       #7

    pparks1 said:
    The question is what do you need a static IP address for?
    Well for starters, I would like to be able to ssh in to my Manjaro box(so to speak) even on the go via my phone. My initial approach seems unnecessary I suppose so long as I can forward the proper ports directly to Manjaro.

    For example, you can connect to your default WSL distro by just typing wsl and hitting enter

    You can get the IP address with wsl -d "DistroNamne" hostname -I
    Static IP for Linux Under WSL?-image.png
    I get this:

    PS C:\WSL\Manjaro> wsl -d "Manjaro" hostname -Ihostname: invalid option -- 'I'
    Try 'hostname --help' or 'hostname --usage' for more information.


    - - - Updated - - -

    Oh and my system is only returning 127.0.0.1
    Code:
    PS C:\Users\Xplor> wsl -d "Manjaro" hostname -i127.0.1.1
      My Computer


  8. Posts : 2,068
    Windows 10 Pro
       #8

    Actually, it looks like your box is returning 127.0.1.1 Apparently this is a Debian thing that the installer will create this IP address for system without a permanent IP address to address some software that won't work without an entry. I'm not familiar with Debian distros (besides a bit of Ubuntu), I have worked with the Red Hat based distros my entire career.

    I'm not sure why you are not getting a 172.16.x.x/20 range IP address. i've always gotten one with WSL2. Here is the output from my work machine.
    Static IP for Linux Under WSL?-image.png
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 21:03.
Find Us




Windows 10 Forums