Skip to main content

UFW (Uncomplicated Firewall) Command Reference

Basic UFW Operations

  • Enable the Firewall
  • Disable the Firewall
  • Check Firewall Status

Allowing Traffic

  • Allow Incoming Traffic on a Specific Port (e.g., SSH)
  • Allow Incoming Traffic on a Specific Port and Protocol (e.g., UDP)
  • Allow Incoming Traffic from a Specific IP Address
  • Allow Incoming Traffic from a Specific IP Address and Port
  • Allow Incoming Traffic from a Specific IP Range
  • Allow Outgoing Traffic on a Specific Port (e.g., HTTP)
  • Allow a Specific Application/Service (e.g., Apache Full)

Denying Traffic

  • Deny Incoming Traffic on a Specific Port (e.g., FTP)
  • Deny Incoming Traffic from a Specific IP Address
  • Limit the Rate of Incoming Connections (e.g., SSH)

Managing Rules

  • Delete a Specific Rule by Its Rule Number
  • Reset UFW to Default Settings
  • Show Advanced UFW Options
  • Show the List of Applications/Services That Can Be Enabled
  • Enable a Specific Application/Service (e.g., OpenSSH)
  • Disable a Specific Application/Service (e.g., OpenSSH)
  • Enable Logging of UFW Actions
  • Disable Logging of UFW Actions
  • Reset UFW to Factory Defaults (Disable and Delete All Rules)

Example Commands for Apache and Nginx

  • Allow Apache Traffic
  • Allow Nginx Traffic
  • Allow Specific Port (e.g., SSH)
  • Deny Specific Port (e.g., HTTP)

iptables Command Reference

Basic iptables Operations

  • List All Rules
  • Flush (Reset) All Rules

Managing Rules

  • Allow Incoming SSH Connections (Port 22)
  • Allow Incoming Connections from a Specific IP Address
  • Deny Incoming Connections from a Specific IP Address
  • Delete a Specific Rule by Its Line Number

This docs provides a quick reference for managing firewall rules with UFW and iptables. Make sure to adjust the port numbers, IP addresses, and service names according to your specific requirements.