3

I came across this question here:

Mounting network drive in Windows 10 bash?

Where mounting network share directories between Windows 10 and WSL is supported in Windows 10 Creator's Update (1703). Here in this question, the proposed solution is to mount the directory like so:

sudo mount -t drvfs '\\192.168.xxx.xxx\folder' /mnt/new_folder

I'm going to be focusing on the IP address, the '\\192.168.xxx.xxx' part.

I wanted to know the correct process and procedures required to figure how to find this IP address for WSL and Windows 10 to use. Here are a few questions I have:

  1. How to lookup for this IP Address, especially for LAN/WLAN, and LANs joined by a hub/router?
  2. How do you make changes to the IP Address, so you know exactly how to map the first xxx and the second xxx? Are they related to one another when you're doing the above mentioned lookup?
  3. When a network configuration change occurs, such as needing to reinstall WSL because of accidents (i.e., worst-case scenario like someone running a rm -rf /* in WSL), is the same procedures for finding said IP Address the same as the procedures mentioned/answered for Question 1?

I'm learning as I go, and hopefully the procedures aren't too much of a hassle. If there are duplicate questions, please let me know, because I am pretty sure there are similar questions being asked, but:

  • Superuser's suggested questions didn't come up with what I wanted to know about.
  • Most of the Google search results I find are about mapping directories locally and remotely to different hosts/OSes, but there aren't a whole lot of information for WSL (possibly due to how recent WSL is).

Thanks.

0

1 Answer 1

1

First: The answer you've found has 192.168.xxx.xxx only because the question has it. The author of the answer only corrected the surrounding options – usage of -t cifs to -t drvfs, the kind of slashes used, and so on. The rest was just copied from the question and is not authoritative.

But nowhere does it say that you must use an IP address. If you know the computer name, I would expect \\the_computer_name\folder to also work, the same way it already works on "native" Windows. You don't need to resolve it manually if Windows can do the same automatically.

If you usually access the shares via Network explorer, just copy the full path from the explorer's address bar (and add the quotes).

For example, mount -t drvfs '\\desktop-abcdef\Music' /mnt/music.


Second: If you know the computer name and Windows is already able to resolve it, but you still want to look it up manually:

  • From WSL, getent ahosts the_computer_name should work.
  • From standard Windows: ping or nslookup or nbtstat -a the computer name.

(I shouldn't be suggesting ping, as it has a different purpose and the addresses it shows are not always quite correct. But I don't know of a more suitable tool – for example, nslookup is good for DNS but doesn't do NetBIOS or LLMNR at all. There's nbtstat for NetBIOS, but not for LLMNR.)

If it's a situation where you know the computer name but Windows cannot automatically reach it, that requires a bit more details and is out of scope for this thread.


Third: A lot of what you're asking about "filling in the xxx" falls under the basics of IP networking, and I won't go far into detail about how IP addresses, networks and subnets work – it's out of scope for this thread.

But to avoid further confusion, it should be noted that 192.168.xxx.xxx is just an example (of a common address format), but not a form to fill the blanks in. The entire address depends on where you are and how your LAN is configured.

(There are a few address ranges reserved for private LANs, and 192.168.0.0/16 is one of them. Most home/consumer routers come preconfigured with a smaller range such as 192.168.1.0/24, but that's not guaranteed to be the case.)

In any case, when you resolve a name to IP address, you get the whole address at once and there is no need to map any individual components to anything.

5
  • Ok, so I should use the computer name then. Is the WSL's computer name the left side of the @, or the right side of the @, when you open up Bash for Windows? (Usually for me, it would be xxx@yyy at the top and in the terminal before the $). If not, then I really don't know what the WSL's computer name looks like. Apr 23, 2018 at 13:24
  • WSL doesn't have a separate computer name (it is the same as the "host" Windows system's), and generally it doesn't have a separate file-sharing service either (only the "host" Windows system has). Remember, you're supposed to use the file server's name/address, not your own... All that said, in the default bash prompt, the computer name is on the right of @.
    – user1686
    Apr 23, 2018 at 13:27
  • I see. I'll be sure to look around in the "Basics of IP networking" to learn more about this. For the "file server", may I ask what that would be in WSL? I'm assuming WSL is more of a local OS, and I never think of it as a server OS of any kind, let alone a file server. Apr 23, 2018 at 13:31
  • Again, it's not something you'll usually find in WSL – it's just a part of the main Windows OS itself; sometimes called "SMB server" or just "file sharing service". (If it were a full Linux system, it would use "Samba" as the server, but that won't work on WSL, nor would it be of any use.)
    – user1686
    Apr 23, 2018 at 13:34
  • Oh I see. Thanks for pointing out what I need to learn more about, as well as the information provided. Apr 23, 2018 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.