wireguard-ui icon indicating copy to clipboard operation
wireguard-ui copied to clipboard

Clients generated with UI does not work

Open afzl-wtu opened this issue 2 years ago • 2 comments

I have installed wireguard with road-warrior script. It works really very good. Then I run 'sudo ./wireguard-ui.sh' and web ui server starts at port 5000. In Status tab it also shows all clients added by above script. I also updated private and public keys of interface from old /etc/wireguard/wg0.conf (generated by road warrior script) and updated interface address to 10.7.0.1/24 (this interface adress is also generated by roadwarror script). But when I add any client with your web-ui, It is displayed under Clients tab and also in /etc/wireguard/wg0/conf but not shown in Status Tab. Moreover any generated config file or QR code does not connect to the server. Only files generated with script works.

Update

Finally I found a solution. After every client addition or deletion You must run "sudo systemctl restart wg-quick@wg0" in terminal after clicking on "Apply Config" Button.


I also tried installing wireguard-ui without above script. There is no any documentation of how to install wireguard and what to configure and when to run sudo ./wireguard-ui. But anyway here are steps that I made on a new new clean server which had never a wireguard server before:

  1. I installed wireguard by sudo apt install wireguard wireguard-tools.
  2. Then I ran sudo ./wireguard-ui and thats all. This ways UI is not even able to generate a interface and again clients generated do not connect to server.

afzl-wtu avatar Jul 17 '22 10:07 afzl-wtu

WireGuard-UI only takes care of configuration generation. You can use systemd to watch for the changes and restart the service. Following is an example:

systemd Create /etc/systemd/system/wgui.service

[Unit]
Description=Restart WireGuard
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart [email protected]

[Install]
RequiredBy=wgui.path

Create /etc/systemd/system/wgui.path

[Unit]
Description=Watch /etc/wireguard/wg0.conf for changes

[Path]
PathModified=/etc/wireguard/wg0.conf

[Install]
WantedBy=multi-user.target

Apply it

systemctl enable wgui.{path,service}
systemctl start wgui.{path,service}

nanhantianyi avatar Sep 02 '22 00:09 nanhantianyi

restarting wg-quick@wg0 removes all recorded stats. No need to restart the interface just upload new configuration to interface.

afzl-wtu avatar Sep 02 '22 06:09 afzl-wtu

restarting wg-quick@wg0 removes all recorded stats. No need to restart the interface just upload new configuration to interface. @afzl-wtu do you mean you used systemd to watch for the changes and upload new configuration to interface ? how did you do that ? Thanks

ramikhreim1 avatar Oct 01 '22 22:10 ramikhreim1

No need to restart the interface just upload new configuration to interface.

how did you do that ?

Change the ExecStart line in the unit file to this (adjust paths as necessary):

ExecStart=/usr/bin/wg syncconf wg0 <(/usr/bin/wg-quick strip /etc/wireguard/wg0.conf)

This won't apply all changes to the interface itself, though, as certain options are only understood by wg-quick (hence the wg-quick strip command). But for just adding/removing/enabling/disabling clients without bumping others off, this is perfect.

See the wg-quick manpage for a list of those items that won't be refreshed. When changes are made for these options in wireguard-ui, you'll have to restart wireguard manually, if you use the ExecStart line above.

MaffooClock avatar Nov 02 '22 14:11 MaffooClock

restarting wg-quick@wg0 removes all recorded stats. No need to restart the interface just upload new configuration to interface. @afzl-wtu do you mean you used systemd to watch for the changes and upload new configuration to interface ? how did you do that ? Thanks

Sorry for Late reply. There is a command in this script that After adding new configuration to /etc/wireguard/wg0.conf again adds the new added client configuaration to wireguard interface directly. So no need to create systemd and keep watching for changes in the file.

https://github.com/Nyr/wireguard-install

afzl-wtu avatar Nov 02 '22 15:11 afzl-wtu

ExecStart=/usr/bin/wg syncconf wg0 <(/usr/bin/wg-quick strip /etc/wireguard/wg0.conf)

i'm new to this, are you referring to this line?

# Append new client configuration to the WireGuard interface
wg addconf wg0 <(sed -n "/^# BEGIN_PEER $client/,/^# END_PEER $client/p" /etc/wireguard/wg0.conf)

if so, how should this be for this setup?

yodaphone avatar Dec 11 '22 12:12 yodaphone

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Feb 18 '23 00:02 stale[bot]