amirajoodani / Wireguard

Installation Wireguard

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wireguard Installation

1-Install
apt -y wireguard-tools
2-Generate Private key
wg genkey | tee /etc/wireguard/server.key (copy in notepad as server key)
3-Generate public key From private key
cat /etc/wireguard/server.key | wg pubkey | tee /etc/wireguard/server.pub (copy in notepad as public key)
4-Generate Private key for client
wg genkey | tee /etc/wireguard/client.key (copy in notepad as server key)
5-Generate public key From private key For client
cat /etc/wireguard/client.key | wg pubkey | tee /etc/wireguard/client.pub (copy in notepad as public key)
6- Create preshared Key (it same as server and client )(copy to notepad)
wg genpsk | tee /etc/wireguard/preshares-client1
7- Create config file for wireguard Interface
vi etc/wireguard/wg0.conf
[Interface]
PrivateKey=
Address=10.8.0.2/24
ListenPort=51280
PostUp=iptables -A FORWARD -i wg0 -j ACCEPT;iptables -t nat _A POSTROUTING -o eth0 -j MASQURADE
PostDown=iptables -D FORWARD -i wg0 -j ACCEPT;iptables -t nat -D POSTROUTING -o eth0 -j MASQURADE
[peer]
PublicKey=
PresharedKey=
AllowedIPs=range of ip
8- up tunnel
wg-quick up wg0
wg-show (show status of tunnel )
9- config client
[Interface]
PrivateKey=
Address=10.8.0.2/24 (IP address of vpn interface)
DNS=1.1.1.1
[peer]
PublicKey= (public key for server generated on wireguard server )
PresharedKey=
AllowedIPs=172.16.100.1 , 10.0.0.0/24
Endpoint=172.29.10.100:51280 (ip address of vpn server )
save clint config as wg2.conf and then download wireguard client for windows or android and load client config file (wg2.conf)
(be sure that have receive traffic on clent if you dont have traffic check log for more information)
Linux Client
apt -y install wireguard-tools
vi /etc/wireguard/wg0.conf
[Interface]
PrivateKey=
Address=10.8.0.2/24 (IP address of vpn interface)
DNS=1.1.1.1
[peer]
PublicKey= (public key for server generated on wireguard server )
PresharedKey=
AllowedIPs=172.16.100.1 , 10.0.0.0/24
Endpoint=172.29.10.100:51280 (ip address of vpn server )
wg-quick up wg0
enavle tunnel :
systemctl enable --now wg-quick@wg0

Install Wireguard With Docker-compose

git clone https://github.com/farshadnick/wg-easy.git
change docker-compose parameters as below :
WG_HOST=IP Address Of VPS
secend port is used for web panel
clear optional word and do below their paramaters in the WG_HOST block
PASSWORD=Wireguard password WEB PANEL
clear allowd ip part

About

Installation Wireguard