Linux: firewall-cmd command options

firewall-cmd is a command-line utility for managing firewalld, the dynamic firewall manager available on many Linux distributions. It allows you to configure various aspects of your firewall settings. To display the available options for firewall-cmd, you can use the --help option or explore specific subcommands and their options. Here are the general options:

  1. To display the general help and a list of available options for firewall-cmd:firewall-cmd --help
  2. To display the version of firewall-cmd:cssCopy codefirewall-cmd --version
  3. To display help for a specific subcommand, you can use:firewall-cmd --<subcommand> --help Replace <subcommand> with the specific operation you want to learn more about, such as --add-service, --add-port, --list-services, --list-ports, etc.

Here are some common firewall-cmd subcommands and their options:

  • --add-service: Add a service to the firewall configuration.
    • --permanent: Make the change permanent (will survive reboots).

Example:

firewall-cmd --add-service=http firewall-cmd --add-service=http --permanent

  • --add-port: Add a port to the firewall configuration.
    • --permanent: Make the change permanent (will survive reboots).

Example:

firewall-cmd --add-port=80/tcp firewall-cmd --add-port=80/tcp --permanent

  • --remove-service: Remove a service from the firewall configuration.
    • --permanent: Make the change permanent (will survive reboots).

Example:

firewall-cmd --remove-service=http firewall-cmd --remove-service=http --permanent

  • --remove-port: Remove a port from the firewall configuration.
    • --permanent: Make the change permanent (will survive reboots).

Example:

firewall-cmd --remove-port=80/tcp firewall-cmd --remove-port=80/tcp --permanent

  • --list-all: Show all configured rules, including services, ports, and other settings.
    • --permanent: List only the permanent rules.

Example:

firewall-cmd --list-all firewall-cmd --list-all --permanent

  • --reload: Reload the firewall configuration. Useful when you make changes to the configuration.

Example:

firewall-cmd --reload

These are just a few of the many options and subcommands available with firewall-cmd. For detailed information on specific options, you can refer to the firewall-cmd manual page or use the --help option for specific subcommands, as shown earlier.