wg-easy provides a simplified, user-friendly interface to manage WireGuard. If you're using wg-easy, the process can be slightly different since the configuration is abstracted through a web interface. However, you can still enforce the same principles regarding network access.
Here’s a step-by-step guide tailored to wg-easy:
Step 1: Set Up Your wg-easy Server
Assuming you already have wg-easy set up and running, you can access it via its web interface.
Step 2: Create a Configuration for Your Friend
-
Log in to wg-easy:
Open your web browser and go to the wg-easy web interface.
-
Add a Client:
- In the
wg-easy web interface, add a new client configuration for your friend. This typically generates a client configuration file and QR code.
- Copy the contents of the configuration file or share the QR code with your friend.
-
Restrict Allowed IPs:
Edit your friend’s configuration to limit the AllowedIPs to only your local network. In wg-easy, this can generally be done through the web interface.
For instance:
[Interface]
PrivateKey = <Friend_Private_Key>
Address = 10.0.0.2/24
[Peer]
PublicKey = <Server_Public_Key>
Endpoint = <Server_Public_IP>:51820
AllowedIPs = 192.168.1.0/24 # Change this to your local network
In this case, ensure that the AllowedIPs on the WireGuard client is only set to the local service subnet or specific service IP.
Step 3: Configure Server-Side Firewalls
Since wg-easy abstracts the underlying configuration, you won’t need to manually edit any WireGuard configuration files like wg0.conf. Instead, focus on setting up firewall rules on the server itself:
-
Setup iptables:
If your server doesn’t have iptables installed, you can install it:
sudo apt-get update
sudo apt-get install iptables
-
Configure iptables Rules:
Implement firewall rules to restrict your friend’s access:
# Allow WireGuard clients to access the local network
iptables -A FORWARD -i wg0 -s 10.0.0.2/32 -d 192.168.1.0/24 -j ACCEPT
# Default policy for other traffic from WireGuard clients: DROP everything else
iptables -A FORWARD -i wg0 -s 10.0.0.2/32 -j DROP
# Ensure the rules are persistent across reboots
sudo apt-get install iptables-persistent
sudo netfilter-persistent save
Replace 192.168.1.0/24 with your actual local network or the specific service IP.
Verification
Ensure that your friend can connect to the WireGuard-enabled network and access the specific local service but is unable to use WireGuard to access other parts of the internet.
Summary
Using wg-easy makes managing WireGuard simpler, but you can still implement precise access controls by combining configured AllowedIPs on the client side and iptables rules on the server side to enforce network policies. This ensures that your friend can only access the resources you specify and nothing else.