Skip to content

Instantly share code, notes, and snippets.

@Hermitter
Last active October 5, 2020 14:51
Show Gist options
  • Save Hermitter/70fdda5af227519f335834d28b9b1847 to your computer and use it in GitHub Desktop.
Save Hermitter/70fdda5af227519f335834d28b9b1847 to your computer and use it in GitHub Desktop.
Creating a Firewalld Service
SERVICE_NAME=minecraft2
ZONE_NAME=FedoraServer
# create service
sudo firewall-cmd --permanent --new-service=$SERVICE_NAME
sudo firewall-cmd --permanent --service=$SERVICE_NAME --add-port=9026/udp
sudo firewall-cmd --permanent --service=$SERVICE_NAME --add-port=9026/tcp
sudo firewall-cmd --reload
# view all existing services
sudo firewall-cmd --get-services | grep $SERVICE_NAME
# add service to zone
sudo firewall-cmd --permanent --zone=$ZONE_NAME --add-service=$SERVICE_NAME
sudo firewall-cmd --reload
# view zone services
sudo firewall-cmd --list-all --zone=$ZONE_NAME
# remove&delete service
sudo firewall-cmd --permanent --remove-service=$SERVICE_NAME
sudo rm /etc/firewalld/services/$SERVICE_NAME.xml
sudo rm /etc/firewalld/services/$SERVICE_NAME.xml.old
sudo firewall-cmd --reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment