Libp2p is a networking library created by Protocol Labs that allows nodes to discover eachother using a Distributed Hash Table. Paired with NAT hole punching this allows Hyprspace to create a direct encrypted tunnel between two nodes even if they're both behind firewalls.
Moreover! Each node doesn't even need to know the other's ip address prior to starting up the connection. This makes Hyprspace perfect for devices that frequently migrate between locations but still require a constant virtual ip address.
I use this system when travelling, if I'm staying in a rental or hotel and want to try something out on a Raspberry Pi I can plug the Pi into the location's router or ethernet port and then just ssh into the system using the same-old internal Hyprspace ip address without having to worry about their NAT or local firewall. Furthermore, if I'm connected to the Virtual Hyprspace Network I can ssh into my machines at home without requiring me to set up any sort of port forwarding.
Honestly, I even use this system when I'm at home and could connect directly to my local infastructure. Using Hyprspace however, I don't have to trust the security of my local network and hyprspace will intelligently connect to my machines using their local ip addresses for maximum speed.
If anyone else has some use cases please add them! Pull requests welcome!
- Go to Hyprspace Releases (other there -->)
- Copy the link for your corresponding OS and Architecture.
- Run
sudo curl -L "PATH-TO-RELEASE" -o /usr/local/bin/hyprspace - Run
sudo chmod a+x /usr/local/bin/hyprspace - (Optional) Run
sudo ln -s /usr/local/bin/hyprspace /usr/bin/hyprspace
| Command | Alias | Description |
|---|---|---|
help |
? |
Get help with a specific subcommand. |
init |
i |
Initialize an interface's configuration. |
up |
up |
Create and Bring Up a Hyprspace Interface |
down |
d |
Bring Down and Delete A Hyprspace Interface |
update |
upd |
Have Hyprspace update its own binary. |
The first thing we'll want to do once we've got Hyprspace installed is
initialize the configuration for an interface. In this case we'll call the
interface on our local machine hs0 (for hypr-space 0) and hs1 on our remote server
but yours could be anything you'd like.
hyprspace init hs0hyprspace init hs1Now that we've got a set of configurations we'll want to
tell the machines about eachother. By default Hyprspace will
put the interface configurations in /etc/hyprspace/interface-name.yaml.
So for our example we'll run
sudo nano /etc/hyprspace/hs0.yamland
sudo nano /etc/hyprspace/hs1.yamlNow in each config we'll add the other machine's ID as a peer. You can find each machine's ID at the top of their configuration file. Update,
peers: {}to
peers:
10.1.1.2:
id: YOUR-OTHER-PEER-IDNotice here we'll have to pick one of our machines to be 10.1.1.1
and the other to be 10.1.1.2. Make sure to update the interface's IP
address for the machine who needs to change to be 10.1.1.2.
Looking in the interface's configuration you'll also notice a field called
discover_key (right above the interface's private key). It doesn't matter
which discovery key you pick but it much be the same for all of the nodes in your little cluster
so that they can find eachother.
(*Note you can use different discover_keys with different interfaces on the same
host to create different isolated networks.)
discover_key: fiftieth-dandelion-wronged-craftworkNow that we've got our configs all sorted we can start up the two interfaces!
sudo hyprspace up hs0and
sudo hyprspace up hs1After a few seconds you should see a the network finish setting up and find your other machine. We can now test the connection by pinging back and forth across the network.
ping 10.1.1.2Now to stop the interface and clean up the system you can run,
sudo hyprspace down hs0and,
sudo hyprspace down hs1Copyright 2021 Alec Scott hi@alecbcs.com
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.