Skip to main content
# WireGuard Peer-to-Peer

A tool for setting up WireGuard connections from peer to peer.

It takes care of exchanging public keys, IP addresses and NAT traversal.


## Installation

### 0) Install WireGuard
See WireGuard's [installation page](https://www.wireguard.io/install/)

### 1) Install [BulletinBoard DHT](https://github.com/manuels/bulletinboard-dht/)

```bash
wget 'https://github.com/manuels/bulletinboard-dht/releases/download/v0.5.0/bulletinboard_0.5.0_amd64.deb'
sudo dpkg -i bulletinboard_0.5.0_amd64.deb
```

### 2) Install wg-p2p

```bash
pip install wireguard-p2p
```

## Exchange Public Keys

### 0) Create new config file (optional)

Alice creates a new WireGuard [configuration file](https://git.zx2c4.com/WireGuard/about/src/tools/wg.8) on her computer named `bob`. (Bob does the same on his machine.)

```bash
alice$ wg-p2p bob new | sudo tee /etc/wireguard/bob.conf >/dev/null

alice$ sudo cat /etc/wireguard/bob.conf
[Interface]
ListenPort = 51800
PrivateKey = p504swpAoXHitQOOPHfPmt4qqY5ik5xkUrMnAZTr4X8=
Address = 10.0.100.2/24
```


### 1) Publish Public Keys

Alice publishes her public key, so Bob can find it.

```bash
alice$ wg-p2p bob publish alice
[sudo] password for alice: # to read /etc/wireguard/bob.conf
Published public key LLgKTG7VaTZKzikIRR0oRkyZw1IKNPIXGt0RYJV2OWA= as "alice".
```


### 2) Retrieve Bob's Public Key

Alice adds Bob's public key to her configuration file. (Bob does the same on his machine.)

```bash
alice$ wg-p2p bob add-peer bob | sudo tee /etc/wireguard/bob.conf >/dev/null
1 peer(s) found named "alice".
Would you like to add the peer with public key EKJDRxMeLswhIpaCy6xnYLD1ZaHMNvi5SuT10L8w1m8=? [Y/n]
```


## Update Bob's IP and Port and traverse NAT

Alice and Bob can determine their current IP address and setup NAT traversal (using STUN) and publish it.

This has to be done initially and from time to time when both IP addresses change or the NAT traversal expired.

```bash
alice$ wg-quick down bob

alice$ wg-p2p bob update | sudo tee /etc/wireguard/bob.conf >/dev/null
Own public address: 38.12.81.2:21280, NAT type: Full Cone
Local NAT: Full Cone
Remote NAT: Full Cone
[Interface]
ListenPort = 51800
PrivateKey = p504swpAoXHitQOOPHfPmt4qqY5ik5xkUrMnAZTr4X8=
Address = 10.0.100.2/24

[Peer]
AllowedIPs = 10.0.0.0/24
PublicKey = EKJDRxMeLswhIpaCy6xnYLD1ZaHMNvi5SuT10L8w1m8=
Endpoint = 81.52.9.1:2286

alice$ wg-quick up bob
```

(Bob does the same on his machine.)

Metadata

Release files for wireguard-p2p 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wireguard-p2p 0.1.3
File Size Uploaded
wireguard-p2p-0.1.3.tar.gz 2.4 kB Details

Release files / wireguard-p2p-0.1.3.tar.gz

Download URL wireguard-p2p-0.1.3.tar.gz
Size 2.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5aedeb7aa44fd5c1c6883c181c7ab01a61d94b56ee0715957ebc037fda1a6da3
BLAKE2b-256 checksum
How to use checksums
d78792cd95856536b39dbf574d8e9455ac614afb3da4b2d23f69bd7b088c6bda
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.3 This release

1 release file

0.1.2

1 release file

0.1.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page