Closed nathandtrone closed 2 years ago
Hi,
I see a couple of things:
bash$ wg show
interface: wg0
public key: nBfPpavcYn1eP8iWnme7xzUE+hhgblHG93gBbbbycXU=
private key: (hidden)
listening port: 51820
it seems that you haven't registered the peer in the server:
wg0.conf
provided is the server configuration, it looks like you're using the same key for the client and the server.
The server's private key mHYd133DU06uB2+UX+hpgqVrrDkQi8KReNfHIx9pynk=
(pubkey: nBfPpavcYn1eP8iWnme7xzUE+hhgblHG93gBbbbycXU=
) and at the same time you configure the peer (client) with same public key.I hope this solves the problem!
PS: don't forget to change all the keys
You nailed it. My Copy and paste didn't actually copy. Sorry for something so simple. I have a new problem though. My clients, testing using my phone right now and my personal machine.. I've discovered I cannot have wireguard for Android use the option AllowedIPs set to the wireguard network only(ex: 10.11.12.#/24). Anyway, on my desktop and phone, I don't seem to have internet access. I can ping the servers Local IP and everything networking wise functions as expected. I am concerned about my routing tables.
Do you think this is the appropriate approach for the post-up/down (In the event I set the AllowedIPs to something more restricting like 0.0.0.0/0.):
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
I am wondering how I should approach giving these clients access to a specific docker containers IP via the VPN. I was going to add another entry to the up/down to manually redirect an IP within the VPN range (ex .254), not sure how, but from my research I gather that should be possible. Just figure it's probably something you've seen attempted before?
I've since changed my keys haha. Thanks for the reminder.
I understand that you want to use the wireguard server as a "privacy vpn" to route all your internet traffic. If that's the case, your server config should look like this:
[Interface]
Address = 10.11.12.1/24
ListenPort = 51820
PostUp = iptables -t nat -A POSTROUTING -s 10.11.12.0/24 -o eth0 -j MASQUERADE
PostDown = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
PrivateKey = ...
and the AllowedIPs
in your client configuration should be 0.0.0.0/0
(route everything to the wg interface).
I am wondering how I should approach giving these clients access to a specific docker containers IP via the VPN. I was going to add another entry to the up/down to manually redirect an IP within the VPN range (ex .254), not sure how, but from my research I gather that should be possible. Just figure it's probably something you've seen attempted before?
This is the easiest way I know:
wg0
interface from the hostwg0
ip:docker-compose.yaml
ports:
- 10.11.12.2:80:80
If you want to run the wireguard in a container, I guess you could do the same as long as the docker containers you want to expose are in the same network as the wireguard container, but I haven't tried. If you find how to do it please share it ;)
I've spun up a docker container using
sudo docker-compose up -d
but the wireguard server isn't allowing clients to connect. I've got all of the related files here, and I've made sure that the clients are able to reach into the container(see the UDP NC listen below). I see it's reaching the server, but for whatever reason it refuses to respond to the handshake for the client. I'm not sure what I'm doing wrong here. I was hoping to use this container to build a web management interface as well. Any insight would be greatly appreciated.