Giter Site home page Giter Site logo

wireguard-key-generator's Introduction

Prepare files

  1. install python dependency

    python3 -m pip install -r req.txt
    
  2. rename db.json.template to db.json

    cp ./db.json.template ./db.json
  3. change last_ip in db.json to your own network ip address.

For example in wireguard default network is 10.0.0.0/8 and server address is 10.0.0.1.

You should set "last_ip" as 10.0.0.1 and after that the script will increment ip addresses

  1. in main.py you have to set BASE_DIR
    ...
    BASE_DIR = "/etc/wireguard"
    ...

Generate server and client keys

  1. run key generator

    python3 main.py --name <client-name>
    
  2. copy output to wg0.conf

    output look like

    udwfMasdsadsadsddsasdkjasoidhughfasd=
    
    # <client-name>
    [Peer]
    PublicKey = udwfMasdsadsadsddsasdkjasoidhughfasd=
    
    AllowedIPs = 10.0.0.29/32
    
    /<BASE_DIR>/confs/<client-name>_wg.conf
    

    You have to copy

    # <client-name>
    [Peer]
    PublicKey = udwfMasdsadsadsddsasdkjasoidhughfasd=
    
    AllowedIPs = 10.0.0.29/32
    

    and paste it to wireguard config file (by default /etc/wireguard/wg0.conf)

  3. send /<BASE_DIR>/confs/_wg.conf to client

  4. restart wireguard service

    systemctl restart wg-quick@wg0
    

Client

Install wireguard https://www.wireguard.com/install

Connect to server

wg-quick up <client-name>_wg.conf

Drop connection

wg-quick down <client-name>_wg.conf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.