WireGuard and Fly
Along with our 6PN private networking, the Fly team have a new way of connecting to your apps using the popular WireGuard networking software. This is a flexible and secure way to plug into each one of your Fly organizations and connect to any and all apps within that organization.
TL:DR;
Fly's command line can generate you a tunnel configuration file with private keys already embedded. You can load that file into your local WireGuard application to create a tunnel. Activate the tunnel and you'll be using the internal Fly DNS service which resolves .internal
addresses - and passes on other requests to Google's DNS for resolution.
Step by Step
Install your WireGuard App
There are many options for installing WireGuard on your system, detailed on the WireGuard site. Install the software that is appropriate for your system. Window and macOS have apps available to install. Linux systems have packages, typically named wireguard and wireguard-tools, you should install both.
Creating your tunnel configuration
To create your tunnel, run:
fly wireguard create
You'll be asked to select which organization you want the WireGuard tunnel to work with:
? Select organization: [Use arrows to move, type to filter]
> Dj (personal)
Demo Sandbox (demo-sandbox)
You'll then be asked for a region where the gateway is. Currently, there is one region, dev, which handles the Wireguard traffic.
? Region in which to add WireGuard peer: dev
Now it's time to name our WireGuard peer, effectively a name for the connection. We'll call this connection basic
for this example:
? Name of WireGuard peer to add: basic
Creating WireGuard peer "basic" in region "dev" for organization personal
As well as configuring the Wireguard service, the create command also generates a tunnel configuration file, complete with private keys which cannot be recovered. This configuration file will be used in the next step. First it has to be saved:
!!!! WARNING: Output includes private key. Private keys cannot be recovered !!!!
!!!! after creating the peer; if you lose the key, you’ll need to remove !!!!
!!!! and re-add the peering connection. !!!!
? Filename to store WireGuard configuration in, or 'stdout': basic.conf
Wrote WireGuard configuration to 'basic.conf'; load in your WireGuard client
We suggest you name your saved configuration with the same name as the peer you have created. Add the extension .conf
to ensure it can will be recognized by the various WireGuard apps as a configuration file for a tunnel.
Importing your tunnel
Windows
Run the WireGuard app. Click the Import tunnel(s) from file
button. Select your configuration file. The Wireguard app will display the details of your tunnel. Click Activate
to bring the tunnel online.
macOS
Run the WireGuard app. Click the Import tunnel(s) from file
button. Select your configuration file and click Ok. You will be prompted by the OS that WireGuard would like to add VPN configurations; click Allow
. The Wireguard app will display the details of your tunnel. Click Activate
to bring the tunnel online.
Ubuntu Linux
Ensure you have wg-quick
installed, if not, run:
sudo apt install wireguard-tools
Copy the configuration file to /etc/wireguard
; you'll need root/sudo permissions:
sudo cp basic.conf /etc/wireguard
Run wg-quick
to bring up
the connection by name (i.e. less the .conf
extension):
wg-quick up basic
[#] ip link add basic type wireguard
[#] wg setconf basic /dev/fd/63
[#] ip -6 address add fdaa:0:4:a7b:ab6:0:a:102/120 dev basic
[#] ip link set mtu 1420 up dev basic
[#] resolvconf -a tun.basic -m 0 -x
[#] ip -6 route add fdaa:0:4::/48 dev basic
Testing the tunnel
If you have the dig
tool installed, a TXT query to _apps.internal
will show all the application names available in the organization you are connected to.
Managing Wireguard on Fly
Listing the tunnels
To list all the tunnels set up for an organization, run fly wireguard list
. You can provide an organization on the command line or you'll be prompted for one.
Removing a tunnel
To remove a tunnel, run fly wireguard remove
. You can specify the organization and tunnel name on the command line or be prompted for both.