This repository has been archived on 2024-03-22. You can view files and clone it, but cannot push or open issues or pull requests.
NA-NYC-01-WIREGUARD-TUNNEL-.../flush-and-restart.sh
2024-03-08 15:14:38 -05:00

40 lines
993 B
Bash

#!/bin/bash
# Function to ask for confirmation
confirm() {
read -p "Do you want to flush iptables and restart ALL wireguard tunnels? (y/n): " choice
case "$choice" in
y|Y ) return 0;;
n|N ) echo "Script aborted."; exit 1;;
* ) echo "Invalid input. Please enter 'y' or 'n'."; confirm;;
esac
}
# Confirmation prompt
confirm
# Flush iptables rules
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
# Set default policies to ACCEPT
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# Execute other commands if confirmed
iptables -L -v -n
ip6tables -L -n -v
iptables -t nat -L -n -v
ip6tables -t nat -L -n -v
sudo journalctl -u INBOUND_TRAFFIC --vacuum-size=100G
sudo journalctl -u OUTBOUND_TRAFFIC --vacuum-size=100G
systemctl restart wg-quick@wg0.service
systemctl restart wg-quick@wg1.service
systemctl restart wg-quick@wg2.service
echo "Script executed successfully."