Giter Club home page Giter Club logo

wireguard-site-to-site's Introduction

About this

This is wireguard script configuration for a intermediate public server to interconnect two sites.

Network Schema, there is a LAN called 1 in one side with a router drawing a line to vpn server and another line to internet and the same in the other side

So you can reach LAN 2 from LAN 1 and vice versa but LAN also reach Internet directly without using VPN Server. The VPN server is only used to reach each LAN.

Warning

This is not a newbie tool, this is just a helper to configure my VPN server. If you do not know about networking, linux & vpn (wireguard) this tool maybe, it is not for you. Anyway if you know and you think you can do a better job to give a good documentation for everyone I accept contributions.

Generate the configuration in your system

Install wireguard-tools to generate the configuration.

Linux

  1. Install using whatever package manager is in your Linux system the packages wireguard & wireguard-tools
  2. Configure .env.dist and save as .env
  3. Generate the config
./generate_wg_config

macOS

  1. Install brew & wireguard cli
! { command -v brew &> /dev/null; } && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
! brew list wireguard-tools &> /dev/null && brew install wireguard-go wireguard-tools
  1. Configure .env.dist and rename to .env
mv .env.dist .env
  1. Generate the config
./generate_wg_config

Windows

  1. Install WSL and use in WSL as Linux

Next step

Starting Wireguard

If you have generated the configuration files in the final Wireguard Server you can set up Wireguard as a service by using:

./start_wg_as_service

If you want to test or you want to execute wireguard manually you can by using:

echo "Starting wireguard"
./start_wg

To stop:

echo "Stoping wireguard"
./stop_wg

Configure terminals

Install wireguard in the terminals (phone or computer) that would be also a peers (outside of the LANS) and use the configuration files for those peers.

Configure gateways

In the LANs, install the wireguard or use wireguard-go dockerized using the configuration file.

If you use Wg in your gateway it must know how to get any direct local network so you should be able to get those networks that router must know how to reach and route to other networks through the VPN networks. Any special routing configuration can be needed so you need some networking knowledge.

Please do not use issues to ask about any other configuration that is not implicit with wireguard or any linux server configuration.

Adding new peers

After generating a configuration you can add a new peer by using ./add_new_peer command.

See usage with ./add_new_peer --help.

IMPORTANT: You need to know the ip you will give to the peer and configuration must be as when generated (minimum the public & private keys & configuration for server, normmally called wg0).

Using as binaries

You can use these scripts by adding them to PATH in your .bashrc (or equivalent file), execute in the path of these files locally:

echo "PATH=\"\${PATH+:\$PATH:$PWD}\"\n" | tee -a ~/.bashrc &>/dev/null
. ~/.bashrc
{ grep -q "$PWD" ~/.bashrc && command -v add_new_peer && echo "Now you can execute wireguard-site-to-site scripts"; } || echo "[FAIL] wireguard-site-to-site PATH could not be found"

Contributing

PRs are accepted to improve the scripts, tools and documentation. Anyway, whatever contribution should keep the main target which is connect P2P two or more LANs.

Wireguard Help

If you need some help with wireguard the official webiste (witepapper) is very good reference but you can also access to sample wireguard configurations and documentation here:

wireguard-site-to-site's People

Contributors

gtrabanco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.