Innernet in WSL

Assumption: Running Ubuntu 20.04 WSL2 instance

Install Microsoft repository and dotnet-sdk-5.0:

Install .NET on Ubuntu - .NET
Demonstrates the various ways to install .NET SDK and .NET Runtime on Ubuntu.
sudo apt-get update
sudo apt-get install -y apt-transport-https
wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y dotnet-sdk-5.0

Install wsl-transdebian

wsl-transdebian
A repository for WSL-only apt packages.
wget -O /etc/apt/trusted.gpg.d/wsl-transdebian.gpg https://arkane-systems.github.io/wsl-transdebian/apt/wsl-transdebian.gpg
chmod a+r /etc/apt/trusted.gpg.d/wsl-transdebian.gpg

cat << EOF > /etc/apt/sources.list.d/wsl-transdebian.list
deb https://arkane-systems.github.io/wsl-transdebian/apt/ focal main
deb-src https://arkane-systems.github.io/wsl-transdebian/apt/ focal main
EOF

apt update

Install systemd-genie

arkane-systems/genie
A quick way into a systemd “bottle” for WSL. Contribute to arkane-systems/genie development by creating an account on GitHub.
sudo apt install -y systemd-genie
sudo systemctl mask systemd-remount-fs.service
sudo systemctl mask multipathd.socket

Configure systemd-genie

Add the following lines to .profile to make sure genie automatically starts when you sign into WSL:

if [[ -v SSH_CLIENT ]]; then
  TMPFILE=$(mktemp)
  systemctl show-environment | awk '{print "export "$0}' >> "$TMPFILE"
  source "$TMPFILE"
  rm "$TMPFILE"
fi
if [[ "$(genie -r)" != "running" ]];then
  /usr/bin/genie -i
fi
# Are we in the bottle?
if [[ ! -v INSIDE_GENIE ]]; then
  read -p "yn? * Not inside the genie bottle; enter it? " yn
  echo

  if [[ $yn == "y" ]]; then
    echo "Starting genie:"
    exec /usr/bin/genie -s
  fi
else
  echo -n " * Waiting for systemd (user)..."
  until systemctl --user is-system-running &>/dev/null
  do
    sleep 1
    echo -n "."
  done
  echo
fi

Restart WSL

wsl -t ubuntu
wsl -d ubuntu

Install innernet

wget https://github.com/tonarino/innernet/releases/download/v1.0.0/innernet_1.0.0_amd64.deb
sudo apt install ./innernet_1.0.0_amd64.deb

You now can configure innernet as you normally would. You may want to add something to trigger genie on startup to ensure that systemd loads and starts the innernet interface.

This will allow anything in WSL to interact with your innernet peers, but you wont be able to use it directly from the host system.

Show Comments