Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mbprtpnix/86761c763ed704da4566808631e16191 to your computer and use it in GitHub Desktop.
Save mbprtpnix/86761c763ed704da4566808631e16191 to your computer and use it in GitHub Desktop.
WireGuard Complete Installation
sudo apt-get update && sudo apt-get -y upgrade && sudo apt-get autoremove -y
sudo apt install software-properties-common && sudo apt install linux-headers-$(uname -r)
sudo add-apt-repository ppa:wireguard/wireguard
sudo apt install wireguard wireguard-dkms wireguard-tools resolvconf -y
wg genkey | sudo tee /etc/wireguard/privatekey | wg pubkey | sudo tee /etc/wireguard/publickey
ifconfig
sudo nano /etc/wireguard/wg0.conf
## WireGuard VPN Server Config File
#Server:
[Interface]
Address = 10.26.26.1/24
ListenPort = 51820
PrivateKey = SERVER-PRIVATE-KEY
SaveConfig = true
## Firewall Rules
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o YOUR-INTERFACE-NAME -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o YOUR-INTERFACE-NAME -j MASQUERADE
#Client Profile
#Laptop:
[Peer]
Public Key = CLIENT-1-PUBLIC-KEY
AllowedIPs = 10.26.26.2/32
#Android:
[Peer]
Public Key = CLIENT-2-PUBLIC-KEY
AllowedIPs = 10.26.26.3/32
sudo wg-quick up wg0
sudo wg show wg0
sudo systemctl enable wg-quick@wg0
sysctl -w net.ipv4.ip_forward=1
sysctl -w net.ipv6.conf.all.forwarding=1
sudo sysctl -p
ufw alliow 22/tcp
sudo ufw allow 51820/udp
sudo nano /etc/wireguard/wg0.conf
## WireGuard VPN Client Config File
[Interface]
PrivateKey = CLIENT-PRIVATE-KEY
Address = 10.26.26.2/24
ListenPort = 51820
DNS = 1.1.1.1
MTU = 1412
## VPN Server Public Key
[Peer]
PublicKey = SERVER-PUBLIC-KEY
Endpoint = SERVER-IP:51820
AllowedIPs = 0.0.0.0/0, ::/0
PersistentKeepalive = 25
sudo wg set wg0 peer NEW-CLIENT-PUBLIC-KEY allowed-ips 10.26.26.15
sudo wg set wg0 peer NEW-CLIENT-PUBLIC-KEY allowed-ips 10.26.26.15 remove
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment