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

Added option to open the port on firewalld. #1200

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
27 changes: 27 additions & 0 deletions openvpn-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,27 @@ function installQuestions() {
PROTOCOL="tcp"
;;
esac
if command -v "firewall-cmd" &> /dev/null
then
SUGGESTION=y
echo "Command \"firewall-cmd\" has been detected."
until [[ $ADDPORT =~ (y|n) ]]; do
read -rp "Would you like to open port ${PORT} on firewalld? [y/n]: " -e -i $SUGGESTION ADDPORT
done
if [[ $ADDPORT == "y" ]]; then
firewall-cmd --add-port "${PORT}"/"${PROTOCOL}"
firewall-cmd --permanent --add-port "${PORT}"/"${PROTOCOL}"

Choose a reason for hiding this comment

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

Not always need to be --permanent

fi
fi

echo ""
echo "Option client-to-client allows clients to \"see\" eachother."
echo "Would you like to enable this option?"
SUGGESTION=y
until [[ $CLIENT_TO_CLIENT_OPTION =~ (y|n) ]]; do
read -rp "Enable client-to-client? [y/n]: " -e -i $SUGGESTION CLIENT_TO_CLIENT_OPTION
done

echo ""
echo "What DNS resolvers do you want to use with the VPN?"
echo " 1) Current system resolvers (from /etc/resolv.conf)"
Expand Down Expand Up @@ -624,6 +645,8 @@ function installOpenVPN() {
CLIENT=${CLIENT:-client}
PASS=${PASS:-1}
CONTINUE=${CONTINUE:-y}
CLIENT_TO_CLIENT_OPTION="y"
ADDPORT="y"

# Behind NAT, we'll default to the publicly reachable IPv4/IPv6.
if [[ $IPV6_SUPPORT == "y" ]]; then
Expand Down Expand Up @@ -775,6 +798,10 @@ function installOpenVPN() {
echo "proto ${PROTOCOL}6" >>/etc/openvpn/server.conf
fi

if [[ $CLIENT_TO_CLIENT_OPTION == "y" ]]; then
echo "client-to-client" >>/etc/openvpn/server.conf
fi

echo "dev tun
user nobody
group $NOGROUP
Expand Down