Enabling Bridge mode on Ubuntu WSL

I noticed that I was unable to access the same network that my host pc was on when using Ubuntu WSL. I could not ping my 192.168.0.1 host which was my IP that given to my Window’s machine.

This was causing a problem when I was working on a project. I performed some Googling and found the solution. I had to create a new file in my user’s profile folder.

First you can find your user’s profile by typing in the following command into the file explorer.

%userprofile%

Now that you are in your user’s profile folder, you will need to create a new file named the following.

.wslconfig 

The dot in front of the word is needed because the file is hidden. You may need to change settings in File Explorer to be able to see hidden files.

Now that the file is created you need to add the following text to the file.

[wsl2]
networkingMode=mirrored

You will need to exit any current terminals and create a new one, it should change the networking mode to mirrored without needing to restart the computer. After exiting all the terminals you must wait eight seconds for the changes to take effect.

If you do not want to use mirrored there also the following options:

  • none
  • nat
  • virtioproxy

More information about .wslconfig can be found here.