1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-11-04 23:10:14 +01:00
Simplest dashboard for WireGuard VPN written in Python w/ Flask
Go to file
Donald Cheng Hong Zou 42bbfbe538 v2.2-beta update
2021-08-03 18:45:40 -04:00
.github/ISSUE_TEMPLATE Update issue templates 2021-04-10 12:49:34 -04:00
img Push Logo 2021-04-12 23:16:12 -04:00
src v2.2-beta update 2021-08-03 18:45:40 -04:00
.all-contributorsrc docs: update .all-contributorsrc [skip ci] 2021-04-13 02:29:48 +00:00
.gitignore Commit June 2 2021-07-02 13:23:04 -04:00
LICENSE Initial commit 2020-10-18 01:08:59 -04:00
README.md v2.2-beta update 2021-08-03 18:45:40 -04:00


Please provide your OS name and version if you can run the dashboard on it perfectly in #31, since I only tested on Ubuntu. Thank you!


Wireguard Dashboard

Monitoring WireGuard is not convinient, need to login into server and type wg show. That's why this platform is being created, to view all configurations and manage them in a easier way.

📣 What's New: Version 2.1

  • Added Ping and Traceroute tools!
  • Adjusted the calculation of data usage on each peers
  • Added refresh interval of the dashboard
  • Bug fixed when no configuration on fresh install (Bug report)
  • Fixed crash when too many peers (Bug report)

Table of Content

💡 Features

  • Add peers for each WireGuard configuration

  • Manage peer

  • Delete peers

  • And many more coming up! Welcome to contribute to this project!

