Update : all variable, create function service

This commit is contained in:
2025-04-24 08:09:49 +02:00
parent 5991764110
commit 9db64d936e
15 changed files with 104 additions and 137 deletions

View File

@@ -29,30 +29,41 @@ configure_ufw() {
ufw --force reset
# Set default policies
log_message "INFO" "Setting default UFW policies"
log_message "INFO" "IPv4 : Setting default UFW policies"
ufw default deny incoming
ufw default allow outgoing
# Allow SSH on custom port
log_message "INFO" "Allowing SSH on port 2222"
ufw allow 2222/tcp
log_message "INFO" "IPv4 : Allowing SSH on port 22"
ufw allow 22/tcp
# Allow HTTP/HTTPS for web services if needed
log_message "INFO" "Allowing HTTP/HTTPS ports"
log_message "INFO" "IPv4 : Allowing HTTP/HTTPS ports"
ufw allow 80/tcp
ufw allow 443/tcp
# Allow SNMP for monitoring
log_message "INFO" "Allowing SNMP port for monitoring"
log_message "INFO" "IPv4 : Allowing SNMP port for monitoring"
ufw allow 161/udp
# Allow NRPE for monitoring
log_message "INFO" "Allowing NRPE port for monitoring"
log_message "INFO" "IPv4 : Allowing NRPE port for monitoring"
ufw allow 5666/tcp
# Allow IPv6 if needed
log_message "INFO" "IPv6 : Setting default UFW policies"
ufw allow in on lo
ufw allow out on lo
ufw deny in from ::/0
ufw allow out to ::/0
# Enable log
log_message "INFO" "Enabling logging for UFW"
ufw logging on
# Enable UFW
log_message "INFO" "Enabling UFW"
echo "y" | ufw enable
echo "y" | ufw -force enable
if [ $? -eq 0 ]; then
log_message "SUCCESS" "UFW enabled successfully"