Wireguard Setup on Azure
Installation on server
$ sudo apt-get install wireguard-dkms wireguard-tools$ sudo nano /etc/sysctl.confuncomment the line
net.ipv4.ip_forward=1Generation of keys for server and client
$ sudo -i
$ cd /etc/wireguard
$ wg genkey | tee server_private_key | wg pubkey > server_public.keyConfiguration file for server
create /etc/wireguard/wg0.conf as following
for this example, the IP address of server used is 100.0.0.1
make sure the ip address is not having same subnet as the internet source of the server for example eth0.
DO NOT use IP 100.0.0.1 if you realize it is having same subnet as eth0 as shown below
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 100.0.0.4 netmask 255.255.255.0 broadcast 100.0.0.255the ListenPort depends on the your UDP port allowed at firewall.
example of firewall at Azure

create /etc/wireguard/iptable/rules.sh.
Configuration for DNS
Install unbound to provide DNS
check number of threads by running
You will need to fill in num-threads in the next configuration
Restart and enable unbound service
You may need to disable the default DNS resolver if unbound fails to start with an error message saying port 53 has been binded to another process
Wireguard service on server
You can test your DNS setup with the following commands and you should expect to see similar results returned
Setting up clients
Server
Set wg0 down then up again in order to take effect
Client
Install dependencies
Assuming the client vpn IP is 100.0.0.2
Create configuration file as below
Bring up the connection
Last updated