donaldzou / WGDashboard

Simple dashboard for WireGuard VPN written in Python & Vue.js
https://donaldzou.github.io/WGDashboard-Documentation/
Apache License 2.0
1.59k stars 236 forks source link

Enable Configuration after restart #402

Closed PuckeyP closed 1 week ago

PuckeyP commented 1 month ago

I installed WGDashboard as an lxc on a Proxmox host. After install I created a wireguard configuration with several peers. This works fine. But when the the LXC reboots/restarts, the configuration is disabled. I would need an option to autostart/enable a configuration at start

feliscat commented 1 month ago

@PuckeyP It would be very helpful to have this, but as a workaround you can put a one-line curl command to the API to toggle on the configuration at startup.

Kroesss commented 1 month ago

I second this request. It is annoying to find out that you don't have access anymore because you rebooted. In my opinion, it should be the defult behaviour to have the configurations enabled or disabled, depending on their state when the system was rebooted.

PuckeyP commented 1 month ago

@PuckeyP It would be very helpful to have this, but as a workaround you can put a one-line curl command to the API to toggle on the configuration at startup.

Hi Feliscat can yoou explain how to do this? Thx, PPee

donaldzou commented 1 month ago

Hi all, yes I'm aware this feature is highly requested and is in the pipeline of the next release. In the mean time, please follow this instruction if you're using a service file to host WGDashboard :)

Enable WireGuard configuration when WGDashboard start

donaldzou commented 1 month ago

Hi @PuckeyP , you can follow the API instruction on API Documentation to utilize WGDashboard's API endpoint.

Assuming you have API keys setup, to toggle a WireGuard configuration with cURL, you just need to do the following:

curl --location 'http://hostname:port/api/toggleWireguardConfiguration/?configurationName=wg0' \ 
--header 'wg-dashboard-apikey: your_api_key'

For more information on this endpoint

DaanSelen commented 1 month ago

I installed WGDashboard as an lxc on a Proxmox host. After install I created a wireguard configuration with several peers. This works fine. But when the the LXC reboots/restarts, the configuration is disabled. I would need an option to autostart/enable a configuration at start

Do you mean like the feature in the Docker container with the enable option? https://github.com/donaldzou/WGDashboard/blob/main/docker/compose.yaml

Just so that we can nail down the issue

Kroesss commented 1 month ago

@DaanSelen I don't have experience with docker, but the following line from your link looks exactly like what I would like to see indeed:

- enable=wg0 # <--- Set the interfaces that will be enabled on startup, default: none. The option "off" is also allowed.

DaanSelen commented 1 month ago

@DaanSelen I don't have experience with docker, but the following line from your link looks exactly like what I would like to see indeed:

- enable=wg0 # <--- Set the interfaces that will be enabled on startup, default: none. The option "off" is also allowed.

@donaldzou is this possible? Otherwise @Kroesss you can try the docker container if you are comfortable with that, I can help if you'd like.

Kroesss commented 1 month ago

@DaanSelen I have no experience with docker at all. I'm running Wireguard with WGDashboard in a Proxmox LXC-container.

If it is possible to solve this, that would obviously be the most ideal for me. For now, I know the issue exists and can work around it, so there is no need to put a alternative in place. If this is not fixable, than maybe the docker-version will become more appealing for my use-case.

donaldzou commented 1 month ago

@donaldzou is this possible? Otherwise @Kroesss you can try the docker container if you are comfortable with that, I can help if you'd like.

I'm thinking one potential solution is embedding a line in the .conf file of the configuration, where:

[Interface]
#AutoStart#=true
PrivateKey=....

[Peer]
PublicKey=...

and WGDashboard will look for if #AutoStart#=true and enable it the configuration whenever it start.

DaanSelen commented 1 month ago

@donaldzou is this possible? Otherwise @Kroesss you can try the docker container if you are comfortable with that, I can help if you'd like.

I'm thinking one potential solution is embedding a line in the .conf file of the configuration, where:

[Interface]
#AutoStart#=true
PrivateKey=....

[Peer]
PublicKey=...

and WGDashboard will look for if #AutoStart#=true and enable it the configuration whenever it start.

If that works, it would be great then I can remove the feature from the Docker container and let WGDashboard do it instead.

rayzorben commented 1 month ago

Came here for this same issue, I am switching from wg-easy to WGDashboard because of LXC support and couldn't get into my system after a power outage :(

donaldzou commented 1 month ago

Came here for this same issue, I am switching from wg-easy to WGDashboard because of LXC support and couldn't get into my system after a power outage :(

Hi @rayzorben, please follow this Enable WireGuard configuration when WGDashboard start instruction if you're using system service to start WGDashboard. I'm implementing an easier way to enable configuration automatically in the next release. Sorry for the wait :(

donaldzou commented 1 week ago

This feature is implemented in v4.1-dev :)

DaanSelen commented 1 week ago

This feature is implemented in v4.1-dev :)

Okay then I can remove it from the bash script in the Docker container.

donaldzou commented 1 week ago

This feature is implemented in v4.1-dev :)

Okay then I can remove it from the bash script in the Docker container.

If u needed to have it by default, simply add it in the generated default wg-dashboard.ini file you mentioned sometimes ago:

[WireGuardConfiguration]
autostart = wg0||wg1

Just split the configuration name with two pipe (|)