Setting up a WireGuard client on a self-hosted mail server with a dedicated public IP address

#!/bin/bash

# ssh to mail server

# ssh root@local_lan_ip

# If you need to ssh into the VPS server running WireGuard (assuming you have set this up yourself)

# ssh root@VPS-cloud-ip

# Settung up WireGuard on the mail server
# First ssh into the mail server and run

apt update
apt install -y apt-utils openresolv wireguard wireguard-tools iproute2 curl iputils-ping dialog

# Copy your WireGuard client configuration to the mail server
#
# If you setup a VPS server with multiple dedicated static IP addresses yourself using the directions from
# https://www.thinkpenguin.com/gnu-linux/expose-house-servers-vps-multiple...
# then the wireguard client configuration files can be found at: /tmp/wg-client0.conf, /tmp/wg-client1.conf, etc

nano /etc/wireguard/wg-client0.conf

# Make it so only root can read the WireGuard configuration

chmod 600 /etc/wireguard/ -R

# Start WireGuard client

systemctl start wg-quick@wg-client0.service

# Enable WireGuard client to start on every boot

systemctl enable wg-quick@wg-client0.service

# The below command should show you your dedicated public IP of the WireGuard / VPS server

curl ifconfig.me

# You can test that the mail server is publicly accessible via the WireGuard VPS server's static dedicated public IP address by installing apache2

apt install -y apache2

# Open a browser and visit the public IP address you were assigned by the WireGuard VPS server and see if you get the Trisquel apache2 page

# http://public_ip_of_VPS_wireguard_server_static_address_you_were_assigned