vx3r / wg-gen-web

Simple Web based configuration generator for WireGuard
https://wg-gen-web-demo.127-0-0-1.fr
Do What The F*ck You Want To Public License
1.6k stars 191 forks source link

Site to Site #62

Open Schu- opened 3 years ago

Schu- commented 3 years ago

I have been working with this project and really like how it seems to work. I was wondering if there is an easy way to setup like a site to site connection with it. Maybe even a wg-gen-web to wg-gen-web configuration? Right now i might need to setup 2 wireguard interfaces so I can still achieve my site to site with one, while having another with client roaming clients.

Thanks for all the hard work in this tool.

vx3r commented 3 years ago

hi, what is missing for the site to site config ? You need to add a static route right ? If you can describe what is needed for your config i can look at it.

Schu- commented 3 years ago

Ahh sorry. Maybe I was not clear. So Site A has wg-gen-web setup. Site B also has wg-gen-web setup. There is no way for me to setup a client at Site A and import it into Site B. I have been able to modify the config files and make it so both endpoints have the right info on both sides. Problem is I am not able to set an Endpoint for a client. So they never actually try and connect to each other. If I modify the wg0 config file it gets overwritten as expected.

kreditor0815 commented 3 years ago

I'm also looking for a solution to this problem. As far as I can tell, the [Peer]-Section of the resulting wg0.conf is missing an "Entrypoint = $dns.of.remote.endpoint:51280" and "PersistentKeepalive = 25" Entries. As soon I add those two lines to the wg0.conf generated by wg-gen-web, my site2site vpn is working.

Beside this, I manipulated the "PublicKey = " and "PresharedKey = " entries in the peer-json, that is merged with the server.json to wg0.conf

It would be great to be able to set those client-specific settings via the web-ui. But to get this up and running it would be awesome to be able to set those settings in the according json-file.

Eg: extended the Client struct in file https://github.com/vx3r/wg-gen-web/blob/master/model/client.go with those fields:

    Endpoint                string `json:"endpoint"`
    PersistentKeepalive     int `json:"persistentKeepalive"`

and maybe add checks accordingly.

Also in https://github.com/vx3r/wg-gen-web/blob/master/template/template.go add the apropriate sections to the wgTpl-variable:

{{if ne .Endpoint "" -}}
Endpoint = {{ .Endpoint }}
{{- end }}
{{if ne .PersistentKeepalive 0 -}}
PersistentKeepalive = {{ .PersistentKeepalive }}
{{- end }}

As far as i saw, this should be enough to persist needed settings over regeneration of the wg0.conf-file. But that is just a result of a first look at the code.

What do you think?

Edit: I got it running with these modifications.