Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix problem with enabled UFW with Random Ports #2603

Merged
merged 1 commit into from
May 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion openvpn/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,13 @@ function ufwAllowPort {
portNum=${1}
if [[ "${ENABLE_UFW,,}" == "true" ]] && [[ -n "${portNum-}" ]]; then
echo "allowing ${portNum} through the firewall"
ufw allow ${portNum}
if [[ $portNum == *":"* ]];
then
ufw allow ${portNum}/tcp
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is required to allow a range of ports eh?
Thanks for the fix

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, or if you don't like IF statement we can just use:

ufw allow ${portNum}/tcp
ufw allow ${portNum}/udp

instead of:

ufw allow ${portNum}

Correct command for range of ports is:

ufw allow ###:####/tcp
ufw allow ###:####/udp

where one port can be added using ufw allow ### but for one port command ufw allow ###/tcp is also working.

ufw allow ${portNum}/udp
else
ufw allow ${portNum}
fi
fi
}

Expand Down