finished wireguard script

This commit is contained in:
Matthew Tran 2023-09-05 17:01:48 +00:00
parent 244180d014
commit 1685a02f90

View File

@ -59,8 +59,6 @@ def serverconf(cfg):
f'Address = {cfg["ipv6"] + ipv6_prefix}\n' f'Address = {cfg["ipv6"] + ipv6_prefix}\n'
f'ListenPort = 51820\n' f'ListenPort = 51820\n'
f'PrivateKey = {cfg["key"]}\n' f'PrivateKey = {cfg["key"]}\n'
# TODO probably need to change
f'PostUp = sysctl -w net.ipv4.ip_forward=1\n' f'PostUp = sysctl -w net.ipv4.ip_forward=1\n'
f'PostUp = sysctl -w net.ipv6.conf.all.forwarding=1\n' f'PostUp = sysctl -w net.ipv6.conf.all.forwarding=1\n'
f'PostUp = iptables -A FORWARD -i wg0 -j ACCEPT\n' f'PostUp = iptables -A FORWARD -i wg0 -j ACCEPT\n'
@ -113,7 +111,7 @@ if __name__ == '__main__':
}) })
with open(c + '.conf', 'w') as file: with open(c + '.conf', 'w') as file:
file.write(clientconf(cfg, key)) file.write(clientconf(cfg, key)) # qrencode -t ansiutf8 < <conf>
# generate files # generate files
with wg_json.open('w') as file: with wg_json.open('w') as file:
@ -123,5 +121,5 @@ if __name__ == '__main__':
with wg_conf.open('w') as file: with wg_conf.open('w') as file:
file.write(serverconf(cfg)) file.write(serverconf(cfg))
print('encode as QR with "qrencode -t ansiutf8 < <conf>"') # reload new configs
print('run "sudo systemctl restart wg-quick@wg0.service" to load new settings') subprocess.check_output(['systemctl', 'reload', 'wg-quick@wg0.service'])