Gerenciamento com firewalld no CentOS 7
Publicado por Amaury Borges Souza (última atualização em 27/05/2020)
[ Hits: 3.236 ]
Homepage: https://amaurybsouza.medium.com/
Gerenciamento com firewalld no CentOS 7 para facilitar o uso do serviço no dia a dia. Você pode listar as regras, adicionar novas regras, verificar se o firewalld está instalado, ver o status do serviço.
#!/usr/bin/env bash # ------------------------------------------------------------------------ # # Script Name: firewalld.sh # Description: Firewalld service management # Site: https://medium.com/@amaurybsouza # Written by: Amaury Souza # Maintenance: Amaury Souza # ------------------------------------------------------------------------ # # Usage: # $ ./firewalld.sh # ------------------------------------------------------------------------ # # Tested on: # Bash 4.2.46 # ------------------------------------------------------------------------ # # History: v1.0 25/05/2020, Amaury: # - Start de program # - Add case feature # v1.1 25/05/2020, Amaury: # - Adding new variables # v1.2 25/05/2020, Amaury: # - Executing new tests in my system # ------------------------------------------------------------------------ # # Thankfulness: # # ------------------------------------------------------------------------ # #VARIABLES --------------------------------------------------------------- # STATUS=`systemctl status firewalld | grep -i "running" | cut -d " " -f 4,5,6` START=`systemctl start firewalld` SHOW=`firewall-cmd --list-all | grep -i "services"` RELOAD=`firewall-cmd --reload` #CODE -------------------------------------------------------------------- # clear while true;do echo " " echo "Welcome at $0" echo " " echo "Choose a option below to start! 1- ensure firewalld service is installed 2- show firewalld status 3- start firewalld service 4- show available rules 5- add new rules 6- reload firewalld service 0- Exit script" echo " " echo -n "selected option: " read option case $option in 1) if [ -x `command -v firewalld` ] then echo " " echo "Installed and latest version" sleep 2 echo " " else echo "Not installed yet" sleep 2 echo " " fi ;; 2) echo " " echo "Firewalld status: $STATUS" ;; 3) echo "Starting service..." sleep 2 echo "$START" ;; 4) echo -n "Rules available... $SHOW" echo " " ;; 5) echo -n "Type a rule: " read rule if [ -z $rule ] then echo "You don't type nothing" else echo -n "Your rule: $rule" echo " " firewall-cmd --add-service=$rule --permanent fi echo ;; 6) echo "Reloading..." sleep 2 echo "$RELOAD" ;; *) echo "invalid option, please, try again!" ;; esac done #END ------------------------------------------------------------------ #
Script em shell do artigo: Implementando a segurança em servicos de acesso remoto
Detecta e bloqueia tentativa de acesso ao SSH
POSTFIX AUTOMÁTICO COM MYSQL E IPTABLES - CALCULA O % DE USO DA QUOTA E ATUALIZA BANCO
Script FIREWALL IPTABLES com 3 (três) interfaces (Int, Ext e DMZ)
Aprenda a Gerenciar Permissões de Arquivos no Linux
Como transformar um áudio em vídeo com efeito de forma de onda (wave form)
Como aprovar Pull Requests em seu repositório Github via linha de comando
Visualizar arquivos em formato markdown (ex.: README.md) pelo terminal
Dando - teoricamente - um gás no Gnome-Shell do Arch Linux
Como instalar o Google Cloud CLI no Ubuntu/Debian
Mantenha seu Sistema Leve e Rápido com a Limpeza do APT!
Procurando vídeos de YouTube pelo terminal e assistindo via mpv (2025)
Alguém já usou o framework Avalonia para desenvolver interfaces de usu... (4)
Ajuda Pra Melhoria do NFTABLES. (8)
Sinto uma leve lentidão ao arrastar, miniminizar e restauras as janela... (2)
Pastas da raiz foram para a área de trabalho [RESOLVIDO] (7)