-
Notifications
You must be signed in to change notification settings - Fork 0
/
c8
35 lines (25 loc) · 1.16 KB
/
c8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
#/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/kent0/Scripts/master/c8)";
sudo dnf install -y epel-release elrepo-release
sudo dnf install -y kmod-wireguard wireguard-tools
sudo yum install -y git vim tmux gcc mpich
sudo yum update -y
sudo mkdir /etc/wireguard
wg genkey | sudo tee /etc/wireguard/privatekey | wg pubkey | sudo tee /etc/wireguard/publickey
#file=/etc/wireguard/wg0.conf
file=$(mktemp)
echo '[Interface]' > file
echo 'Address = 10.0.0.1/24' >> file
echo 'SaveConfig = true' >> file
echo 'ListenPort = 51820' >> file
echo 'PrivateKey = ' "$(sudo cat /etc/wireguard/privatekey)" >> file
echo 'PostUp = firewall-cmd --zone=public --add-port 51820/udp && firewall-cmd --zone=public --add-masquerade' >> file
echo 'PostDown = firewall-cmd --zone=public --remove-port 51820/udp && firewall-cmd --zone=public --remove-masquerade' >> file
sudo mv $file /etc/wireguard/wg0.conf
sudo chown root.root /etc/wireguard/wg0.conf
sudo chmod 600 /etc/wireguard/{privatekey,wg0.conf}
sudo wg-quick up wg0
file=$(mktemp)
echo 'net.ipv4.ip_forward=1' > $file
sudo mv $file /etc/sysctl.d/99-custom.conf
sudo chown root.root /etc/sysctl.d/99-custom.conf