Fly offers a Wireguard VPN usually used from an individual’s computer. However, there are situations where having access to the VPN from an entire private network is beneficial. This can be difficult because Fly doesn’t offer a /64 subnet, a requirement for IPv6 Router Advertisement. The solution to this is NAT66 (Network Address Translation for IPv6-to-IPv6). Basically, we enable the router to connect to Fly through a WG peer and then advertise an IPv6 network internally that will be NAT’d through the Fly IPv6 address. Without the NAT, there isn’t a route for the return traffic to the internal network. This guide will layout how to get the connection working with both a pfSense router and a Mikrotik router.
pfSense Setup
Wireguard Configuration
- Install WG package under System → Package Manager
- In a console, run
fly wg create
and fill in the appropriate information - Under the VPN tab, select WireGuard
- Add a new tunnel
- Add a useful description (e.g. fly)
- Pick a listening port
- Paste into the Private Key the private key from step 2
- For interface address, paste in the address from step 2
- Click Save Tunnel
- Add Peer
- Select appropriate tunnel
- Add a useful description (e.g. fly-sea)
- Unselect Dynamic
- Paste endpoint from step 2
- Enter value from step 2 for Keep Alive
- Paste paste public key from step 2
- Leave Pre-shared Key blank
- Fill in Allowed IPs from step 2
- Click Save Peer
- Under Interfaces tab, select Assignments
- Add the new fly tun_wg* network port
- Click on the new interface name
- Change Description to something more descriptive (e.g. Fly)
- Under Static IPv6 Configuration, make sure the address is correct based on step 2’s information
- Add a new gateway
- Gateway IPv6 address, should be the interface address defined in step 2
- Click Save
- Last we need to create a static route for all traffic going to our Fly /48
- Go to System → Routing → Static Routes
- Click Add
- For Destination network, fill in the AllowedIPs from step 2
- Set Gateway to the new fly v6 gateway
- Click Save
At this point the router should be able to ping the IP of any Fly node.
DNS Configuration
So that we can communicate with all of the nodes in the Fly org by name, we need to forward DNS requests for the internal
TLD to Fly’s DNS server. These steps assume that you are using the DNS Resolver, but they might work for the DNS Forwarder.
- Services → DNS Resolver
- Scroll to the bottom of the page and click Add under Domain Overrides
- Set Domain to
internal
- IP Address should be the address of the DNS server reported when the WG connection was created
- Set Description to “Forward .internal to fly”
- Click Save
At this point, you should be able to use Diagnostics → DNS Lookup to lookup the address(es) of one of your apps by .internal.
NAT66 Configuration
This is the last major configuration that needs to be made to enable the internal network to communicate to Fly through the router. We create a private IPv6 subnet on the LAN, add a NAT rule, and then advertise the subnet.
- First, we need to define a /64 for the internal network to use and to be routed to Fly.
- Go to Interfaces → LAN (or whichever interface you want to be allowed to connect to Fly)
- For the IPv6 Configuration Type, set to
Static IPv6
- Scroll down and set the IPv6 address to something in the
fd00::0/8
range with a /64 subnet. - Click Save
- Go to Firewall → NAT
- Go to Outbound
- Select Hybrid Outbound NAT
- Click Save
- Click Add to add an outbound NAT rule
- Select the appropriate interface
- Address Family:
IPv6
- Source: Network and set the network equal to the IPv6 range defined in 1.c above
- Click Save
- Last, we need to advertise that the defined IPv6 address can be used for routing.
- Go to Services → DHCPv6 Server & RA
- Select the appropriate interface tab
- Select the Router Advertisements tab
- Change the Router mode to
Unmanaged
- Click Save
And you are done!
Mikrotik Setup
For the Mikrotik setup, I’m primarily a WinBox user so all configuration will be with respect to that user interface.
Wireguard Configuration
- In a console, run
fly wg create
and fill in the appropriate information - In WinBox, click WireGuard on the side bar and then the + to add a new interface
- Give the interface a name
- Click the down arrow to the right of the Private Key and paste in the private key from step 2.
- Click OK to save
- Go to the Peers tab and click + to add a new peer
- Select the appropriate interface that was just created
- Paste in the Public Key, Endpoint, and Endpoint Port
- For the Allowed Address, fill in the CIDR block specified from step 2 as
AllowedIPs
- For Persistent Keepalive, step 2 specifies the number of seconds
- Click OK
IPv6 Addresses and Private Subnet
- On the side bar, click IPv6 → Addresses
- Click + to add the fly peer address
- Set the Address to the Address specified in the wireguard configuration (step 2 above)
- Set the Interface to the new wireguard interface
- Uncheck the Advertise checkbox
- Click OK to save
- Now add another address for the subnet by clicking the +
- For Address, set to something in the
fd00::0/8
range with a /64 subnet. - Set the Interface to the bridge
NOTE: This adds the CIDR block to your LAN network. You might need to change this if your router/switch is configured differently. - Make sure that the Advertise checkbox is checked.
Note: This advertises to the network that the router is able to route for this address. Other computers in the network will now allocate their own addresses within that CIDR block via SLAAC. - Click OK
- Now we need to create a static route for your Org’s Fly network by going to the side bar and clicking IPv6 → Routes
- Add a route with the + button
- Dst. Address should be the AllowedIPs from the wireguard configuration (step 2 in first section)
- Gateway should be set to the new fly wg interface
- Click OK
- Lastly, we need to add the NAT66 rule to send traffic to Fly through the WG tunnel. On the side bar, click IPv6 → Firewall.
- Go to the NAT tab
- Create a new NAT rule with the following setting:
- Chain:
srcnat
- Dst. Address should be the AllowedIPs CIDR block from the wireguard configuration (step 2 in first section)
- Action:
src nat
- To Address: Address from the wireguard configuration (step 2 in first section)
- Chain:
- Click OK
DNS Configuration
So that we can communicate with all of the nodes in the Fly org by name, we need to forward DNS requests for the internal
TLD to Fly’s DNS server. These steps assume that you are using the DNS server on the Mikrotik for your network.
- On the side bar, click IP → DNS
- Click the Static button
- Add a new static entry with the + button
- Name is optional
- Fill in Regexp as
.*\.internal$
- Change the Type to
FWD
- Paste into the Forward To field the DNS address from the wireguard configuration (step 2 in the first section)
- Click OK
And you are done! Enjoy your easy access to your Org’s Fly private network and DNS.