Files
linux-script-helpers/wg-port-add
2025-11-13 17:45:47 +07:00

20 lines
373 B
Bash
Executable File

#!/bin/bash
n="$(basename $0)"
quit() {
printf "%s: %s\n" "$n" "$1"
exit 1
}
usage() {
printf "UFW Allow Port for WireGuard interface.\n"
printf "usage: %s <tcp,udp> <XX>\n" "$n"
exit 0
}
[[ -z $1 && -z $2 ]] && usage
[[ -z $1 ]] && quit "Required Protocol (tcp,udp)"
[[ -z $2 ]] && quit "Required Port Number"
sudo ufw allow in on wg0 proto "$1" to any port "$2"