wireguard-install README

The project's README from github.com/hwdsl2/wireguard-install. As one markdown file: README.md.

English | 简体中文 | 繁體中文 | Русский | Video en Español

WireGuard VPN Server Auto Setup Script

Build Status GitHub Stars License: MIT

WireGuard VPN server installer for Ubuntu, Debian, AlmaLinux, Rocky Linux, CentOS, Fedora, openSUSE and Raspberry Pi OS.

This script will let you set up your own VPN server in just a few minutes, even if you haven't used WireGuard before. WireGuard is a fast and modern VPN designed with the goals of ease of use and high performance.

Features:

Also available:

📘 Interested in self-hosted AI? The Self-Hosted AI Builder’s Guide is a practical guide to building, securing, and operating your own private AI stack.

Installation

First, download the script on your Linux server*:

wget -O wireguard.sh https://get.vpnsetup.net/wg

* A cloud server, virtual private server (VPS) or dedicated server.

Option 1: Auto install WireGuard using default options.

sudo bash wireguard.sh --auto
See the script in action (terminal recording).

Note: This recording is for demo purposes only.

Tip: Optionally install OpenVPN, IPsec VPN and/or Headscale on the same server.

For servers with an external firewall (e.g. EC2/GCE), open UDP port 51820 for the VPN.

Option 2: Interactive install using custom options.

sudo bash wireguard.sh

You can customize the following options: VPN server's DNS name, UDP port, DNS server for VPN clients and name of the first client.

For servers with an external firewall, open your selected UDP port for the VPN.

Click here if you are unable to download.

You may also use curl to download:

curl -fL -o wireguard.sh https://get.vpnsetup.net/wg

Then follow the instructions above to install.

Alternative setup URLs:

https://github.com/hwdsl2/wireguard-install/raw/master/wireguard-install.sh
https://gitlab.com/hwdsl2/wireguard-install/-/raw/master/wireguard-install.sh

If you are unable to download, open wireguard-install.sh, then click the Raw button on the right. Press Ctrl/Cmd+A to select all, Ctrl/Cmd+C to copy, then paste into your favorite editor.

Advanced: Auto install using custom options.

Advanced users can auto install WireGuard using custom options, by specifying command-line options when running the script. For more details, see the next section "view usage information for the WireGuard script".

Alternatively, you may provide a Bash "here document" as input to the setup script. This method can also be used to provide input to manage users after install.

First, install WireGuard interactively using custom options, and write down all your inputs to the script.

sudo bash wireguard.sh

If you need to remove WireGuard, run the script again and select the appropriate option.

Next, create the custom install command using your inputs. Example:

sudo bash wireguard.sh <<ANSWERS
n
51820
client
2
y
ANSWERS

Note: The install options may change in future versions of the script.

View usage information for the WireGuard script.
Usage: bash wireguard.sh [options]

Options:

  --addclient [client name]      add a new client
  --dns1 [DNS server IP]         primary DNS server for new client (optional, default: Google Public DNS)
  --dns2 [DNS server IP]         secondary DNS server for new client (optional)
  --listclients                  list the names of existing clients
  --removeclient [client name]   remove an existing client
  --showclientqr [client name]   show QR code for an existing client
  --uninstall                    remove WireGuard and delete all configuration
  -y, --yes                      assume "yes" as answer to prompts when removing a client or removing WireGuard
  -h, --help                     show this help message and exit

Install options (optional):

  --auto                         auto install WireGuard using default or custom options
  --serveraddr [DNS name or IP]  server address, must be a fully qualified domain name (FQDN) or an IPv4 address
  --port [number]                port for WireGuard (1-65535, default: 51820)
  --clientname [client name]     name for the first WireGuard client (default: client)
  --dns1 [DNS server IP]         primary DNS server for first client (default: Google Public DNS)
  --dns2 [DNS server IP]         secondary DNS server for first client

To customize options, you may also run this script without arguments.

Community

Next steps

After setup, you can run the script again to manage users or uninstall WireGuard.

Get your computer or device to use the VPN. Please refer to:

Configure WireGuard VPN Clients

Read 📘 VPN book to access extra content.

Enjoy your very own VPN! :sparkles::tada::rocket::sparkles:

Credits

This script is based on the great work of Nyr and contributors, with enhancements and changes for compatibility with the Setup IPsec VPN project.

List of enhancements over Nyr/wireguard-install.
  • Improved compatibility with Setup IPsec VPN
  • Improved script reliability, user input and output
  • Supports auto install using default or custom options
  • Supports using a DNS name as server address
  • Added support for openSUSE Linux
  • Supports listing existing VPN clients
  • Supports showing QR code for a client
  • Supports custom DNS server(s) for VPN clients
  • Supports command-line options for managing VPN clients
  • Optimizes sysctl settings for improved VPN performance
  • Improved creation of client config files when using sudo

...and more!

License

MIT

wireguard-install (hwdsl2/wireguard-install)

Searching Database…

这是什么?这是一个 shell 脚本,可在 Linux 上自动安装并配置 WireGuard VPN 服务器,让你无需任何 WireGuard 经验,几分钟内就能搭好自己的 VPN。
这是独立安装器,还是我要导入的库?它是一个独立的 Bash 脚本,下载到服务器上运行即可;不是库,也不是应用软件包。
怎么让 VPN 服务器跑起来?把 wireguard-install.sh 下载到 Linux 服务器并运行:可以用默认选项自动安装,也可以交互式运行,自定义 DNS 名称、UDP 端口、客户端使用的 DNS 服务器和第一个客户端的名称。
我需要什么样的服务器来运行它?你需要一台云服务器、VPS 或独立服务器,运行受支持的 Linux 发行版(Ubuntu、Debian、AlmaLinux、Rocky Linux、CentOS、Fedora、openSUSE)或 Raspberry Pi OS。
防火墙或端口方面有什么要注意的坑吗?如果你的服务器位于外部防火墙之后(例如在 EC2 或 GCE 上),必须手动放行 WireGuard 使用的 UDP 端口(默认 51820,或你的自定义端口),VPN 才能工作。
哪些客户端设备可以连接?脚本会生成 VPN 配置文件和二维码,自动配置 Windows、macOS、iOS 和 Android 客户端设备。
搭建好之后怎么管理 VPN 用户?只需在服务器上再次运行脚本,即可添加/删除/列出客户端、显示某个客户端的二维码,或完全卸载 WireGuard。
它与原版 Nyr/wireguard-install 有什么不同?它是原项目的一个分支,增加了 openSUSE 支持、基于 DNS 名称的服务器地址、客户端自定义 DNS、管理客户端的命令行选项、sysctl 性能调优,以及对相关 Setup IPsec VPN 项目更好的兼容性。
它支持 IPv6 吗?支持,它为 VPN 客户端提供 IPv4 和 IPv6 双栈支持。
可以在没有任何交互提示的情况下自动安装吗?可以,高级用户可以通过命令行选项实现完全非交互安装,也可以用 Bash here-document 预先提供交互提示的答案。
Creator
hwdsl2
Size
0.7 MB
Stars
3.1K
Updated
CommitOct 17
Age
4y
Commits · 90 Days