Ubuntu

Installing UBUNTU WSL on Windows 10 on private (office) network

Problem

Windows subsystem for linux is definitely a developers dream to have linux running with windows on official laptops. With all the restrictions around installation of VM and dual boot this comes as a life saver. Docker linux images did solve some of the problems but with WSL2, life is much more easier for working on windows host OS but developing and testing on linux. But there are few hiccups which we might have to encounter to get it working all togethor on official laptops.

Solution

  • Preferred way of installing ubuntu WSL on windows 10 is to download it from Microsoft store as mentioned here. But there could be restrictions to download any app from store as was in my case. The help came from Microsoft itself. You can download it manually and steps are provided here. Don’t miss enabling virtual machine platform and creating user
  • Once installed and machine restarted, you could see the installed distro in your start menu. For me its Ubuntu 20.04 LTS. But clicking on it gave me an exception as below. This is problem with the location.
1
2
3
C:\Program Files\WindowsApps\CanonicalGroupLimited.Ubuntu20.04onWindows_2004...\ubuntu.exe
 
The service has not been started.

To Fix this just move the folder from Program files to a folder called unix under C: drive.

  • Now you can just open a command prompt, navigate to folder containing ubuntu disto and start the ubuntu application under it. This would be your entry to linux world.
  • You would need some basic applications like git and python3 for doing dev work here. You can always apt them but before that run the below command.
1
sudo apt update && sudo apt upgrade
  • Now any service that runs under this linux env would be accessible from host windows env. To test it you can run below command and you would be able to access it from your windows browser by running http://localhost:8080
1
python3 -m http.sever 8080
  • The next problem is to access URL’s which are within the company’s firewall from this linux env. Most of the companies use DHCP protocol to provide DNS names and other network properties to our machines, but in some cases these DNS names are not passed correctly to WSL2 linux env. The way to fix them is 2 step process
    1. Get all DNS Servers specified for all network adapters provided by ipconfig/all command and making sure all of them are present with nameserver tags in /etc/resolve.conf file.
    2. If some of them are missing, add those with nameserver tag in /etc/resolve.conf file name

** I believe there are better ways to do it , but other options didn’t work for me 😦

  • The above step should solve the problem of finding hosts within corporate firewalls. But this might cause issues with connecting to internet world. To fix this you might have to set proxy which is used by your browsers. It could be easily found using chrome://net-export logs and tracing what proxy is used when you access http://www.google.com. Once found you can add them as below in your linux env. If you using bash, you can set it in ~/.bash_profile.
1
2
export http_proxy="<PROXY URL>"
export https_proxy="<PROXY URL>"

This should fix all the issues and you can start playing with linux on windows 10.

Published on System Code Geeks with permission by Abhijeet Iyengar, partner at our SCG program. See the original article here: Installing UBUNTU WSL on Windows 10 on private (office) network

Opinions expressed by System Code Geeks contributors are their own.

Abhijeet Iyengar

Abhijeet is a Software Engineer working with financial client . He has been involved in building UI and service based applications.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button