Created
April 17, 2021 12:13
-
-
Save HackingGate/cf0e2011d328e58f7ec61c5400f50bf5 to your computer and use it in GitHub Desktop.
WireGuard server on Oracle Cloud Always Free Compute Instance
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
# WIP | |
# The script is compatible with Canonical Ubuntu (Always Free Eligible) Minimal | |
sudo apt update | |
sudo apt install wireguard | |
# ifconfig to check your interfae | |
# for Ubuntu 20.04 Minimal 2021.03.25-0 it's ens3 | |
# Generate keys (WIP) | |
sudo echo ' | |
[Interface] | |
PrivateKey = server.key | |
Address = 192.168.16.1/24 | |
ListenPort = 51820 | |
PostUp = sysctl -w net.ipv4.ip_forward=1; iptables -A FORWARD -i %i -j ACCEPT; iptables -t nat -A POSTROUTING -o ens3 -j MASQUERADE | |
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -t nat -D POSTROUTING -o ens3 -j MASQUERADE | |
[Peer] | |
PublicKey = client.pub | |
PresharedKey = shared.psk | |
AllowedIPs = 192.168.16.0/24 | |
PersistentKeepalive = 25 | |
' > /etc/wireguard/wg0.conf | |
# Firewall settings | |
# https://stackoverflow.com/a/54835902 | |
# WireGuard uses udp. | |
sudo firewall-cmd --zone=public --permanent --add-port=51820/udp | |
sudo firewall-cmd --reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oracle Cloud VNC setup on web
Create VNC
Go to Virtual Cloud Networks. Create a VCN. Enable IPv6 CIDR block (/56).
Create Subnet
Create a subnet inside that VCN. Assign IPv4 CIDR block (any) and IPv6 CIDR block (/64). Choose Default Security List for $(VCN name).
Allow WireGuard
Go to Default Security List for $(VCN name). Add two new Ingress Rules. One for IPv4, SOURCE CIDR is
0.0.0.0/0
. One for IPv6, SOURCE CIDR is::/0
. Both use IP ProtocolUDP
and port number51820
.Create Internet Gateway
Check the above image to make sure you don't have something missing.