Wireguard HALP

So I've come up with a Wireguard use case I'd like to pursue: use wireguard to allow devices off my home network to VPN onto my home network, and connect to the Internet through my home network. The idea is for remote server access, private Internet use in hotels and cafes, and so on.

Complications: I'm new to VPN in general, don't know much at all about IPv6, and my v4 isn't super-sharp either, and I'm testing all this on a home network that's a little complicated (and this may be adding more difficulty than there should be).

My test clients are on my "guest" network: 192.168.2.0/24. My test server is on my regular network: 192.168.1.0/24. Guests can get on the Internet but not on my regular network for the most part, but I've opened up ports and confirmed that I can successfully allow guests to access specific ports on the server.

Running "wg" in the (Linux) server shows:

interface: wg0
public key: (hidden)
private key: (hidden)
listening port: 51820

peer: (hidden)
endpoint: 192.168.2.209:55467
allowed ips: 0.0.0.0/0, ::/0
latest handshake: 49 seconds ago
transfer: 25.77 KiB received, 26.64 KiB sent

peer: (hidden)
endpoint: 192.168.2.194:60176
allowed ips: 0.0.0.0/0, ::/0
latest handshake: 4 hours, 24 minutes, 24 seconds ago
transfer: 8.94 KiB received, 18.31 KiB sent

Both clients (PC running the beta official Windows wireguard client, and an Android running the app) seem to be doing the handshake just fine, but once connected, no traffic flows to any point on the LAN or the Internet.

The wireguard network interface is 192.168.3.1/24. I'm thinking maybe the problem is some sort of missing step to route the traffic from 3.x to anywhere else, but I'm not sure what to try.

The clients have allowed IPs set to 0.0.0.0/0 on their end, but I've also tried 192.168.0.0/16 and so on, but that just limits the scope of where I can't connect--anything sent through the tunnel fails. The android client Wireguard IP is 192.168.3.3/32.

Anything obviously off? Theoretically I wouldn't even be using this from my own guest network, but it's an easier way to test. If it's simply not going to work from my guest network because of some factor I hadn't considered, but would still work remotely, that's fine with me.
 

chalex

Ars Legatus Legionis
11,921
Subscriptor++
I think you also need to set up ip forwarding and routing correctly.

I used the ansible playbooks from the algo project for my wireguard testing (on Ubuntu on GCP).

Think about it, on the client, you probably want to reconfigure your routing to send all traffic to just the wireguard interface. And then on the server, it needs to know how to masquerade and forward the traffic out to whichever network you want it to go.

There's some stuff here, but I think it's Ubuntu-specific and Ansible-specific https://github.com/trailofbits/algo/tre ... /wireguard

I have also found the main wireguard docs not sufficient to get things up and running.
 

gusgizmo

Ars Praefectus
3,057
Subscriptor
Not wireguard specific, but you really, really want to change that 192.168.1.0/24 network to something a bit more unique so you don't end up with a client on the same network range tweaking out due to the overlap in IP's. Let's just call it undefined behavior. I like the 172.22.0.0/16 prefix as it's easy to type and uncommon on consumer gear.

Sounds like you are trying to hairpin your VPN traffic from the guest to the main network? That can work, but I would suggest it's extra work and complexity. Testing on a 4g hotspot is a good way to handle this.
 
In my experience it's just the one 192.168.1.1 address that new devices like to sit on, but the rest of the 1.x range is safe. I definitely already avoid putting anything at 1.1 for this reason, but I've found having 1.x be the default network helps me get those new devices configured more easily. YMMV. So far, no hairpinning because I'm using internal-only addresses for testing this VPN, and there's no NAT happening anywhere on the network except at the WAN link. Presumably once I got it working externally, I'd need hairpin NAT working to get the same config working internally. But I don't actually need it working internally beyond the test phase.
 

Coleman

Ars Legatus Legionis
16,790
Subscriptor
So, start smaller...
when the tunnel is up, can the peers ping each other?

Also, any particular reason you changed the end points on the peers (why not run everyone on 51820, changing the endpoints now(which you can always do later) just seems like making it extra complicated for yourself?

Also, it looks like you've got 3 peers? Start with 2, and get 2 running. Once you have 2 going, then add others. Oh in fact...I just realized...you have *2* peers that say you are routing all traffic to. Don't do that. Change your allowed IPs for now to just be the each of the peers own local address. Again, start small, get that working, then expand out.

More specifically, you don't want this on more than 1 peer:
Code:
allowed ips: 0.0.0.0/0, ::/0

Otherwise you are telling it that each one of those peers should handle all traffic. I imagine at best, that's confusing the heck out of everything. You're creating a multiple gateway situation which...you don't want to get into right now.
 
Piggy-backing on what Coleman stated. You'll need to change the AllowedIPs for the peers to the peer's IP address so that only traffic destined for that peer gets routed there. You use AllowedIPs = 0.0.0.0/0 on the clients only if you want to route all traffic across the wireguard vpn. Otherwise, you can put only your internal networks there and do split tunneling.


I've posted a sanitized version of my wireguard configs from my server and a client. Peer2 would be similar:

Server config:
Code:
interface: wg0
  public key: (hidden)
  private key: (hidden)
  listening port: 51820

peer: (peer1-key)
  allowed ips: 192.168.0.10/32
  
peer: (peer2-key)
  allowed ips: 192.168.0.11/32
Peer1 config:
Code:
[Interface]
Address = 192.168.0.10/32
PrivateKey = (peer-private-key)
DNS = 192.168.0.5

[Peer]
PublicKey = (hidden)
Endpoint = server_hostname:51820
AllowedIPs = 0.0.0.0/0
 

Frennzy

Ars Legatus Legionis
85,841
ally want to change that 192.168.1.0/24 network to something a bit more unique so you don't end up with a client on the same network range tweaking out due to the overlap in IP's. Let's just call it undefined behavior

I just wanted to point something out here:

There is nothing undefined about what would happen. If you have IP overlap, you simply won't be able to communicate, because when a sending client compares its IP and subnet mask (AND operation) it will see that the destination IP it wants to send to is "local" to its own subnet, and thus will ARP for it, and timeout...rather than thinking it's offnet and handing the packet to the next hop/default gateway.

Also, 172.16.0.0 as a prefix is *extremely* common.
 

sryan2k1

Ars Legatus Legionis
46,882
Subscriptor++
There is nothing undefined about what would happen. If you have IP overlap, you simply won't be able to communicate, because when a sending client compares its IP and subnet mask (AND operation) it will see that the destination IP it wants to send to is "local" to its own subnet, and thus will ARP for it, and timeout...rather than thinking it's offnet and handing the packet to the next hop/default gateway.


Depends on VPN client. Pulse, and AnyConnect have preferences of what to do it the case of IP overlap. You basically pick "Prefer tunneled routes" or "prefer local routes".

Since the VPN adapter is working at the network driver level it intercepts requests before an ARP would even occur.