WireGuard / wgctrl-go

Package wgctrl enables control of WireGuard interfaces on multiple platforms.
https://godoc.org/golang.zx2c4.com/wireguard/wgctrl
MIT License
753 stars 84 forks source link

problems with ip-forwarding #93

Open schnapper79 opened 4 years ago

schnapper79 commented 4 years ago

Hi there,

i seem to have a strange behavior which I narrowed down to this library even if it makes no sense in the first place.

I wrote an application where clients can add themselves to the wireguard vpn via gprc calls.I want to have ipforwarding within the private network using the "wireguard -server" where the application is running as a "router". It's a machine running Arch linux, IP-forwarding is activated via sysctl and iptables, routes for the network (lets say 172.15.0.0/16) get set when firing up the device with wg-quick up wg0.

When server is up the clients can connect the server via gprc, give their public key, get their associated IP and the public key of server and are added to the server wireguard configuration using this library (adding a new peer like shown in the examples). So far everything works fine, i get a connection, I can ping or ssh from server to client and backwards, just like a dream. BUT: i can not ping from Client A to Client B. I use the same configuration for allowedIPs as I do when configuring manually via wg0.conf. Configuring the wireguard device on server 100% via wg0.conf, IP-forwarding works 100% (I tested by using wg showconf wg, stored configuration into wg0.conf and started again without using this library.) Is there any flag I have to set when adding a peer with this library i may have overlooked? Any Ideas what might be wrong?

Just to clearify: i am using wireguard as a kernel module

SaadAhmedGit commented 6 months ago

I am probably late but this is because you need to add a rule in the routing table to route that particular ip to the wireguard interface. This is not the job of this library and wg-quick does it automatically.