Howto wireguard

From Vidalinux Wiki
Revision as of 03:34, 2 August 2020 by Mandulete1 (talk | contribs) (Created page with "= server configuration = install repos: yum install -y epel-release https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm yum install -y yum-plugin-elrepo yum insta...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

server configuration

install repos:

yum install -y epel-release https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
yum install -y yum-plugin-elrepo
yum install -y kmod-wireguard wireguard-tools

create wireguard config directory on etc:

mkdir /etc/wireguard

create a public/private key pair:

wg genkey | tee /etc/wireguard/server_private.key | wg pubkey | tee /etc/wireguard/server_public.key

create a wireguard configuration file /etc/wireguard/wg0.conf:

[Interface]
Address = 10.10.10.1/24
SaveConfig = true
PrivateKey = kLmHUf4LNmxtz1uA3riC7MMXzwBFjJrSWE/Lb4p+4Ec=
ListenPort = 51820

[Peer]
PublicKey = 75VNV7HqFh+3QIT5OHZkcjWfbjx8tc6Ck62gZJT/KRA=
AllowedIPs = 10.10.10.2/32

fix wireguard config directory permissions:

chmod 600 /etc/wireguard/ -R

enable ip forwarding:

nano /etc/sysctl.d/99-sysctl.conf

add the following line at the end of this file:

net.ipv4.ip_forward = 1

apply changes:

sysctl -p /etc/sysctl.d/99-sysctl.conf

start and enable wireguard service:

systemctl start wg-quick@wg0.service
systemctl enable wg-quick@wg0.service

an alternative way to start or stop wireguard:

wg-quick up wg0
wg-quick down wg0

client configuration

install repos:

yum install epel-release https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
yum install yum-plugin-elrepo
yum install kmod-wireguard wireguard-tools -y

create wireguard config directory on etc:

mkdir /etc/wireguard

create a public/private key pair:

wg genkey | tee /etc/wireguard/client_private.key | wg pubkey | tee /etc/wireguard/client_public.key

create a wireguard configuration file /etc/wireguard/wg0.conf:

[Interface]
Address = 10.10.10.2/24
DNS = 10.10.10.1
PrivateKey = cOFA+x5UvHF+a3xJ6enLatG+DoE3I5PhMgKrMKkUyXI=

[Peer]
PublicKey = vxyo4l4I3jWK+KZquNIDJF/hzQq29DOIxSUOrfNZZCs=
AllowedIPs = 0.0.0.0/0
Endpoint = 12.34.56.78:51820
PersistentKeepalive = 25

fix wireguard config directory permissions:

chmod 600 /etc/wireguard/ -R

start and enable wireguard service:

systemctl start wg-quick@wg0.service
systemctl enable wg-quick@wg0.service

show information about the vpn connection:

wg show

references