📝 Requirement

  • Ubuntu or Debian based OS, other might work, but haven't test yet. Tested on the following OS:

    • Ubuntu 18.04.1 LTS
    • Ubuntu 20.04.1 LTS
    • Debian GNU/Linux 10 (buster) [❤️ @robchez]
    • AlmaLinux 8.4 (Electric Cheetah) [❤️ @barry-smithjr]
    • CentOS 7 [❤️ @PrzemekSkw]
    • If you have tested on other OS and it works perfectly please provide it to me in #31. Thank you!
  • ‼️ Make sure you have Wireguard and Wireguard-Tools (wg-quick) installed.‼️ How to install?

  • Configuration files under /etc/wireguard

    • Note:
      • For [Interface] in the .conf file, please make sure you have SaveConfig = true under [Interface] (Bug mentioned in #9)
      • For peers, PublicKey & AllowedIPs is required.
  • Python 3.7+ & Pip3

🛠 Install

  1. Download Wireguard Dashboard

    $ git clone -b v2.1 https://github.com/donaldzou/Wireguard-Dashboard.git
    
  2. Install Python Dependencies

    $ cd Wireguard-Dashboard/src
    $ python3 -m pip install -r requirements.txt
    
  3. Install & run Wireguard Dashboard

    $ sudo chmod -R 744 /etc/wireguard   # Add read and execute permission of the wireguard config folder
    $ sudo chmod u+x wgd.sh
    $ ./wgd.sh start
    

    Note:

    For pivpn user, please use sudo ./wgd.sh start to run if your current account does not have the permission to run wg show and wg-quick.

  4. Access dashboard

    Access your server with port 10086 ! e.g (http://your_server_ip:10086), continue to read to on how to change port and ip that dashboard is running with.

🪜 Usage

Start/Stop/Restart Wireguard Dashboard

$ cd Wireguard-Dashboard/src
-----------------------------
$ ./wgd.sh start    # Start the dashboard in background
-----------------------------
$ ./wgd.sh debug    # Start the dashboard in foreground (debug mode)
-----------------------------
$ ./wgd.sh stop     # Stop the dashboard
-----------------------------
$ ./wgd.sh restart  # Restart the dasboard

Autostart Wireguard Dashboard on boot

In the src folder, it contained a file called wg-dashboard.service, we can use this file to let our system to autostart the dashboard after reboot. The following has tested on Ubuntu 18.04.1 LTS, please don't hesitate to provide your system if you have tested the autostart on another system.

  1. Changing the directory to the dashboard's directory

    $ cd wireguard-dashboard/src
    
  2. Get the full path of the dashboard's directory

    $ pwd
    #Output: /root/wireguard-dashboard/src
    

    For me, my output is the one above, your's might be different since it depends on where you downloaded the dashboard. Copy the the output to somewhere, we will need this in the next step.

  3. Edit the service file

    $ nano wg-dashboard.service
    

    You will see something like this:

    [Unit]
    After=netword.service
    
    [Service]
    WorkingDirectory=<your dashboard directory full path here>
    ExecStart=/usr/bin/python3 <your dashboard directory full path here>/dashboard.py
    Restart=always
    
    
    [Install]
    WantedBy=default.target
    

    Now, we need to replace both <your dashboard directory full path here> to the one you just copied from step 2. After doing this, the file will become something like this:

    [Unit]
    After=netword.service
    
    [Service]
    WorkingDirectory=/root/wireguard-dashboard/src
    ExecStart=/usr/bin/python3 /root/wireguard-dashboard/src/dashboard.py
    Restart=always
    
    
    [Install]
    WantedBy=default.target
    

    Be aware that after the value of WorkingDirectory, it does not have a / (slash). You can save the file with control+x and press Y.

  4. Copy the service file to systemd folder

    $ cp wg-dashboard.service /etc/systemd/system/wg-dashboard.service
    

    To make sure you copy the file successfully, you can use this command cat /etc/systemd/system/wg-dashboard.service to see if it will output the file you just edited.

  5. Enable the service

    $ sudo chmod 664 /etc/systemd/system/wg-dashboard.service
    $ sudo systemctl daemon-reload
    $ sudo systemctl enable wg-dashboard.service
    $ sudo systemctl start wg-dashboard.service  # <-- To start the service
    
  6. Check if the service run correctly

    $ sudo systemctl status wg-dashboard.service
    

    And you should see something like this

    ● wg-dashboard.service
         Loaded: loaded (/etc/systemd/system/wg-dashboard.service; enabled; vendor preset: enabled)
         Active: active (running) since Tue 2021-08-03 22:31:26 UTC; 4s ago
       Main PID: 6602 (python3)
          Tasks: 1 (limit: 453)
         Memory: 26.1M
         CGroup: /system.slice/wg-dashboard.service
                 └─6602 /usr/bin/python3 /root/wireguard-dashboard/src/dashboard.py
    
    Aug 03 22:31:26 ubuntu-wg systemd[1]: Started wg-dashboard.service.
    Aug 03 22:31:27 ubuntu-wg python3[6602]:  * Serving Flask app "Wireguard Dashboard" (lazy loading)
    Aug 03 22:31:27 ubuntu-wg python3[6602]:  * Environment: production
    Aug 03 22:31:27 ubuntu-wg python3[6602]:    WARNING: This is a development server. Do not use it in a production deployment.
    Aug 03 22:31:27 ubuntu-wg python3[6602]:    Use a production WSGI server instead.
    Aug 03 22:31:27 ubuntu-wg python3[6602]:  * Debug mode: off
    Aug 03 22:31:27 ubuntu-wg python3[6602]:  * Running on all addresses.
    Aug 03 22:31:27 ubuntu-wg python3[6602]:    WARNING: This is a development server. Do not use it in a production deployment.
    Aug 03 22:31:27 ubuntu-wg python3[6602]:  * Running on http://0.0.0.0:10086/ (Press CTRL+C to quit)
    

    If you see Active: followed by active (running) since... then it means it run correctly.

  7. Stop/Start/Restart the service

    $ sudo systemctl stop wg-dashboard.service # <-- To stop the service
    $ sudo systemctl start wg-dashboard.service # <-- To start the service
    $ sudo systemctl restart wg-dashboard.service # <-- To restart the service
    
  8. And now you can reboot your system, and use the command at step 6 to see if it will auto start after the reboot. If you have any questions or problem, please report a bug.

⚠️ For first time user please also read the next section.

✂️ Dashboard Configuration

Since version 2.0, Wireguard Dashboard will be using a configuration file called wg-dashboard.ini, (It will generate automatically after first time running the dashboard). More options will include in future versions, and for now it included the following config:

Description Default Value
[Account]
username Dashboard login username admin
password Password, will be hash with SHA256 admin hashed in SHA256
[Server]
wg_conf_path The path of all the Wireguard configurations /etc/wireguard
app_ip IP address the dashboard will run with 0.0.0.0
app_port Port the the dashboard will run with 10086
auth_req Does the dashboard need authentication to access true
If auth_req = false , user will not be access the Setting tab due to security consideration. User can only change the file directly in system.
version Dashboard Version N/A

Latest Version: V2.1

All these settings will be able to configure within the dashboard in Settings on the sidebar, without changing the actual file. Except version and auth_req due to security consideration.

How to update the dashboard?

  1. Change your directory to wireguard-dashboard
    $ cd wireguard-dashboard
    
  2. Get the newest version
    $ sudo git pull https://github.com/donaldzou/wireguard-dashboard.git v2.1 --force
    
  3. Update and install all python dependencies
    $ python3 -m pip install -r requirements.txt
    
  4. Start the dashboard
    $ ./wgd.sh start
    

⚠️ Update from v1.x.x

  1. Stop the dashboard if it is running.
  2. You can use git pull https://github.com/donaldzou/Wireguard-Dashboard.git v2.1 to get the new update inside Wireguard-Dashboard directory.
  3. Proceed Step 2 & 3 in the Install step down below.

🔍 Screenshot

Index Image

Index Page

Signin Image

Signin Page

Configuration Image

Configuration Page

Settings Image

Settings Page

🛒 Dependencies

Contributors

All Contributors

Thanks goes to these wonderful people (emoji key):


antonioag95

⚠️ 💻

tonjo

💻

This project follows the all-contributors specification. Contributions of any kind welcome!