micahmo / WgServerforWindows

Wg Server for Windows (WS4W) is a desktop application that allows running and managing a WireGuard server endpoint on Windows
MIT License
895 stars 87 forks source link

How to reload the new clients? #107

Open WMKTT opened 1 year ago

WMKTT commented 1 year ago

I try to add new clients but it didn't work, until i reinstall it. Because i don't know how to restart it or reload the config file.

The same thing i noticed in linux, when i modify something in wg-server config file, i need to restart wireguard to make it work.

so i wondering how to restart win-wireguard or how to reload its config file....

Thank you to make this ui for us!

micahmo commented 1 year ago

Hi @WMKTT, WS4W is supposed to automatically synchronize the server and client configs as soon as you save them. The conditions for doing so are that all the clients are valid (no red boxes), the server config is also valid, and the tunnel service is installed. Here is the code.

I personally have not had this issue, nor have I had to manually restart WireGuard to get new clients, so you may have discovered a unique bug.

Maybe when this happens you can try syncing the config manually (without restarting) and see if you get any errors. This is the command that WS4W uses.

wg syncconf wg_server wg_server.conf

P.S. That same syncconf command should help you on Linux.

Hope that helps!

WMKTT commented 1 year ago

Hi, micahmo: Thanks your reply, i have tried your suggestion, i think my problem is when a new client i added, it can establish connection with server, but can not access the server local network 192.168.0.1/24, the old clients can. I don't know why.

Hope your reply, thanks!

micahmo commented 1 year ago

Interesting, so you must restart the WireGuard service in order for your clients to access the private network? And that's also true on Linux? Again I do not see that on my system. And if it's true on Linux, then I'm not sure what WS4W is doing wrong.

I suppose the nice thing is that you can restart the service in WS4W by pressing "Uninstall tunnel service" and then "Install tunnel service". It's a bit painful, but at least it's possible without going into any other apps or command line.

WMKTT commented 1 year ago

Thank you very much for your suggestion. I tried it on another Win10 computer and was able to load the new client by deleting and reinstalling Tunnel. Otherwise, it wouldn't work. I encountered the same issue with the official WireGuard on Ubuntu 20.04, where I had to restart the service once to make it work. It seems that WireGuard generates client information directly from the configuration in wg.conf, and changes to the script are not effective after the service is started, as the official documentation also mentions. However, restarting WireGuard on Windows is quite difficult in a work environment, which is why I came to ask for help. Thank you very much for your response. This was translated using ChatGPT, so please forgive any inaccuracies in the language.

micahmo commented 1 year ago

This was translated using ChatGPT

It is very good, I am impressed! 😊

It seems that WireGuard generates client information directly from the configuration in wg.conf, and changes to the script are not effective after the service is started, as the official documentation also mentions.

Can you link this part of the documentation? This has not been my experience, at least when using the syncconf command. Also, as you mentioned, the client does work, it just doesn't have access to the private network, so something else is going on.

WMKTT commented 1 year ago

Thanks your reply again,

I looked at the wrong URL and mistook Procustodibus' tutorial for the official website of WireGuard. But the tutorial was very detailed, and since I was previously learning how to use WireGuard, I used that website as a reference.

This is the url :https://www.procustodibus.com/blog/2020/11/wireguard-point-to-site-config/#configure-routing-on-host-b.

I have a Windows server with local IP 192.168.1.2 and an Ubuntu 22 server with local IP 192.168.1.3 and WireGuard IP 10.0.0.1. To access the Windows server, I decided to set up WireGuard on the Ubuntu server by following a guide I found online.

I successfully created a client with WireGuard IP 10.0.0.2 and was able to access the Ubuntu server from another PC, with successful ping to 10.0.0.0/24 and 192.168.0.0/24 . However, when I added a new client with WireGuard IP 10.0.0.3 to the WireGuard config file on Ubuntu, I couldn't access the server with that IP unless I restarted WireGuard by running "wg-quick down" and then "wg-quick up".

Although I set up WireGuard on Ubuntu, I still couldn't access the Windows server. I suspect something went wrong with the NAT settings, as I have an IPsec VPN on Ubuntu that can reach other devices on the local network. However, I couldn't find any useful settings after searching in google for two weeks.

Eventually, I set up WireGuard on the Windows server and it worked perfectly.

I'm grateful to you created this software!

micahmo commented 1 year ago

I looked at the wrong URL and mistook Procustodibus' tutorial for the official website of WireGuard.

That is understandable, their logo and color scheme are very similar to WireGuard's.

on Ubuntu, I couldn't access the server with that IP unless I restarted WireGuard by running "wg-quick down" and then "wg-quick up"

Did you try the syncconf command?

Eventually, I set up WireGuard on the Windows server and it worked perfectly.

I'm very glad to hear that! Are you all set with this issue?