Run one application through a VPN with Tube

Put Firefox, or any other program, in an OpenVPN connection of its own, while the rest of the machine keeps its normal network.

4 min to read

A VPN client usually moves the whole machine into the VPN. Tube moves one application. tube firefox gives you a Firefox whose network goes through the VPN, next to everything else that does not.

You need an OpenVPN profile: an .ovpn file from your VPN provider or from your own server.

What you need on Linux#

  • Linux on x86-64 or arm64.
  • A kernel that lets an ordinary user make user namespaces.
  • A /dev/net/tun that you may open, which is the default of the distributions.

Tube needs no root, no sudo, no system service and no installed openvpn. It checks what it needs when it starts, and says what is missing.

If it complains about user namespaces, three settings decide it:

# must be above 0
sysctl user.max_user_namespaces
# Debian: must be 1
sysctl kernel.unprivileged_userns_clone
# Ubuntu 24.04 and later: must be 0
sysctl kernel.apparmor_restrict_unprivileged_userns

A setting that your distribution does not have is not a problem. On Ubuntu, an AppArmor profile that allows Tube works too.

Install#

With Go 1.27.3 or later:

go install github.com/rm4n0s/tube/cmd/tube@latest

Or with Soft, which also installs gtube with its entry in the menu of the desktop:

soft install github.com/rm4n0s/tube

Run an application#

tube firefox

This opens a terminal UI, which you use with the keys or with the mouse.

  1. Add a profile. The first time there is none. Add your .ovpn file from the list of your folders. Tube keeps your profiles: you can look at them, change them and delete them here.
  2. Select the profile. Tube connects to it and starts Firefox, with all of Firefox’s network in that VPN: TCP, UDP, ICMP and the looking up of names.
  3. Watch it. The terminal UI stays open while Firefox runs, and closes by itself when you close Firefox.

The terminal UI has three tabs:

TabWhat it shows
StatusThe connection and its traffic
OutputWhat the application prints
NetworkSwitch to another profile, or take the network away

Before the VPN is connected, and after it has ended, the application has no network at all.

Without the terminal UI#

For scripts, and for programs that need the whole terminal (vim, htop, ssh), name the profile:

tube --profile work curl https://example.com

--profile also takes an .ovpn file, which is added the first time:

tube --profile ~/Downloads/work.ovpn curl https://example.com

What that run is missing (the user name, the password, DNS servers) is asked on the terminal, and saved when you say so. The options --username, --password, --auth-file, --dns and --save give it without a question.

With windows: gtube#

gtube is Tube with windows in place of the terminal UI, for Linux.

go install github.com/rm4n0s/tube/cmd/gtube@latest
  1. Run gtube alone. It lists the applications of your desktop.
  2. Select one, for example Firefox, and press Install. The menu of your desktop gets Firefox (Tube), with Tube’s logo on its icon.
  3. Start Firefox (Tube) from the menu. A window shows your profiles. Select one and press Connect and run.

While the application runs, the window shows the connection, the traffic and the output, and it goes to the tray when you close it. gtube uses the same profiles as tube.

On macOS#

On macOS an ordinary user can make neither a network device nor a namespace, so Tube has a helper that runs as root. Install it once, and again after each new version of Tube:

sudo tube --install-helper
tube --helper-status

Tube itself still never runs sudo. Some things are different from Linux: programs that leave their network to a process that macOS starts (Safari, Mail, open) are not in the VPN, ICMP is not, and at most 8 runs work at once.

Limits to know#

  • Services on the machine’s own 127.0.0.1 cannot be reached from the application.
  • Programs that need to gain rights (sudo, a setuid program) do not gain them inside.
  • IPv6 works only when the VPN gives an IPv6 address.
  • Compression, proxies, static keys, encrypted private keys and challenge/response logins are not supported.
  • Flatpak applications run through Tube (tube flatpak run org.mozilla.firefox). Snap applications do not.

Where to go next#

Tube’s guide says how to use every part of Tube and what its errors mean, and SECURITY.md says what Tube promises and what it does not.