Skip to content

Create Firewall Rules Script for Service Security

Description

Create a bash script to configure iptables firewall rules limiting egress traffic to internal networks only and allowing ingress traffic only for SSH (22), HTTP (80), and HTTPS (443).

Implementation Tasks

Script Features

  • Input validation
  • Error handling
  • Logging
  • Backup functionality
  • Rule verification
  • Restoration capability

Network Rules

  • Define internal networks
  • Configure ingress ports
  • Set egress restrictions
  • Allow DNS resolution
  • Configure logging

Safety Measures

  • Backup existing rules
  • Verification steps
  • Rollback capability
  • SSH safety check