Created
June 18, 2022 13:46
-
-
Save paulc/bd90bbe61fe15de610f5777d1845d512 to your computer and use it in GitHub Desktop.
Configure WG endpoint (Oracle Linux)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Configure WG endpoint (Oracle Linux) | |
WG_PRIVATE_KEY= | |
WG_ADDRESS= | |
WG_PEER= | |
WG_PSK= | |
WG_ALLOWED_IP= | |
WG_ENDPOINT= | |
WG_KEEPALIVE= | |
( | |
umask 077 | |
# Update | |
yum update -y | |
yum upgrade -y | |
# Enable wireguard | |
yum install -y wireguard-tools | |
# Configure WG | |
cd /etc/wireguard | |
cat >wg0.conf <<EOM | |
[Interface] | |
PrivateKey = ${WG_PRIVATE_KEY} | |
Address = ${WG_ADDRESS} | |
[Peer] | |
PublicKey = ${WG_PEER} | |
PresharedKey = ${WG_PSK} | |
AllowedIPs = ${WG_ALLOWED_IP} | |
Endpoint = ${WG_ENDPOINT} | |
PersistentKeepalive = ${WG_KEEPALIVE} | |
EOM | |
awk '/PrivateKey/ { printf "WG_PUBLIC_KEY :: "; print $3 |"wg pubkey"; exit }' wg0.conf | |
# IP Forwarding | |
cat >/etc/sysctl.d/10-forward.conf <<EOM | |
net.ipv4.ip_forward=1 | |
net.ipv6.conf.all.forwarding=1 | |
EOM | |
# Firewalld | |
firewall-cmd --zone=public --add-masquerade --permanent | |
# Systemd | |
systemctl enable [email protected] | |
systemctl start [email protected] | |
systemctl status [email protected] | |
) >/config.out 2> /config.err | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment