Which type of firewall filters ip traffic between a pair of bridged interfaces?

Expand section "17. Setting up an 802.1x network authentication service for LAN clients using hostapd with FreeRADIUS backend" Collapse section "17. Setting up an 802.1x network authentication service for LAN clients using hostapd with FreeRADIUS backend"
  1. 17.1. Prerequisites
  2. 17.2. Setting up the bridge on the authenticator
  3. 17.3. Certificate requirements by FreeRADIUS
  4. 17.4. Creating a set of certificates on a FreeRADIUS server for testing purposes
  5. 17.5. Configuring FreeRADIUS to authenticate network clients securely using EAP
  6. 17.6. Configuring hostapd as an authenticator in a wired network
  7. 17.7. Testing EAP-TTLS authentication against a FreeRADIUS server or authenticator
  8. 17.8. Testing EAP-TLS authentication against a FreeRADIUS server or authenticator
  9. 17.9. Blocking and allowing traffic based on hostapd authentication events
  • 18. Authenticating a RHEL client to the network using the 802.1X standard with a certificate stored on the file systemExpand section "18. Authenticating a RHEL client to the network using the 802.1X standard with a certificate stored on the file system" Collapse section "18. Authenticating a RHEL client to the network using the 802.1X standard with a certificate stored on the file system"
    1. 18.1. Configuring 802.1X network authentication on an existing Ethernet connection using nmcli
    2. 18.2. Configuring a static Ethernet connection with 802.1X network authentication using nmstatectl
    3. 18.3. Configuring a static Ethernet connection with 802.1X network authentication using RHEL System Roles
  • 19. Managing the default gateway settingExpand section "19. Managing the default gateway setting" Collapse section "19. Managing the default gateway setting"
    1. 19.1. Setting the default gateway on an existing connection using nmcli
    2. 19.2. Setting the default gateway on an existing connection using the nmcli interactive mode
    3. 19.3. Setting the default gateway on an existing connection using nm-connection-editor
    4. 19.4. Setting the default gateway on an existing connection using control-center
    5. 19.5. Setting the default gateway on an existing connection using nmstatectl
    6. 19.6. Setting the default gateway on an existing connection using RHEL System Roles
    7. 19.7. Setting the default gateway on an existing connection when using the legacy network scripts
    8. 19.8. How NetworkManager manages multiple default gateways
    9. 19.9. Configuring NetworkManager to avoid using a specific profile to provide a default gateway
    10. 19.10. Fixing unexpected routing behavior due to multiple default gateways
  • 20. Configuring static routesExpand section "20. Configuring static routes" Collapse section "20. Configuring static routes"
    1. 20.1. Example of a network that requires static routes
    2. 20.2. How to use the nmcli command to configure a static route
    3. 20.3. Configuring a static route using an nmcli command
    4. 20.4. Configuring a static route using nmtui
    5. 20.5. Configuring a static route using control-center
    6. 20.6. Configuring a static route using nm-connection-editor
    7. 20.7. Configuring a static route using the nmcli interactive mode
    8. 20.8. Configuring a static route using nmstatectl
    9. 20.9. Configuring a static route using RHEL System Roles
    10. 20.10. Creating static routes configuration files in key-value format when using the legacy network scripts
    11. 20.11. Creating static routes configuration files in ip-command format when using the legacy network scripts
  • 21. Configuring policy-based routing to define alternative routesExpand section "21. Configuring policy-based routing to define alternative routes" Collapse section "21. Configuring policy-based routing to define alternative routes"
    1. 21.1. Routing traffic from a specific subnet to a different default gateway using NetworkManager
    2. 21.2. Routing traffic from a specific subnet to a different default gateway using RHEL System Roles
    3. 21.3. Overview of configuration files involved in policy-based routing when using the legacy network scripts
    4. 21.4. Routing traffic from a specific subnet to a different default gateway using the legacy network scripts
  • 22. Creating a dummy interfaceExpand section "22. Creating a dummy interface" Collapse section "22. Creating a dummy interface"
    1. 22.1. Creating a dummy interface with both an IPv4 and IPv6 address using nmcli
  • 23. Using nmstate-autoconf to automatically configure the network state using LLDPExpand section "23. Using nmstate-autoconf to automatically configure the network state using LLDP" Collapse section "23. Using nmstate-autoconf to automatically configure the network state using LLDP"
    1. 23.1. Using nmstate-autoconf to automatically configure network interfaces
  • 24. Using LLDP to debug network configuration problemsExpand section "24. Using LLDP to debug network configuration problems" Collapse section "24. Using LLDP to debug network configuration problems"
    1. 24.1. Debugging an incorrect VLAN configuration using LLDP information
  • 25. Manually creating NetworkManager profiles in keyfile formatExpand section "25. Manually creating NetworkManager profiles in keyfile format" Collapse section "25. Manually creating NetworkManager profiles in keyfile format"
    1. 25.1. The keyfile format of NetworkManager profiles
    2. 25.2. Creating a NetworkManager profile in keyfile format
    3. 25.3. Migrating NetworkManager profiles from ifcfg to keyfile format
    4. 25.4. Using nmcli to create keyfile connection profiles in offline mode
  • 26. Using netconsole to log kernel messages over a networkExpand section "26. Using netconsole to log kernel messages over a network" Collapse section "26. Using netconsole to log kernel messages over a network"
    1. 26.1. Configuring the netconsole service to log kernel messages to a remote host
  • 27. Systemd network targets and servicesExpand section "27. Systemd network targets and services" Collapse section "27. Systemd network targets and services"
    1. 27.1. Differences between the network and network-online systemd target
    2. 27.2. Overview of NetworkManager-wait-online
    3. 27.3. Configuring a systemd service to start after the network has been started
  • 28. Linux traffic controlExpand section "28. Linux traffic control" Collapse section "28. Linux traffic control"
    1. 28.1. Overview of queuing disciplines
    2. 28.2. Available qdiscs in RHEL
    3. 28.3. Inspecting qdiscs of a network interface using the tc utility
    4. 28.4. Updating the default qdisc
    5. 28.5. Temporarily setting the current qdisk of a network interface using the tc utility
    6. 28.6. Permanently setting the current qdisk of a network interface using NetworkManager
  • 29. Getting started with Multipath TCPExpand section "29. Getting started with Multipath TCP" Collapse section "29. Getting started with Multipath TCP"
    1. 29.1. Understanding MPTCP
    2. 29.2. Preparing RHEL to enable MPTCP support
    3. 29.3. Using iproute2 to temporarily configure and enable multiple paths for MPTCP applications
    4. 29.4. Permanently configuring multiple paths for MPTCP applications
    5. 29.5. Monitoring MPTCP sub-flows
    6. 29.6. Disabling Multipath TCP in the kernel
  • 30. Configuring the order of DNS serversExpand section "30. Configuring the order of DNS servers" Collapse section "30. Configuring the order of DNS servers"
    1. 30.1. How NetworkManager orders DNS servers in /etc/resolv.conf
    2. 30.2. Setting a NetworkManager-wide default DNS server priority value
    3. 30.3. Setting the DNS priority of a NetworkManager connection
  • 31. Configuring ip networking with ifcfg filesExpand section "31. Configuring ip networking with ifcfg files" Collapse section "31. Configuring ip networking with ifcfg files"
    1. 31.1. Configuring an interface with static network settings using ifcfg files
    2. 31.2. Configuring an interface with dynamic network settings using ifcfg files
    3. 31.3. Managing system-wide and private connection profiles with ifcfg files
  • 32. Using NetworkManager to disable IPv6 for a specific connectionExpand section "32. Using NetworkManager to disable IPv6 for a specific connection" Collapse section "32. Using NetworkManager to disable IPv6 for a specific connection"
    1. 32.1. Disabling IPv6 on a connection using nmcli
  • 33. Manually configuring the /etc/resolv.conf fileExpand section "33. Manually configuring the /etc/resolv.conf file" Collapse section "33. Manually configuring the /etc/resolv.conf file"
    1. 33.1. Disabling DNS processing in the NetworkManager configuration
    2. 33.2. Replacing /etc/resolv.conf with a symbolic link to manually configure DNS settings
  • 34. Monitoring and tuning NIC ring buffersExpand section "34. Monitoring and tuning NIC ring buffers" Collapse section "34. Monitoring and tuning NIC ring buffers"
    1. 34.1. Displaying the number of dropped packets
    2. 34.2. Increasing the ring buffers to reduce a high packet drop rate
  • 35. Configuring 802.3 link settingsExpand section "35. Configuring 802.3 link settings" Collapse section "35. Configuring 802.3 link settings"
    1. 35.1. Understanding Auto-negotiation
    2. 35.2. Configuring 802.3 link settings using the nmcli utility
  • 36. Configuring ethtool offload featuresExpand section "36. Configuring ethtool offload features" Collapse section "36. Configuring ethtool offload features"
    1. 36.1. Offload features supported by NetworkManager
    2. 36.2. Configuring an ethtool offload feature using NetworkManager
    3. 36.3. Using RHEL System Roles to set ethtool features
  • 37. Configuring ethtool coalesce settingsExpand section "37. Configuring ethtool coalesce settings" Collapse section "37. Configuring ethtool coalesce settings"
    1. 37.1. Coalesce settings supported by NetworkManager
    2. 37.2. Configuring ethtool coalesce settings using NetworkManager
    3. 37.3. Using RHEL System Roles to configure ethtool coalesce settings
  • 38. Using MACsec to encrypt layer-2 traffic in the same physical networkExpand section "38. Using MACsec to encrypt layer-2 traffic in the same physical network" Collapse section "38. Using MACsec to encrypt layer-2 traffic in the same physical network"
    1. 38.1. Configuring a MACsec connection using nmcli
    2. 38.2. Additional resources
  • 39. Using different DNS servers for different domainsExpand section "39. Using different DNS servers for different domains" Collapse section "39. Using different DNS servers for different domains"
    1. 39.1. Sending DNS requests for a specific domain to a selected DNS server
  • 40. Getting started with IPVLANExpand section "40. Getting started with IPVLAN" Collapse section "40. Getting started with IPVLAN"
    1. 40.1. IPVLAN modes
    2. 40.2. Comparison of IPVLAN and MACVLAN
    3. 40.3. Creating and configuring the IPVLAN device using iproute2
  • 41. Reusing the same IP address on different interfacesExpand section "41. Reusing the same IP address on different interfaces" Collapse section "41. Reusing the same IP address on different interfaces"
    1. 41.1. Permanently reusing the same IP address on different interfaces
    2. 41.2. Temporarily reusing the same IP address on different interfaces
    3. 41.3. Additional resources
  • 42. Starting a service within an isolated VRF networkExpand section "42. Starting a service within an isolated VRF network" Collapse section "42. Starting a service within an isolated VRF network"
    1. 42.1. Configuring a VRF device
    2. 42.2. Starting a service within an isolated VRF network
  • 43. Running dhclient exit hooks using NetworkManager a dispatcher scriptExpand section "43. Running dhclient exit hooks using NetworkManager a dispatcher script" Collapse section "43. Running dhclient exit hooks using NetworkManager a dispatcher script"
    1. 43.1. The concept of NetworkManager dispatcher scripts
    2. 43.2. Creating a NetworkManager dispatcher script that runs dhclient exit hooks
  • 44. Introduction to NetworkManager DebuggingExpand section "44. Introduction to NetworkManager Debugging" Collapse section "44. Introduction to NetworkManager Debugging"
    1. 44.1. Debugging levels and domains
    2. 44.2. Setting the NetworkManager log level
    3. 44.3. Temporarily setting log levels at run time using nmcli
    4. 44.4. Viewing NetworkManager logs
  • 45. Introduction to NmstateExpand section "45. Introduction to Nmstate" Collapse section "45. Introduction to Nmstate"
    1. 45.1. Using the libnmstate library in a Python application
    2. 45.2. Updating the current network configuration using nmstatectl
    3. 45.3. Network states for the network RHEL System role
    4. 45.4. Additional resources
  • 46. Capturing network packetsExpand section "46. Capturing network packets" Collapse section "46. Capturing network packets"
    1. 46.1. Using xdpdump to capture network packets including packets dropped by XDP programs
    2. 46.2. Additional resources
  • 47. Using and configuring firewalldExpand section "47. Using and configuring firewalld" Collapse section "47. Using and configuring firewalld"
    1. 47.1. Getting started with firewalldExpand section "47.1. Getting started with firewalld" Collapse section "47.1. Getting started with firewalld"
      1. 47.1.1. When to use firewalld, nftables, or iptables
      2. 47.1.2. Zones
      3. 47.1.3. Predefined services
      4. 47.1.4. Starting firewalld
      5. 47.1.5. Stopping firewalld
      6. 47.1.6. Verifying the permanent firewalld configuration
    2. 47.2. Viewing the current status and settings of firewalldExpand section "47.2. Viewing the current status and settings of firewalld" Collapse section "47.2. Viewing the current status and settings of firewalld"
      1. 47.2.1. Viewing the current status of firewalld
      2. 47.2.2. Viewing allowed services using GUI
      3. 47.2.3. Viewing firewalld settings using CLI
    3. 47.3. Controlling network traffic using firewalldExpand section "47.3. Controlling network traffic using firewalld" Collapse section "47.3. Controlling network traffic using firewalld"
      1. 47.3.1. Disabling all traffic in case of emergency using CLI
      2. 47.3.2. Controlling traffic with predefined services using CLI
      3. 47.3.3. Controlling traffic with predefined services using GUI
      4. 47.3.4. Adding new services
      5. 47.3.5. Opening ports using GUI
      6. 47.3.6. Controlling traffic with protocols using GUI
      7. 47.3.7. Opening source ports using GUI
    4. 47.4. Controlling ports using CLIExpand section "47.4. Controlling ports using CLI" Collapse section "47.4. Controlling ports using CLI"
      1. 47.4.1. Opening a port
      2. 47.4.2. Closing a port
    5. 47.5. Working with firewalld zonesExpand section "47.5. Working with firewalld zones" Collapse section "47.5. Working with firewalld zones"
      1. 47.5.1. Listing zones
      2. 47.5.2. Modifying firewalld settings for a certain zone
      3. 47.5.3. Changing the default zone
      4. 47.5.4. Assigning a network interface to a zone
      5. 47.5.5. Assigning a zone to a connection using nmcli
      6. 47.5.6. Manually assigning a zone to a network connection in an ifcfg file
      7. 47.5.7. Creating a new zone
      8. 47.5.8. Zone configuration files
      9. 47.5.9. Using zone targets to set default behavior for incoming traffic
    6. 47.6. Using zones to manage incoming traffic depending on a sourceExpand section "47.6. Using zones to manage incoming traffic depending on a source" Collapse section "47.6. Using zones to manage incoming traffic depending on a source"
      1. 47.6.1. Adding a source
      2. 47.6.2. Removing a source
      3. 47.6.3. Adding a source port
      4. 47.6.4. Removing a source port
      5. 47.6.5. Using zones and sources to allow a service for only a specific domain
    7. 47.7. Filtering forwarded traffic between zonesExpand section "47.7. Filtering forwarded traffic between zones" Collapse section "47.7. Filtering forwarded traffic between zones"
      1. 47.7.1. The relationship between policy objects and zones
      2. 47.7.2. Using priorities to sort policies
      3. 47.7.3. Using policy objects to filter traffic between locally hosted Containers and a network physically connected to the host
      4. 47.7.4. Setting the default target of policy objects
    8. 47.8. Configuring NAT using firewalldExpand section "47.8. Configuring NAT using firewalld" Collapse section "47.8. Configuring NAT using firewalld"
      1. 47.8.1. NAT types
      2. 47.8.2. Configuring IP address masquerading
    9. 47.9. Using DNAT to forward HTTPS traffic to a different host
    10. 47.10. Managing ICMP requestsExpand section "47.10. Managing ICMP requests" Collapse section "47.10. Managing ICMP requests"
      1. 47.10.1. Listing and blocking ICMP requests
      2. 47.10.2. Configuring the ICMP filter using GUI
    11. 47.11. Setting and controlling IP sets using firewalldExpand section "47.11. Setting and controlling IP sets using firewalld" Collapse section "47.11. Setting and controlling IP sets using firewalld"
      1. 47.11.1. Configuring IP set options using CLI
    12. 47.12. Prioritizing rich rulesExpand section "47.12. Prioritizing rich rules" Collapse section "47.12. Prioritizing rich rules"
      1. 47.12.1. How the priority parameter organizes rules into different chains
      2. 47.12.2. Setting the priority of a rich rule
    13. 47.13. Configuring firewall lockdownExpand section "47.13. Configuring firewall lockdown" Collapse section "47.13. Configuring firewall lockdown"
      1. 47.13.1. Configuring lockdown using CLI
      2. 47.13.2. Configuring lockdown allowlist options using CLI
      3. 47.13.3. Configuring lockdown allowlist options using configuration files
    14. 47.14. Enabling traffic forwarding between different interfaces or sources within a firewalld zoneExpand section "47.14. Enabling traffic forwarding between different interfaces or sources within a firewalld zone" Collapse section "47.14. Enabling traffic forwarding between different interfaces or sources within a firewalld zone"
      1. 47.14.1. The difference between intra-zone forwarding and zones with the default target set to ACCEPT
      2. 47.14.2. Using intra-zone forwarding to forward traffic between an Ethernet and Wi-Fi network
    15. 47.15. Configuring firewalld using System RolesExpand section "47.15. Configuring firewalld using System Roles" Collapse section "47.15. Configuring firewalld using System Roles"
      1. 47.15.1. Introduction to the firewall RHEL System Role
      2. 47.15.2. Resetting the firewalld settings using the firewall RHEL System Role
      3. 47.15.3. Forwarding incoming traffic from one local port to a different local port
      4. 47.15.4. Configuring ports using System Roles
      5. 47.15.5. Configuring a DMZ firewalld zone by using the firewalld RHEL System Role
    16. 47.16. Additional resources
  • 48. Getting started with nftablesExpand section "48. Getting started with nftables" Collapse section "48. Getting started with nftables"
    1. 48.1. Migrating from iptables to nftablesExpand section "48.1. Migrating from iptables to nftables" Collapse section "48.1. Migrating from iptables to nftables"
      1. 48.1.1. When to use firewalld, nftables, or iptables
      2. 48.1.2. Converting iptables and ip6tables rule sets to nftables
      3. 48.1.3. Converting single iptables and ip6tables rules to nftables
      4. 48.1.4. Comparison of common iptables and nftables commands
      5. 48.1.5. Additional resources
    2. 48.2. Writing and executing nftables scriptsExpand section "48.2. Writing and executing nftables scripts" Collapse section "48.2. Writing and executing nftables scripts"
      1. 48.2.1. Supported nftables script formats
      2. 48.2.2. Running nftables scripts
      3. 48.2.3. Using comments in nftables scripts
      4. 48.2.4. Using variables in nftables script
      5. 48.2.5. Including files in nftables scripts
      6. 48.2.6. Automatically loading nftables rules when the system boots
    3. 48.3. Creating and managing nftables tables, chains, and rulesExpand section "48.3. Creating and managing nftables tables, chains, and rules" Collapse section "48.3. Creating and managing nftables tables, chains, and rules"
      1. 48.3.1. Basics of nftables tables
      2. 48.3.2. Basics of nftables chains
      3. 48.3.3. Basics of nftables rules
      4. 48.3.4. Managing tables, chains, and rules using nft commands
    4. 48.4. Configuring NAT using nftablesExpand section "48.4. Configuring NAT using nftables" Collapse section "48.4. Configuring NAT using nftables"
      1. 48.4.1. NAT types
      2. 48.4.2. Configuring masquerading using nftables
      3. 48.4.3. Configuring source NAT using nftables
      4. 48.4.4. Configuring destination NAT using nftables
      5. 48.4.5. Configuring a redirect using nftables
    5. 48.5. Using sets in nftables commandsExpand section "48.5. Using sets in nftables commands" Collapse section "48.5. Using sets in nftables commands"
      1. 48.5.1. Using anonymous sets in nftables
      2. 48.5.2. Using named sets in nftables
      3. 48.5.3. Additional resources
    6. 48.6. Using verdict maps in nftables commandsExpand section "48.6. Using verdict maps in nftables commands" Collapse section "48.6. Using verdict maps in nftables commands"
      1. 48.6.1. Using anonymous maps in nftables
      2. 48.6.2. Using named maps in nftables
      3. 48.6.3. Additional resources
    7. 48.7. Example: Protecting a LAN and DMZ using an nftables scriptExpand section "48.7. Example: Protecting a LAN and DMZ using an nftables script" Collapse section "48.7. Example: Protecting a LAN and DMZ using an nftables script"
      1. 48.7.1. Network conditions
      2. 48.7.2. Security requirements to the firewall script
      3. 48.7.3. Configuring logging of dropped packets to a file
      4. 48.7.4. Writing and activating the nftables script
    8. 48.8. Configuring port forwarding using nftablesExpand section "48.8. Configuring port forwarding using nftables" Collapse section "48.8. Configuring port forwarding using nftables"
      1. 48.8.1. Forwarding incoming packets to a different local port
      2. 48.8.2. Forwarding incoming packets on a specific local port to a different host
    9. 48.9. Using nftables to limit the amount of connectionsExpand section "48.9. Using nftables to limit the amount of connections" Collapse section "48.9. Using nftables to limit the amount of connections"
      1. 48.9.1. Limiting the number of connections using nftables
      2. 48.9.2. Blocking IP addresses that attempt more than ten new incoming TCP connections within one minute
    10. 48.10. Debugging nftables rulesExpand section "48.10. Debugging nftables rules" Collapse section "48.10. Debugging nftables rules"
      1. 48.10.1. Creating a rule with a counter
      2. 48.10.2. Adding a counter to an existing rule
      3. 48.10.3. Monitoring packets that match an existing rule
    11. 48.11. Backing up and restoring the nftables rule setExpand section "48.11. Backing up and restoring the nftables rule set" Collapse section "48.11. Backing up and restoring the nftables rule set"
      1. 48.11.1. Backing up the nftables rule set to a file
      2. 48.11.2. Restoring the nftables rule set from a file
    12. 48.12. Additional resources
  • 49. Using xdp-filter for high-performance traffic filtering to prevent DDoS attacksExpand section "49. Using xdp-filter for high-performance traffic filtering to prevent DDoS attacks" Collapse section "49. Using xdp-filter for high-performance traffic filtering to prevent DDoS attacks"
    1. 49.1. Dropping network packets that match an xdp-filter rule
    2. 49.2. Dropping all network packets except the ones that match an xdp-filter rule
  • 50. Getting started with DPDKExpand section "50. Getting started with DPDK" Collapse section "50. Getting started with DPDK"
    1. 50.1. Installing the dpdk package
    2. 50.2. Additional resources
  • 51. Understanding the eBPF networking features in RHEL 8Expand section "51. Understanding the eBPF networking features in RHEL 8" Collapse section "51. Understanding the eBPF networking features in RHEL 8"
    1. 51.1. Overview of networking eBPF features in RHEL 8
    2. 51.2. Overview of XDP features in RHEL 8 by network cards
  • 52. Network tracing using the BPF compiler collectionExpand section "52. Network tracing using the BPF compiler collection" Collapse section "52. Network tracing using the BPF compiler collection"
    1. 52.1. An introduction to BCC
    2. 52.2. Installing the bcc-tools package
    3. 52.3. Displaying TCP connections added to the Kernel’s accept queue
    4. 52.4. Tracing outgoing TCP connection attempts
    5. 52.5. Measuring the latency of outgoing TCP connections
    6. 52.6. Displaying details about TCP packets and segments that were dropped by the kernel
    7. 52.7. Tracing TCP sessions
    8. 52.8. Tracing TCP retransmissions
    9. 52.9. Displaying TCP state change information
    10. 52.10. Summarizing and aggregating TCP traffic sent to specific subnets
    11. 52.11. Displaying the network throughput by IP address and port
    12. 52.12. Tracing established TCP connections
    13. 52.13. Tracing IPv4 and IPv6 listen attempts
    14. 52.14. Summarizing the service time of soft interrupts
    15. 52.15. Additional resources
  • 53. Getting started with TIPCExpand section "53. Getting started with TIPC" Collapse section "53. Getting started with TIPC"
    1. 53.1. The architecture of TIPC
    2. 53.2. Loading the tipc module when the system boots
    3. 53.3. Creating a TIPC network
    4. 53.4. Additional resources
  • 54. Automatically configuring network interfaces in public clouds using nm-cloud-setupExpand section "54. Automatically configuring network interfaces in public clouds using nm-cloud-setup" Collapse section "54. Automatically configuring network interfaces in public clouds using nm-cloud-setup"
    1. 54.1. Configuring and pre-deploying nm-cloud-setup
  • Legal Notice
  • Show
    Settings Close
    • Language: Language:
      • 简体中文
      • 한국어
      • 日本語
      • English
      • Español
      • Português
    • Format: Format:
      • Multi-page
      • Single-page
      • PDF
      • ePub

    Language and Page Formatting Options

    • Language: Language:
      • 简体中文
      • 한국어
      • 日本語
      • English
      • Español
      • Português
    • Format: Format:
      • Multi-page
      • Single-page
      • PDF
      • ePub

    Red Hat Training

    A Red Hat training course is available for RHEL 8

    Chapter 47. Using and configuring firewalld

    A firewall is a way to protect machines from any unwanted traffic from outside. It enables users to control incoming network traffic on host machines by defining a set of firewall rules. These rules are used to sort the incoming traffic and either block it or allow through.

    # systemctl enable firewalld
    56 is a firewall service daemon that provides a dynamic customizable host-based firewall with a D-Bus interface. Being dynamic, it enables creating, changing, and deleting the rules without the necessity to restart the firewall daemon each time the rules are changed.

    # systemctl enable firewalld
    56 uses the concepts of zones and services, that simplify the traffic management. Zones are predefined sets of rules. Network interfaces and sources can be assigned to a zone. The traffic allowed depends on the network your computer is connected to and the security level this network is assigned. Firewall services are predefined rules that cover all necessary settings to allow incoming traffic for a specific service and they apply within a zone.

    Services use one or more ports or addresses for network communication. Firewalls filter communication based on ports. To allow network traffic for a service, its ports must be open.

    # systemctl enable firewalld
    56 blocks all traffic on ports that are not explicitly set as open. Some zones, such as trusted, allow all traffic by default.

    Note that

    # systemctl enable firewalld
    56 with
    # systemctl enable firewalld
    60 backend does not support passing custom
    # systemctl enable firewalld
    60 rules to
    # systemctl enable firewalld
    56, using the
    # systemctl enable firewalld
    63 option.

    47.1. Getting started with # systemctl enable firewalld56

    This section provides information about

    # systemctl enable firewalld
    56.

    47.1.1. When to use firewalld, nftables, or iptables

    The following is a brief overview in which scenario you should use one of the following utilities:

    • # systemctl enable firewalld
      56: Use the
      # systemctl enable firewalld
      56 utility for simple firewall use cases. The utility is easy to use and covers the typical use cases for these scenarios.
    • # systemctl enable firewalld
      60: Use the
      # systemctl enable firewalld
      60 utility to set up complex and performance-critical firewalls, such as for a whole network.
    • # systemctl enable firewalld
      70: The
      # systemctl enable firewalld
      70 utility on Red Hat Enterprise Linux uses the
      # systemctl enable firewalld
      72 kernel API instead of the
      # systemctl enable firewalld
      73 back end. The
      # systemctl enable firewalld
      72 API provides backward compatibility so that scripts that use
      # systemctl enable firewalld
      70 commands still work on Red Hat Enterprise Linux. For new firewall scripts, Red Hat recommends to use
      # systemctl enable firewalld
      60.

    Important

    To prevent the different firewall services from influencing each other, run only one of them on a RHEL host, and disable the other services.

    47.1.2. Zones

    # systemctl enable firewalld
    56 can be used to separate networks into different zones according to the level of trust that the user has decided to place on the interfaces and traffic within that network. A connection can only be part of one zone, but a zone can be used for many network connections.

    # systemctl enable firewalld
    78 notifies
    # systemctl enable firewalld
    56 of the zone of an interface. You can assign zones to interfaces with:

    • # systemctl enable firewalld
      78
    • # systemctl enable firewalld
      81 tool
    • # systemctl enable firewalld
      82 command-line tool
    • The RHEL web console

    The latter three can only edit the appropriate

    # systemctl enable firewalld
    78 configuration files. If you change the zone of the interface using the web console,
    # systemctl enable firewalld
    82 or
    # systemctl enable firewalld
    81, the request is forwarded to
    # systemctl enable firewalld
    78 and is not handled by ⁠
    # systemctl enable firewalld
    56.

    The predefined zones are stored in the

    # systemctl enable firewalld
    88 directory and can be instantly applied to any available network interface. These files are copied to the
    # systemctl enable firewalld
    89 directory only after they are modified. The default settings of the predefined zones are as follows:

    # systemctl enable firewalld
    90Any incoming network connections are rejected with an icmp-host-prohibited message for
    # systemctl enable firewalld
    91 and icmp6-adm-prohibited for
    # systemctl enable firewalld
    92. Only network connections initiated from within the system are possible.
    # systemctl enable firewalld
    93
    For computers in your demilitarized zone that are publicly-accessible with limited access to your internal network. Only selected incoming connections are accepted.
    # systemctl enable firewalld
    94
    Any incoming network packets are dropped without any notification. Only outgoing network connections are possible.
    # systemctl enable firewalld
    95
    For use on external networks with masquerading enabled, especially for routers. You do not trust the other computers on the network to not harm your computer. Only selected incoming connections are accepted.
    # systemctl enable firewalld
    96
    For use at home when you mostly trust the other computers on the network. Only selected incoming connections are accepted.
    # systemctl enable firewalld
    97
    For use on internal networks when you mostly trust the other computers on the network. Only selected incoming connections are accepted.
    # systemctl enable firewalld
    98
    For use in public areas where you do not trust other computers on the network. Only selected incoming connections are accepted.
    # systemctl enable firewalld
    99
    All network connections are accepted.
    # systemctl stop firewalld
    00
    For use at work where you mostly trust the other computers on the network. Only selected incoming connections are accepted.

    One of these zones is set as the default zone. When interface connections are added to

    # systemctl enable firewalld
    78, they are assigned to the default zone. On installation, the default zone in
    # systemctl enable firewalld
    56 is set to be the
    # systemctl enable firewalld
    98 zone. The default zone can be changed.

    Note

    The network zone names should be self-explanatory and to allow users to quickly make a reasonable decision. To avoid any security problems, review the default zone configuration and disable any unnecessary services according to your needs and risk assessments.

    Additional resources

    • The
      # systemctl stop firewalld
      04 man page.

    47.1.3. Predefined services

    A service can be a list of local ports, protocols, source ports, and destinations, as well as a list of firewall helper modules automatically loaded if a service is enabled. Using services saves users time because they can achieve several tasks, such as opening ports, defining protocols, enabling packet forwarding and more, in a single step, rather than setting up everything one after another.

    Service configuration options and generic file information are described in the

    # systemctl stop firewalld
    05 man page. The services are specified by means of individual XML configuration files, which are named in the following format:
    # systemctl stop firewalld
    06. Protocol names are preferred over service or application names in
    # systemctl enable firewalld
    56.

    Services can be added and removed using the graphical

    # systemctl enable firewalld
    81 tool,
    # systemctl enable firewalld
    82, and
    # systemctl stop firewalld
    10.

    Alternatively, you can edit the XML files in the

    # systemctl stop firewalld
    11 directory. If a service is not added or changed by the user, then no corresponding XML file is found in
    # systemctl stop firewalld
    11. The files in the
    # systemctl stop firewalld
    13 directory can be used as templates if you want to add or change a service.

    Additional resources

    • The
      # systemctl stop firewalld
      05 man page

    47.1.4. Starting firewalld

    Procedure

    1. To start

      # systemctl enable firewalld
      56, enter the following command as
      # systemctl stop firewalld
      16:

      # systemctl unmask firewalld
      # systemctl start firewalld
    2. To ensure

      # systemctl enable firewalld
      56 starts automatically at system start, enter the following command as
      # systemctl stop firewalld
      16:

      # systemctl enable firewalld

    47.1.5. Stopping firewalld

    Procedure

    1. To stop

      # systemctl enable firewalld
      56, enter the following command as
      # systemctl stop firewalld
      16:

      # systemctl stop firewalld
    2. To prevent

      # systemctl enable firewalld
      56 from starting automatically at system start:

      # systemctl disable firewalld
    3. To make sure firewalld is not started by accessing the

      # systemctl enable firewalld
      56
      # systemctl stop firewalld
      23 interface and also if other services require
      # systemctl enable firewalld
      56:

      # systemctl mask firewalld

    47.1.6. Verifying the permanent firewalld configuration

    In certain situations, for example after manually editing

    # systemctl enable firewalld
    56 configuration files, administrators want to verify that the changes are correct. This section describes how to verify the permanent configuration of the
    # systemctl enable firewalld
    56 service.

    Prerequisites

    • The
      # systemctl enable firewalld
      56 service is running.

    Procedure

    1. Verify the permanent configuration of the

      # systemctl enable firewalld
      56 service:

      # firewall-cmd --check-config
      success

      If the permanent configuration is valid, the command returns

      # systemctl stop firewalld
      29. In other cases, the command returns an error with further details, such as the following:

      # firewall-cmd --check-config
      Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}

    47.2. Viewing the current status and settings of # systemctl enable firewalld56

    This section covers information about viewing current status, allowed services, and current settings of

    # systemctl enable firewalld
    56.

    47.2.1. Viewing the current status of # systemctl enable firewalld56

    The firewall service,

    # systemctl enable firewalld
    56, is installed on the system by default. Use the
    # systemctl enable firewalld
    56 CLI interface to check that the service is running.

    Procedure

    1. To see the status of the service:

      # firewall-cmd --state
    2. For more information about the service status, use the

      # systemctl stop firewalld
      35 sub-command:

      # systemctl status firewalld
      firewalld.service - firewalld - dynamic firewall daemon
         Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
         Active: active (running) since Mon 2017-12-18 16:05:15 CET; 50min ago
           Docs: man:firewalld(1)
       Main PID: 705 (firewalld)
          Tasks: 2 (limit: 4915)
         CGroup: /system.slice/firewalld.service
                 └─705 /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid

    47.2.2. Viewing allowed services using GUI

    To view the list of services using the graphical firewall-config tool, press the Super key to enter the Activities Overview, type

    # systemctl stop firewalld
    36, and press Enter. The firewall-config tool appears. You can now view the list of services under the
    # systemctl stop firewalld
    37 tab.

    You can start the graphical firewall configuration tool using the command-line.

    Prerequisites

    • You installed the
      # systemctl enable firewalld
      81 package.

    Procedure

    • To start the graphical firewall configuration tool using the command-line:

      $ firewall-config

    The

    # systemctl stop firewalld
    39 window opens. Note that this command can be run as a normal user, but you are prompted for an administrator password occasionally.

    47.2.3. Viewing firewalld settings using CLI

    With the CLI client, it is possible to get different views of the current firewall settings. The

    # systemctl stop firewalld
    40 option shows a complete overview of the
    # systemctl enable firewalld
    56 settings.

    # systemctl enable firewalld
    56 uses zones to manage the traffic. If a zone is not specified by the
    # systemctl stop firewalld
    43 option, the command is effective in the default zone assigned to the active network interface and connection.

    Procedure

    • To list all the relevant information for the default zone:

      # systemctl enable firewalld
      0
    • To specify the zone for which to display the settings, add the

      # systemctl stop firewalld
      44 argument to the
      # systemctl stop firewalld
      45 command, for example:

      # systemctl enable firewalld
      1
    • To see the settings for particular information, such as services or ports, use a specific option. See the

      # systemctl enable firewalld
      56 manual pages or get a list of the options using the command help:

      # systemctl enable firewalld
      2
    • To see which services are allowed in the current zone:

      # systemctl enable firewalld
      3

    Note

    Listing the settings for a certain subpart using the CLI tool can sometimes be difficult to interpret. For example, you allow the

    # systemctl stop firewalld
    47 service and
    # systemctl enable firewalld
    56 opens the necessary port (22) for the service. Later, if you list the allowed services, the list shows the
    # systemctl stop firewalld
    47 service, but if you list open ports, it does not show any. Therefore, it is recommended to use the
    # systemctl stop firewalld
    40 option to make sure you receive a complete information.

    47.3. Controlling network traffic using # systemctl enable firewalld56

    This section covers information about controlling network traffic using

    # systemctl enable firewalld
    56.

    47.3.1. Disabling all traffic in case of emergency using CLI

    In an emergency situation, such as a system attack, it is possible to disable all network traffic and cut off the attacker.

    Procedure

    1. To immediately disable networking traffic, switch panic mode on:

      # systemctl enable firewalld
      4

      Important

      Enabling panic mode stops all networking traffic. For this reason, it should be used only when you have the physical access to the machine or if you are logged in using a serial console.

    2. Switching off panic mode reverts the firewall to its permanent settings. To switch panic mode off, enter:

      # systemctl enable firewalld
      5

    Verification

    • To see whether panic mode is switched on or off, use:

      # systemctl enable firewalld
      6

    47.3.2. Controlling traffic with predefined services using CLI

    The most straightforward method to control traffic is to add a predefined service to

    # systemctl enable firewalld
    56. This opens all necessary ports and modifies other settings according to the service definition file.

    Procedure

    1. Check that the service is not already allowed:

      # systemctl enable firewalld
      7
    2. List all predefined services:

      # systemctl enable firewalld
      8
    3. Add the service to the allowed services:

      # systemctl enable firewalld
      9
    4. Make the new settings persistent:

      # systemctl stop firewalld
      0

    47.3.3. Controlling traffic with predefined services using GUI

    This procedure describes how to control the network traffic with predefined services using graphical user interface.

    Prerequisites

    • You installed the
      # systemctl enable firewalld
      81 package

    Procedure

    1. To enable or disable a predefined or custom service:

      1. Start the firewall-config tool and select the network zone whose services are to be configured.
      2. Select the
        # systemctl stop firewalld
        55 tab and then the
        # systemctl stop firewalld
        37 tab below.
      3. Select the check box for each type of service you want to trust or clear the check box to block a service in the selected zone.

    2. To edit a service:

      1. Start the firewall-config tool.
      2. Select
        # systemctl stop firewalld
        57 from the menu labeled
        # systemctl stop firewalld
        58. Additional icons and menu buttons appear at the bottom of the Services window.
      3. Select the service you want to configure.

    The

    # systemctl stop firewalld
    59,
    # systemctl stop firewalld
    60, and
    # systemctl stop firewalld
    61 tabs enable adding, changing, and removing of ports, protocols, and source port for the selected service. The modules tab is for configuring Netfilter helper modules. The
    # systemctl stop firewalld
    62 tab enables limiting traffic to a particular destination address and Internet Protocol (
    # systemctl enable firewalld
    91 or
    # systemctl enable firewalld
    92).

    Note

    It is not possible to alter service settings in the

    # systemctl stop firewalld
    65 mode.

    47.3.4. Adding new services

    Services can be added and removed using the graphical firewall-config tool,

    # systemctl enable firewalld
    82, and
    # systemctl stop firewalld
    10. Alternatively, you can edit the XML files in
    # systemctl stop firewalld
    11. If a service is not added or changed by the user, then no corresponding XML file are found in
    # systemctl stop firewalld
    11. The files
    # systemctl stop firewalld
    13 can be used as templates if you want to add or change a service.

    Note

    Service names must be alphanumeric and can, additionally, include only

    # systemctl stop firewalld
    71 (underscore) and
    # systemctl stop firewalld
    72 (dash) characters.

    Procedure

    To add a new service in a terminal, use

    # systemctl enable firewalld
    82, or
    # systemctl stop firewalld
    10 in case of not active
    # systemctl enable firewalld
    56.

    1. Enter the following command to add a new and empty service:

      # systemctl stop firewalld
      1
    2. To add a new service using a local file, use the following command:

      # systemctl stop firewalld
      2

      You can change the service name with the additional

      # systemctl stop firewalld
      76 option.

    3. As soon as service settings are changed, an updated copy of the service is placed into

      # systemctl stop firewalld
      11.

      As

      # systemctl stop firewalld
      16, you can enter the following command to copy a service manually:

      # systemctl stop firewalld
      3

    # systemctl enable firewalld
    56 loads files from
    # systemctl stop firewalld
    80 in the first place. If files are placed in
    # systemctl stop firewalld
    81 and they are valid, then these will override the matching files from
    # systemctl stop firewalld
    80. The overridden files in
    # systemctl stop firewalld
    80 are used as soon as the matching files in
    # systemctl stop firewalld
    81 have been removed or if
    # systemctl enable firewalld
    56 has been asked to load the defaults of the services. This applies to the permanent environment only. A reload is needed to get these fallbacks also in the runtime environment.

    47.3.5. Opening ports using GUI

    To permit traffic through the firewall to a certain port, you can open the port in the GUI.

    Prerequisites

    • You installed the
      # systemctl enable firewalld
      81 package

    Procedure

    1. Start the firewall-config tool and select the network zone whose settings you want to change.
    2. Select the
      # systemctl stop firewalld
      59 tab and click the Add button on the right-hand side. The
      # systemctl stop firewalld
      88 window opens.
    3. Enter the port number or range of ports to permit.
    4. Select
      # systemctl stop firewalld
      89 or
      # systemctl stop firewalld
      90 from the list.

    47.3.6. Controlling traffic with protocols using GUI

    To permit traffic through the firewall using a certain protocol, you can use the GUI.

    Prerequisites

    • You installed the
      # systemctl enable firewalld
      81 package

    Procedure

    1. Start the firewall-config tool and select the network zone whose settings you want to change.
    2. Select the
      # systemctl stop firewalld
      60 tab and click the
      # systemctl stop firewalld
      93 button on the right-hand side. The
      # systemctl stop firewalld
      94 window opens.
    3. Either select a protocol from the list or select the
      # systemctl stop firewalld
      95 check box and enter the protocol in the field.

    47.3.7. Opening source ports using GUI

    To permit traffic through the firewall from a certain port, you can use the GUI.

    Prerequisites

    • You installed the
      # systemctl enable firewalld
      81 package

    Procedure

    1. Start the firewall-config tool and select the network zone whose settings you want to change.
    2. Select the
      # systemctl stop firewalld
      61 tab and click the
      # systemctl stop firewalld
      93 button on the right-hand side. The
      # systemctl stop firewalld
      61 window opens.
    3. Enter the port number or range of ports to permit. Select
      # systemctl stop firewalld
      89 or
      # systemctl stop firewalld
      90 from the list.

    47.4. Controlling ports using CLI

    Ports are logical devices that enable an operating system to receive and distinguish network traffic and forward it accordingly to system services. These are usually represented by a daemon that listens on the port, that is it waits for any traffic coming to this port.

    Normally, system services listen on standard ports that are reserved for them. The

    # systemctl disable firewalld
    02 daemon, for example, listens on port 80. However, system administrators by default configure daemons to listen on different ports to enhance security or for other reasons.

    47.4.1. Opening a port

    Through open ports, the system is accessible from the outside, which represents a security risk. Generally, keep ports closed and only open them if they are required for certain services.

    Procedure

    To get a list of open ports in the current zone:

    1. List all allowed ports:

      # systemctl stop firewalld
      4
    2. Add a port to the allowed ports to open it for incoming traffic:

      # systemctl stop firewalld
      5

      The port types are either

      # systemctl stop firewalld
      89,
      # systemctl stop firewalld
      90,
      # systemctl disable firewalld
      05, or
      # systemctl disable firewalld
      06. The type must match the type of network communication.

    3. Make the new settings persistent:

      # systemctl stop firewalld
      0

      The port types are either

      # systemctl stop firewalld
      89,
      # systemctl stop firewalld
      90,
      # systemctl disable firewalld
      05, or
      # systemctl disable firewalld
      06. The type must match the type of network communication.

    47.4.2. Closing a port

    When an open port is no longer needed, close that port in

    # systemctl enable firewalld
    56. It is highly recommended to close all unnecessary ports as soon as they are not used because leaving a port open represents a security risk.

    Procedure

    To close a port, remove it from the list of allowed ports:

    1. List all allowed ports:

      # systemctl stop firewalld
      4

      Warning

      This command will only give you a list of ports that have been opened as ports. You will not be able to see any open ports that have been opened as a service. Therefore, you should consider using the

      # systemctl stop firewalld
      40 option instead of
      # systemctl disable firewalld
      13.

    2. Remove the port from the allowed ports to close it for the incoming traffic:

      # systemctl stop firewalld
      8
    3. Make the new settings persistent:

      # systemctl stop firewalld
      0

    47.5. Working with firewalld zones

    Zones represent a concept to manage incoming traffic more transparently. The zones are connected to networking interfaces or assigned a range of source addresses. You manage firewall rules for each zone independently, which enables you to define complex firewall settings and apply them to the traffic.

    47.5.1. Listing zones

    This procedure describes how to list zones using the command line.

    Procedure

    1. To see which zones are available on your system:

      # systemctl disable firewalld
      0

      The

      # systemctl disable firewalld
      14 command displays all zones that are available on the system, but it does not show any details for particular zones.

    2. To see detailed information for all zones:

      # systemctl disable firewalld
      1
    3. To see detailed information for a specific zone:

      # systemctl disable firewalld
      2

    47.5.2. Modifying firewalld settings for a certain zone

    The Controlling traffic with predefined services using cli and Controlling ports using cli explain how to add services or modify ports in the scope of the current working zone. Sometimes, it is required to set up rules in a different zone.

    Procedure

    • To work in a different zone, use the

      # systemctl stop firewalld
      44 option. For example, to allow the
      # systemctl stop firewalld
      47 service in the zone public:

      # systemctl disable firewalld
      3

    47.5.3. Changing the default zone

    System administrators assign a zone to a networking interface in its configuration files. If an interface is not assigned to a specific zone, it is assigned to the default zone. After each restart of the

    # systemctl enable firewalld
    56 service,
    # systemctl enable firewalld
    56 loads the settings for the default zone and makes it active.

    Procedure

    To set up the default zone:

    1. Display the current default zone:

      # systemctl disable firewalld
      4
    2. Set the new default zone:

      # systemctl disable firewalld
      5

      Note

      Following this procedure, the setting is a permanent setting, even without the

      # systemctl disable firewalld
      19 option.

    47.5.4. Assigning a network interface to a zone

    It is possible to define different sets of rules for different zones and then change the settings quickly by changing the zone for the interface that is being used. With multiple interfaces, a specific zone can be set for each of them to distinguish traffic that is coming through them.

    Procedure

    To assign the zone to a specific interface:

    1. List the active zones and the interfaces assigned to them:

      # systemctl disable firewalld
      6
    2. Assign the interface to a different zone:

      # systemctl disable firewalld
      7

    47.5.5. Assigning a zone to a connection using nmcli

    This procedure describes how to add a

    # systemctl enable firewalld
    56 zone to a
    # systemctl enable firewalld
    78 connection using the
    # systemctl disable firewalld
    22 utility.

    Procedure

    1. Assign the zone to the

      # systemctl enable firewalld
      78 connection profile:

      # systemctl disable firewalld
      8
    2. Activate the connection:

      # systemctl disable firewalld
      9

    47.5.6. Manually assigning a zone to a network connection in an ifcfg file

    When the connection is managed by NetworkManager, it must be aware of a zone that it uses. For every network connection, a zone can be specified, which provides the flexibility of various firewall settings according to the location of the computer with portable devices. Thus, zones and settings can be specified for different locations, such as company or home.

    Procedure

    • To set a zone for a connection, edit the

      # systemctl disable firewalld
      24 file and add a line that assigns a zone to this connection:

      # systemctl mask firewalld
      0

    47.5.7. Creating a new zone

    To use custom zones, create a new zone and use it just like a predefined zone. New zones require the

    # systemctl disable firewalld
    19 option, otherwise the command does not work.

    Procedure

    1. Create a new zone:

      # systemctl mask firewalld
      1
    2. Check if the new zone is added to your permanent settings:

      # systemctl mask firewalld
      2
    3. Make the new settings persistent:

      # systemctl mask firewalld
      3

    47.5.8. Zone configuration files

    Zones can also be created using a zone configuration file. This approach can be helpful when you need to create a new zone, but want to reuse the settings from a different zone and only alter them a little.

    A

    # systemctl enable firewalld
    56 zone configuration file contains the information for a zone. These are the zone description, services, ports, protocols, icmp-blocks, masquerade, forward-ports and rich language rules in an XML file format. The file name has to be
    # systemctl disable firewalld
    27 where the length of zone-name is currently limited to 17 chars. The zone configuration files are located in the
    # systemctl enable firewalld
    88 and
    # systemctl enable firewalld
    89 directories.

    The following example shows a configuration that allows one service (

    # systemctl stop firewalld
    47) and one port range, for both the
    # systemctl disable firewalld
    31 and
    # systemctl disable firewalld
    32 protocols:

    # systemctl mask firewalld
    4

    To change settings for that zone, add or remove sections to add ports, forward ports, services, and so on.

    Additional resources

    • # systemctl disable firewalld
      33 manual page

    47.5.9. Using zone targets to set default behavior for incoming traffic

    For every zone, you can set a default behavior that handles incoming traffic that is not further specified. Such behavior is defined by setting the target of the zone. There are four options:

    • # systemctl disable firewalld
      34: Accepts all incoming packets except those disallowed by specific rules.
    • # systemctl disable firewalld
      35: Rejects all incoming packets except those allowed by specific rules. When
      # systemctl enable firewalld
      56 rejects packets, the source machine is informed about the rejection.
    • # systemctl disable firewalld
      37: Drops all incoming packets except those allowed by specific rules. When
      # systemctl enable firewalld
      56 drops packets, the source machine is not informed about the packet drop.
    • # systemctl disable firewalld
      39: Similar behavior as for
      # systemctl disable firewalld
      35, but with special meanings in certain scenarios. For details, see the
      # systemctl disable firewalld
      41 section in the
      # systemctl disable firewalld
      42 man page.

    Procedure

    To set a target for a zone:

    1. List the information for the specific zone to see the default target:

      # systemctl mask firewalld
      5
    2. Set a new target in the zone:

      # systemctl mask firewalld
      6

    Additional resources

    • # systemctl disable firewalld
      42 man page

    47.6. Using zones to manage incoming traffic depending on a source

    You can use zones to manage incoming traffic based on its source. That enables you to sort incoming traffic and route it through different zones to allow or disallow services that can be reached by that traffic.

    If you add a source to a zone, the zone becomes active and any incoming traffic from that source will be directed through it. You can specify different settings for each zone, which is applied to the traffic from the given sources accordingly. You can use more zones even if you only have one network interface.

    47.6.1. Adding a source

    To route incoming traffic into a specific zone, add the source to that zone. The source can be an IP address or an IP mask in the classless inter-domain routing (CIDR) notation.

    Note

    In case you add multiple zones with an overlapping network range, they are ordered alphanumerically by zone name and only the first one is considered.

    • To set the source in the current zone:

      # systemctl mask firewalld
      7
    • To set the source IP address for a specific zone:

      # systemctl mask firewalld
      8

    The following procedure allows all incoming traffic from 192.168.2.15 in the

    # systemctl enable firewalld
    99 zone:

    Procedure

    1. List all available zones:

      # systemctl disable firewalld
      0
    2. Add the source IP to the trusted zone in the permanent mode:

      # firewall-cmd --check-config
      success
      0
    3. Make the new settings persistent:

      # systemctl stop firewalld
      0

    47.6.2. Removing a source

    Removing a source from the zone cuts off the traffic coming from it.

    Procedure

    1. List allowed sources for the required zone:

      # firewall-cmd --check-config
      success
      2
    2. Remove the source from the zone permanently:

      # firewall-cmd --check-config
      success
      3
    3. Make the new settings persistent:

      # systemctl stop firewalld
      0

    47.6.3. Adding a source port

    To enable sorting the traffic based on a port of origin, specify a source port using the

    # systemctl disable firewalld
    45 option. You can also combine this with the
    # systemctl disable firewalld
    46 option to limit the traffic to a certain IP address or IP range.

    Procedure

    • To add a source port:

      # firewall-cmd --check-config
      success
      5

    47.6.4. Removing a source port

    By removing a source port you disable sorting the traffic based on a port of origin.

    Procedure

    • To remove a source port:

      # firewall-cmd --check-config
      success
      6

    47.6.5. Using zones and sources to allow a service for only a specific domain

    To allow traffic from a specific network to use a service on a machine, use zones and source. The following procedure allows only HTTP traffic from the

    # systemctl disable firewalld
    47 network while any other traffic is blocked.

    Warning

    When you configure this scenario, use a zone that has the

    # systemctl disable firewalld
    39 target. Using a zone that has the target set to
    # systemctl disable firewalld
    34 is a security risk, because for traffic from
    # systemctl disable firewalld
    47, all network connections would be accepted.

    Procedure

    1. List all available zones:

      # firewall-cmd --check-config
      success
      7
    2. Add the IP range to the

      # systemctl enable firewalld
      97 zone to route the traffic originating from the source through the zone:

      # firewall-cmd --check-config
      success
      8
    3. Add the

      # systemctl disable firewalld
      52 service to the
      # systemctl enable firewalld
      97 zone:

      # firewall-cmd --check-config
      success
      9
    4. Make the new settings persistent:

      # firewall-cmd --check-config
      Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
      0

    Verification

    • Check that the

      # systemctl enable firewalld
      97 zone is active and that the service is allowed in it:

      # firewall-cmd --check-config
      Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
      1

    Additional resources

    • # systemctl disable firewalld
      55 man page

    47.7. Filtering forwarded traffic between zones

    With a policy object, users can group different identities that require similar permissions in the policy. You can apply policies depending on the direction of the traffic.

    The policy objects feature provides forward and output filtering in firewalld. The following describes the usage of firewalld to filter traffic between different zones to allow access to locally hosted VMs to connect the host.

    47.7.1. The relationship between policy objects and zones

    Policy objects allow the user to attach firewalld’s primitives’ such as services, ports, and rich rules to the policy. You can apply the policy objects to traffic that passes between zones in a stateful and unidirectional manner.

    # firewall-cmd --check-config
    Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
    2

    # systemctl disable firewalld
    56 and
    # systemctl disable firewalld
    57 are the symbolic zones used in the ingress and egress zone lists.

    • The
      # systemctl disable firewalld
      56 symbolic zone allows policies for the traffic originating from or has a destination to the host running firewalld.
    • The
      # systemctl disable firewalld
      57 symbolic zone applies policy to all the current and future zones.
      # systemctl disable firewalld
      57 symbolic zone acts as a wildcard for all zones.

    47.7.2. Using priorities to sort policies

    Multiple policies can apply to the same set of traffic, therefore, priorities should be used to create an order of precedence for the policies that may be applied.

    To set a priority to sort the policies:

    # firewall-cmd --check-config
    Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
    3

    In the above example -500 is a lower priority value but has higher precedence. Thus, -500 will execute before -100. Higher priority values have precedence over lower values.

    The following rules apply to policy priorities:

    • Policies with negative priorities apply before rules in zones.
    • Policies with positive priorities apply after rules in zones.
    • Priority 0 is reserved and hence is unusable.

    47.7.3. Using policy objects to filter traffic between locally hosted Containers and a network physically connected to the host

    The policy objects feature allows users to filter their container and virtual machine traffic.

    Procedure

    1. Create a new policy.

      # firewall-cmd --check-config
      Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
      4
    2. Block all traffic.

      # firewall-cmd --check-config
      Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
      5

      Note

      Red Hat recommends that you block all traffic to the host by default and then selectively open the services you need for the host.

    3. Define the ingress zone to use with the policy.

      # firewall-cmd --check-config
      Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
      6
    4. Define the egress zone to use with the policy.

      # firewall-cmd --check-config
      Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
      7

    Verification

    • Verify information about the policy.

      # firewall-cmd --check-config
      Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
      8

    47.7.4. Setting the default target of policy objects

    You can specify --set-target options for policies. The following targets are available:

    • ACCEPT - accepts the packet
    • DROP - drops the unwanted packets
    • REJECT - rejects unwanted packets with an ICMP reply
    • CONTINUE (default) - packets will be subject to rules in following policies and zones.

      # firewall-cmd --check-config
      Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
      9

    Verification

    • Verify information about the policy

      # firewall-cmd --state
      0

    47.8. Configuring NAT using firewalld

    With

    # systemctl enable firewalld
    56, you can configure the following network address translation (NAT) types:

    • Masquerading
    • Source NAT (SNAT)
    • Destination NAT (DNAT)
    • Redirect

    47.8.1. NAT types

    These are the different network address translation (NAT) types:

    Masquerading and source NAT (SNAT)

    Use one of these NAT types to change the source IP address of packets. For example, Internet Service Providers do not route private IP ranges, such as

    # systemctl disable firewalld
    62. If you use private IP ranges in your network and users should be able to reach servers on the Internet, map the source IP address of packets from these ranges to a public IP address.

    Masquerading and SNAT are very similar to one another. The differences are:

    • Masquerading automatically uses the IP address of the outgoing interface. Therefore, use masquerading if the outgoing interface uses a dynamic IP address.
    • SNAT sets the source IP address of packets to a specified IP and does not dynamically look up the IP of the outgoing interface. Therefore, SNAT is faster than masquerading. Use SNAT if the outgoing interface uses a fixed IP address.

    Destination NAT (DNAT)Use this NAT type to rewrite the destination address and port of incoming packets. For example, if your web server uses an IP address from a private IP range and is, therefore, not directly accessible from the Internet, you can set a DNAT rule on the router to redirect incoming traffic to this server.RedirectThis type is a special case of DNAT that redirects packets to the local machine depending on the chain hook. For example, if a service runs on a different port than its standard port, you can redirect incoming traffic from the standard port to this specific port.

    47.8.2. Configuring IP address masquerading

    The following procedure describes how to enable IP masquerading on your system. IP masquerading hides individual machines behind a gateway when accessing the Internet.

    Procedure

    1. To check if IP masquerading is enabled (for example, for the

      # systemctl enable firewalld
      95 zone), enter the following command as
      # systemctl stop firewalld
      16:

      # firewall-cmd --state
      1

      The command prints

      # systemctl disable firewalld
      65 with exit status
      # systemctl disable firewalld
      66 if enabled. It prints
      # systemctl disable firewalld
      67 with exit status
      # systemctl disable firewalld
      68 otherwise. If
      # systemctl disable firewalld
      69 is omitted, the default zone will be used.

    2. To enable IP masquerading, enter the following command as

      # systemctl stop firewalld
      16:

      # firewall-cmd --state
      2
    3. To make this setting persistent, pass the
      # systemctl disable firewalld
      19 option to the command.
    4. To disable IP masquerading, enter the following command as

      # systemctl stop firewalld
      16:

      # firewall-cmd --state
      3

      To make this setting permanent, pass the

      # systemctl disable firewalld
      19 option to the command.

    47.9. Using DNAT to forward HTTPS traffic to a different host

    If your web server runs in a DMZ with private IP addresses, you can configure destination network address translation (DNAT) to enable clients on the internet to connect to this web server. In this case, the host name of the web server resolves to the public IP address of the router. When a client establishes a connection to a defined port on the router, the router forwards the packets to the internal web server.

    Prerequisites

    • The DNS server resolves the host name of the web server to the router’s IP address.
    • You know the following settings:

      • The private IP address and port number that you want to forward
      • The IP protocol to be used
      • The destination IP address and port of the web server where you want to redirect the packets

    Procedure

    1. Create a firewall policy:

      # firewall-cmd --state
      4

      The policies, as opposed to zones, allow packet filtering for input, output, and forwarded traffic. This is important, because forwarding traffic to endpoints on locally run web servers, containers, or virtual machines requires such capability.

    2. Configure symbolic zones for the ingress and egress traffic to also enable the router itself to connect to its local IP address and forward this traffic:

      # firewall-cmd --state
      5

      The

      # systemctl disable firewalld
      74 option refers to packets generated locally, which are transmitted out of the local host. The
      # systemctl disable firewalld
      75 option refers to traffic destined to any zone.

    3. Add a rich rule that forwards traffic to the web server:

      # firewall-cmd --state
      6

      The rich rule forwards TCP traffic from port 443 on the router’s IP address 192.0.2.1 to port 443 of the web server’s IP 198.51.100.20. The rule uses the

      # systemctl disable firewalld
      76 to ensure that the router can also connect to its local IP address.

    4. Reload the firewall configuration files:

      # firewall-cmd --state
      7
    5. Activate routing of 127.0.0.0/8 in the kernel:

      # firewall-cmd --state
      8

    Verification

    1. Connect to the router’s IP address and port that you have forwarded to the web server:

      # firewall-cmd --state
      9
    2. Optional: Verify that

      # systemctl disable firewalld
      77 is active:

      # systemctl status firewalld
      firewalld.service - firewalld - dynamic firewall daemon
         Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
         Active: active (running) since Mon 2017-12-18 16:05:15 CET; 50min ago
           Docs: man:firewalld(1)
       Main PID: 705 (firewalld)
          Tasks: 2 (limit: 4915)
         CGroup: /system.slice/firewalld.service
                 └─705 /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid
      0
    3. Verify that

      # systemctl disable firewalld
      76 is active and contains the settings you need. Especially the source IP address and port, protocol to be used, and the destination IP address and port:

      # systemctl status firewalld
      firewalld.service - firewalld - dynamic firewall daemon
         Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
         Active: active (running) since Mon 2017-12-18 16:05:15 CET; 50min ago
           Docs: man:firewalld(1)
       Main PID: 705 (firewalld)
          Tasks: 2 (limit: 4915)
         CGroup: /system.slice/firewalld.service
                 └─705 /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid
      1

    Additional resources

    • # systemctl disable firewalld
      42
    • # systemctl disable firewalld
      80
    • # systemctl disable firewalld
      81
    • # systemctl disable firewalld
      82
    • # systemctl disable firewalld
      83
    • Using configuration files in /etc/sysctl.d/ to adjust kernel parameters

    47.10. Managing ICMP requests

    The

    # systemctl disable firewalld
    84 (
    # systemctl disable firewalld
    85) is a supporting protocol that is used by various network devices to send error messages and operational information indicating a connection problem, for example, that a requested service is not available.
    # systemctl disable firewalld
    85 differs from transport protocols such as TCP and UDP because it is not used to exchange data between systems.

    Unfortunately, it is possible to use the

    # systemctl disable firewalld
    85 messages, especially
    # systemctl disable firewalld
    88 and
    # systemctl disable firewalld
    89, to reveal information about your network and misuse such information for various kinds of fraudulent activities. Therefore,
    # systemctl enable firewalld
    56 enables blocking the
    # systemctl disable firewalld
    85 requests to protect your network information.

    47.10.1. Listing and blocking ICMP requests

    Listing

    # systemctl disable firewalld
    85 requests

    The

    # systemctl disable firewalld
    85 requests are described in individual XML files that are located in the
    # systemctl disable firewalld
    94 directory. You can read these files to see a description of the request. The
    # systemctl enable firewalld
    82 command controls the
    # systemctl disable firewalld
    85 requests manipulation.

    • To list all available

      # systemctl disable firewalld
      85 types:

      # systemctl status firewalld
      firewalld.service - firewalld - dynamic firewall daemon
         Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
         Active: active (running) since Mon 2017-12-18 16:05:15 CET; 50min ago
           Docs: man:firewalld(1)
       Main PID: 705 (firewalld)
          Tasks: 2 (limit: 4915)
         CGroup: /system.slice/firewalld.service
                 └─705 /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid
      2
    • The

      # systemctl disable firewalld
      85 request can be used by IPv4, IPv6, or by both protocols. To see for which protocol the
      # systemctl disable firewalld
      85 request has used:

      # systemctl status firewalld
      firewalld.service - firewalld - dynamic firewall daemon
         Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
         Active: active (running) since Mon 2017-12-18 16:05:15 CET; 50min ago
           Docs: man:firewalld(1)
       Main PID: 705 (firewalld)
          Tasks: 2 (limit: 4915)
         CGroup: /system.slice/firewalld.service
                 └─705 /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid
      3
    • The status of an

      # systemctl disable firewalld
      85 request shows
      # systemctl disable firewalld
      65 if the request is currently blocked or
      # systemctl disable firewalld
      67 if it is not. To see if an
      # systemctl disable firewalld
      85 request is currently blocked:

      # systemctl status firewalld
      firewalld.service - firewalld - dynamic firewall daemon
         Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
         Active: active (running) since Mon 2017-12-18 16:05:15 CET; 50min ago
           Docs: man:firewalld(1)
       Main PID: 705 (firewalld)
          Tasks: 2 (limit: 4915)
         CGroup: /system.slice/firewalld.service
                 └─705 /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid
      4

    Blocking or unblocking

    # systemctl disable firewalld
    85 requests

    When your server blocks

    # systemctl disable firewalld
    85 requests, it does not provide the information that it normally would. However, that does not mean that no information is given at all. The clients receive information that the particular
    # systemctl disable firewalld
    85 request is being blocked (rejected). Blocking the
    # systemctl disable firewalld
    85 requests should be considered carefully, because it can cause communication problems, especially with IPv6 traffic.

    • To see if an

      # systemctl disable firewalld
      85 request is currently blocked:

      # systemctl status firewalld
      firewalld.service - firewalld - dynamic firewall daemon
         Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
         Active: active (running) since Mon 2017-12-18 16:05:15 CET; 50min ago
           Docs: man:firewalld(1)
       Main PID: 705 (firewalld)
          Tasks: 2 (limit: 4915)
         CGroup: /system.slice/firewalld.service
                 └─705 /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid
      4
    • To block an

      # systemctl disable firewalld
      85 request:

      # systemctl status firewalld
      firewalld.service - firewalld - dynamic firewall daemon
         Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
         Active: active (running) since Mon 2017-12-18 16:05:15 CET; 50min ago
           Docs: man:firewalld(1)
       Main PID: 705 (firewalld)
          Tasks: 2 (limit: 4915)
         CGroup: /system.slice/firewalld.service
                 └─705 /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid
      6
    • To remove the block for an

      # systemctl disable firewalld
      85 request:

      # systemctl status firewalld
      firewalld.service - firewalld - dynamic firewall daemon
         Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
         Active: active (running) since Mon 2017-12-18 16:05:15 CET; 50min ago
           Docs: man:firewalld(1)
       Main PID: 705 (firewalld)
          Tasks: 2 (limit: 4915)
         CGroup: /system.slice/firewalld.service
                 └─705 /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid
      7

    Blocking

    # systemctl disable firewalld
    85 requests without providing any information at all

    Normally, if you block

    # systemctl disable firewalld
    85 requests, clients know that you are blocking it. So, a potential attacker who is sniffing for live IP addresses is still able to see that your IP address is online. To hide this information completely, you have to drop all
    # systemctl disable firewalld
    85 requests.

    • To block and drop all
      # systemctl disable firewalld
      85 requests:
    • Set the target of your zone to

      # systemctl disable firewalld
      37:

      # systemctl status firewalld
      firewalld.service - firewalld - dynamic firewall daemon
         Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
         Active: active (running) since Mon 2017-12-18 16:05:15 CET; 50min ago
           Docs: man:firewalld(1)
       Main PID: 705 (firewalld)
          Tasks: 2 (limit: 4915)
         CGroup: /system.slice/firewalld.service
                 └─705 /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid
      8

    Now, all traffic, including

    # systemctl disable firewalld
    85 requests, is dropped, except traffic which you have explicitly allowed.

    To block and drop certain

    # systemctl disable firewalld
    85 requests and allow others:

    1. Set the target of your zone to

      # systemctl disable firewalld
      37:

      # systemctl status firewalld
      firewalld.service - firewalld - dynamic firewall daemon
         Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
         Active: active (running) since Mon 2017-12-18 16:05:15 CET; 50min ago
           Docs: man:firewalld(1)
       Main PID: 705 (firewalld)
          Tasks: 2 (limit: 4915)
         CGroup: /system.slice/firewalld.service
                 └─705 /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid
      8
    2. Add the ICMP block inversion to block all

      # systemctl disable firewalld
      85 requests at once:

      $ firewall-config
      0
    3. Add the ICMP block for those

      # systemctl disable firewalld
      85 requests that you want to allow:

      # systemctl status firewalld
      firewalld.service - firewalld - dynamic firewall daemon
         Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
         Active: active (running) since Mon 2017-12-18 16:05:15 CET; 50min ago
           Docs: man:firewalld(1)
       Main PID: 705 (firewalld)
          Tasks: 2 (limit: 4915)
         CGroup: /system.slice/firewalld.service
                 └─705 /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid
      6
    4. Make the new settings persistent:

      # systemctl stop firewalld
      0

    The block inversion inverts the setting of the

    # systemctl disable firewalld
    85 requests blocks, so all requests, that were not previously blocked, are blocked because of the target of your zone changes to
    # systemctl disable firewalld
    37. The requests that were blocked are not blocked. This means that if you want to unblock a request, you must use the blocking command.

    To revert the block inversion to a fully permissive setting:

    1. Set the target of your zone to

      # systemctl disable firewalld
      39 or
      # systemctl disable firewalld
      34:

      $ firewall-config
      3
    2. Remove all added blocks for

      # systemctl disable firewalld
      85 requests:

      # systemctl status firewalld
      firewalld.service - firewalld - dynamic firewall daemon
         Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor pr
         Active: active (running) since Mon 2017-12-18 16:05:15 CET; 50min ago
           Docs: man:firewalld(1)
       Main PID: 705 (firewalld)
          Tasks: 2 (limit: 4915)
         CGroup: /system.slice/firewalld.service
                 └─705 /usr/bin/python3 -Es /usr/sbin/firewalld --nofork --nopid
      7
    3. Remove the

      # systemctl disable firewalld
      85 block inversion:

      $ firewall-config
      5
    4. Make the new settings persistent:

      # systemctl stop firewalld
      0

    47.10.2. Configuring the ICMP filter using GUI

    • To enable or disable an
      # systemctl disable firewalld
      85 filter, start the firewall-config tool and select the network zone whose messages are to be filtered. Select the
      # systemctl mask firewalld
      28 tab and select the check box for each type of
      # systemctl disable firewalld
      85 message you want to filter. Clear the check box to disable a filter. This setting is per direction and the default allows everything.
    • To enable inverting the
      # systemctl mask firewalld
      28, click the
      # systemctl mask firewalld
      31 check box on the right. Only marked
      # systemctl disable firewalld
      85 types are now accepted, all other are rejected. In a zone using the DROP target, they are dropped.

    47.11. Setting and controlling IP sets using # systemctl enable firewalld56

    To see the list of IP set types supported by

    # systemctl enable firewalld
    56, enter the following command as root.

    $ firewall-config
    7

    47.11.1. Configuring IP set options using CLI

    IP sets can be used in

    # systemctl enable firewalld
    56 zones as sources and also as sources in rich rules. In Red Hat Enterprise Linux, the preferred method is to use the IP sets created with
    # systemctl enable firewalld
    56 in a direct rule.

    • To list the IP sets known to

      # systemctl enable firewalld
      56 in the permanent environment, use the following command as
      # systemctl stop firewalld
      16:

      $ firewall-config
      8
    • To add a new IP set, use the following command using the permanent environment as

      # systemctl stop firewalld
      16:

      $ firewall-config
      9

      The previous command creates a new IP set with the name test and the

      # systemctl mask firewalld
      40 type for
      # systemctl enable firewalld
      91. To create an IP set for use with
      # systemctl enable firewalld
      92, add the
      # systemctl mask firewalld
      43 option. To make the new setting effective in the runtime environment, reload
      # systemctl enable firewalld
      56.

    • List the new IP set with the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      00
    • To get more information about the IP set, use the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      01

      Note that the IP set does not have any entries at the moment.

    • To add an entry to the test IP set, use the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      02

      The previous command adds the IP address 192.168.0.1 to the IP set.

    • To get the list of current entries in the IP set, use the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      03
    • Generate a file containing a list of IP addresses, for example:

      # systemctl enable firewalld
      04

      The file with the list of IP addresses for an IP set should contain an entry per line. Lines starting with a hash, a semi-colon, or empty lines are ignored.

    • To add the addresses from the iplist.txt file, use the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      05
    • To see the extended entries list of the IP set, use the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      06
    • To remove the addresses from the IP set and to check the updated entries list, use the following commands as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      07
    • You can add the IP set as a source to a zone to handle all traffic coming in from any of the addresses listed in the IP set with a zone. For example, to add the test IP set as a source to the drop zone to drop all packets coming from all entries listed in the test IP set, use the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      08

      The

      # systemctl mask firewalld
      53 prefix in the source shows
      # systemctl enable firewalld
      56 that the source is an IP set and not an IP address or an address range.

    Only the creation and removal of IP sets is limited to the permanent environment, all other IP set options can be used also in the runtime environment without the

    # systemctl disable firewalld
    19 option.

    Warning

    Red Hat does not recommend using IP sets that are not managed through

    # systemctl enable firewalld
    56. To use such IP sets, a permanent direct rule is required to reference the set, and a custom service must be added to create these IP sets. This service needs to be started before
    # systemctl enable firewalld
    56 starts, otherwise
    # systemctl enable firewalld
    56 is not able to add the direct rules using these sets. You can add permanent direct rules with the
    # systemctl mask firewalld
    59 file.

    47.12. Prioritizing rich rules

    By default, rich rules are organized based on their rule action. For example,

    # systemctl mask firewalld
    60 rules have precedence over
    # systemctl mask firewalld
    61 rules. The
    # systemctl mask firewalld
    62 parameter in rich rules provides administrators fine-grained control over rich rules and their execution order.

    47.12.1. How the priority parameter organizes rules into different chains

    You can set the

    # systemctl mask firewalld
    62 parameter in a rich rule to any number between
    # systemctl mask firewalld
    64 and
    # systemctl mask firewalld
    65, and lower values have higher precedence.

    The

    # systemctl enable firewalld
    56 service organizes rules based on their priority value into different chains:

    • Priority lower than 0: the rule is redirected into a chain with the
      # systemctl mask firewalld
      67 suffix.
    • Priority higher than 0: the rule is redirected into a chain with the
      # systemctl mask firewalld
      68 suffix.
    • Priority equals 0: based on the action, the rule is redirected into a chain with the
      # systemctl mask firewalld
      69,
      # systemctl mask firewalld
      70, or
      # systemctl mask firewalld
      71 the action.

    Inside these sub-chains,

    # systemctl enable firewalld
    56 sorts the rules based on their priority value.

    47.12.2. Setting the priority of a rich rule

    The procedure describes an example of how to create a rich rule that uses the

    # systemctl mask firewalld
    62 parameter to log all traffic that is not allowed or denied by other rules. You can use this rule to flag unexpected traffic.

    Procedure

    1. Add a rich rule with a very low precedence to log all traffic that has not been matched by other rules:

      # systemctl enable firewalld
      09

      The command additionally limits the number of log entries to

      # systemctl mask firewalld
      74 per minute.

    2. Optionally, display the

      # systemctl enable firewalld
      60 rule that the command in the previous step created:

      # systemctl enable firewalld
      10

    47.13. Configuring firewall lockdown

    Local applications or services are able to change the firewall configuration if they are running as

    # systemctl stop firewalld
    16 (for example, libvirt). With this feature, the administrator can lock the firewall configuration so that either no applications or only applications that are added to the lockdown allow list are able to request firewall changes. The lockdown settings default to disabled. If enabled, the user can be sure that there are no unwanted configuration changes made to the firewall by local applications or services.

    47.13.1. Configuring lockdown using CLI

    This procedure describes how to enable or disable lockdown using the command line.

    • To query whether lockdown is enabled, use the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      11

      The command prints

      # systemctl disable firewalld
      65 with exit status
      # systemctl disable firewalld
      66 if lockdown is enabled. It prints
      # systemctl disable firewalld
      67 with exit status
      # systemctl disable firewalld
      68 otherwise.

    • To enable lockdown, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      12
    • To disable lockdown, use the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      13

    47.13.2. Configuring lockdown allowlist options using CLI

    The lockdown allowlist can contain commands, security contexts, users and user IDs. If a command entry on the allowlist ends with an asterisk "*", then all command lines starting with that command will match. If the "*" is not there then the absolute command including arguments must match.

    • The context is the security (SELinux) context of a running application or service. To get the context of a running application use the following command:

      # systemctl enable firewalld
      14

      That command returns all running applications. Pipe the output through the grep tool to get the application of interest. For example:

      # systemctl enable firewalld
      15
    • To list all command lines that are in the allowlist, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      16
    • To add a command command to the allowlist, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      17
    • To remove a command command from the allowlist, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      18
    • To query whether the command command is in the allowlist, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      19

      The command prints

      # systemctl disable firewalld
      65 with exit status
      # systemctl disable firewalld
      66 if true. It prints
      # systemctl disable firewalld
      67 with exit status
      # systemctl disable firewalld
      68 otherwise.

    • To list all security contexts that are in the allowlist, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      20
    • To add a context context to the allowlist, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      21
    • To remove a context context from the allowlist, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      22
    • To query whether the context context is in the allowlist, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      23

      Prints

      # systemctl disable firewalld
      65 with exit status
      # systemctl disable firewalld
      66, if true, prints
      # systemctl disable firewalld
      67 with exit status
      # systemctl disable firewalld
      68 otherwise.

    • To list all user IDs that are in the allowlist, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      24
    • To add a user ID uid to the allowlist, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      25
    • To remove a user ID uid from the allowlist, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      26
    • To query whether the user ID uid is in the allowlist, enter the following command:

      # systemctl enable firewalld
      27

      Prints

      # systemctl disable firewalld
      65 with exit status
      # systemctl disable firewalld
      66, if true, prints
      # systemctl disable firewalld
      67 with exit status
      # systemctl disable firewalld
      68 otherwise.

    • To list all user names that are in the allowlist, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      28
    • To add a user name user to the allowlist, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      29
    • To remove a user name user from the allowlist, enter the following command as

      # systemctl stop firewalld
      16:

      # systemctl enable firewalld
      30
    • To query whether the user name user is in the allowlist, enter the following command:

      # systemctl enable firewalld
      31

      Prints

      # systemctl disable firewalld
      65 with exit status
      # systemctl disable firewalld
      66, if true, prints
      # systemctl disable firewalld
      67 with exit status
      # systemctl disable firewalld
      68 otherwise.

    47.13.3. Configuring lockdown allowlist options using configuration files

    The default allowlist configuration file contains the

    # systemctl enable firewalld
    78 context and the default context of
    # firewall-cmd --check-config
    success
    15. The user ID 0 is also on the list.

    + The allowlist configuration files are stored in the

    # firewall-cmd --check-config
    success
    16 directory.

    # systemctl enable firewalld
    32

    Following is an example allowlist configuration file enabling all commands for the

    # systemctl enable firewalld
    82 utility, for a user called user whose user ID is
    # firewall-cmd --check-config
    success
    18:

    # systemctl enable firewalld
    33

    This example shows both

    # firewall-cmd --check-config
    success
    19 and
    # firewall-cmd --check-config
    success
    20, but only one option is required. Python is the interpreter and is prepended to the command line. You can also use a specific command, for example:

    # systemctl enable firewalld
    34

    In that example, only the

    # firewall-cmd --check-config
    success
    21 command is allowed.

    In Red Hat Enterprise Linux, all utilities are placed in the

    # firewall-cmd --check-config
    success
    22 directory and the
    # firewall-cmd --check-config
    success
    23 directory is sym-linked to the
    # firewall-cmd --check-config
    success
    22 directory. In other words, although the path for
    # systemctl enable firewalld
    82 when entered as
    # systemctl stop firewalld
    16 might resolve to
    # firewall-cmd --check-config
    success
    27,
    # firewall-cmd --check-config
    success
    28 can now be used. All new scripts should use the new location. But be aware that if scripts that run as
    # systemctl stop firewalld
    16 are written to use the
    # firewall-cmd --check-config
    success
    27 path, then that command path must be added in the allowlist in addition to the
    # firewall-cmd --check-config
    success
    28 path traditionally used only for non-
    # systemctl stop firewalld
    16 users.

    The

    # firewall-cmd --check-config
    success
    33 at the end of the name attribute of a command means that all commands that start with this string match. If the
    # firewall-cmd --check-config
    success
    33 is not there then the absolute command including arguments must match.

    47.14. Enabling traffic forwarding between different interfaces or sources within a firewalld zone

    Intra-zone forwarding is a

    # systemctl enable firewalld
    56 feature that enables traffic forwarding between interfaces or sources within a
    # systemctl enable firewalld
    56 zone.

    47.14.1. The difference between intra-zone forwarding and zones with the default target set to ACCEPT

    When intra-zone forwarding is enabled, the traffic within a single

    # systemctl enable firewalld
    56 zone can flow from one interface or source to another interface or source. The zone specifies the trust level of interfaces and sources. If the trust level is the same, communication between interfaces or sources is possible.

    Note that, if you enable intra-zone forwarding in the default zone of

    # systemctl enable firewalld
    56, it applies only to the interfaces and sources added to the current default zone.

    The

    # systemctl enable firewalld
    99 zone of
    # systemctl enable firewalld
    56 uses a default target set to
    # systemctl disable firewalld
    34. This zone accepts all forwarded traffic, and intra-zone forwarding is not applicable for it.

    As for other default target values, forwarded traffic is dropped by default, which applies to all standard zones except the trusted zone.

    47.14.2. Using intra-zone forwarding to forward traffic between an Ethernet and Wi-Fi network

    You can use intra-zone forwarding to forward traffic between interfaces and sources within the same

    # systemctl enable firewalld
    56 zone. For example, use this feature to forward traffic between an Ethernet network connected to
    # firewall-cmd --check-config
    success
    43 and a Wi-Fi network connected to
    # firewall-cmd --check-config
    success
    44.

    Procedure

    1. Enable packet forwarding in the kernel:

      # systemctl enable firewalld
      35
    2. Ensure that interfaces between which you want to enable intra-zone forwarding are not assigned to a zone different than the

      # systemctl enable firewalld
      97 zone:

      # systemctl enable firewalld
      36
    3. If the interface is currently assigned to a zone other than

      # systemctl enable firewalld
      97, reassign it:

      # systemctl enable firewalld
      37
    4. Add the

      # firewall-cmd --check-config
      success
      43 and
      # firewall-cmd --check-config
      success
      44 interfaces to the
      # systemctl enable firewalld
      97 zone:

      # systemctl enable firewalld
      38
    5. Enable intra-zone forwarding:

      # systemctl enable firewalld
      39

    Verification

    The following verification steps require that the

    # firewall-cmd --check-config
    success
    50 package is installed on both hosts.

    1. Log in to a host that is in the same network as the
      # firewall-cmd --check-config
      success
      43 interface of the host you enabled zone forwarding on.
    2. Start an echo service with

      # firewall-cmd --check-config
      success
      52 to test connectivity:

      # systemctl enable firewalld
      40
    3. Log in to a host that is in the same network as the
      # firewall-cmd --check-config
      success
      44 interface.
    4. Connect to the echo server running on the host that is in the same network as the

      # firewall-cmd --check-config
      success
      43:

      # systemctl enable firewalld
      41
    5. Type something and press Enter, and verify the text is sent back.

    Additional resources

    • # systemctl disable firewalld
      55 man page

    47.15. Configuring # systemctl enable firewalld56 using System Roles

    You can use the

    # systemctl stop firewalld
    36 System Role to configure settings of the
    # systemctl enable firewalld
    56 service on multiple clients at once. This solution:

    • Provides an interface with efficient input settings.
    • Keeps all intended
      # systemctl enable firewalld
      56 parameters in one place.

    After you run the

    # systemctl stop firewalld
    36 role on the control node, the System Role applies the
    # systemctl enable firewalld
    56 parameters to the managed node immediately and makes them persistent across reboots.

    47.15.1. Introduction to the # systemctl stop firewalld36 RHEL System Role

    RHEL System Roles is a set of contents for the Ansible automation utility. This content together with the Ansible automation utility provides a consistent configuration interface to remotely manage multiple systems.

    The

    # firewall-cmd --check-config
    success
    63 role from the RHEL System Roles was introduced for automated configurations of the
    # systemctl enable firewalld
    56 service. The
    # firewall-cmd --check-config
    success
    65 package contains this System Role, and also the reference documentation.

    To apply the

    # systemctl enable firewalld
    56 parameters on one or more systems in an automated fashion, use the
    # systemctl stop firewalld
    36 System Role variable in a playbook. A playbook is a list of one or more plays that is written in the text-based YAML format.

    You can use an inventory file to define a set of systems that you want Ansible to configure.

    With the

    # systemctl stop firewalld
    36 role you can configure many different
    # systemctl enable firewalld
    56 parameters, for example:

    • Zones.
    • The services for which packets should be allowed.
    • Granting, rejection, or dropping of traffic access to ports.
    • Forwarding of ports or port ranges for a zone.

    Additional resources

    • # firewall-cmd --check-config
      success
      70 and
      # firewall-cmd --check-config
      success
      71 files in the
      # firewall-cmd --check-config
      success
      72 directory
    • Working with playbooks
    • How to build your inventory

    47.15.2. Resetting the firewalld settings using the firewall RHEL System Role

    With the

    # systemctl stop firewalld
    36 RHEL system role, you can reset the
    # systemctl enable firewalld
    56 settings to their default state. If you add the
    # firewall-cmd --check-config
    success
    75 parameter to the variable list, the System Role removes all existing user-defined settings and resets
    # systemctl enable firewalld
    56 to the defaults. If you combine the
    # firewall-cmd --check-config
    success
    75 parameter with other settings, the
    # systemctl stop firewalld
    36 role removes all existing settings before applying new ones.

    Run this procedure on Ansible control node.

    Prerequisites

    • The
      # firewall-cmd --check-config
      success
      79 and
      # firewall-cmd --check-config
      success
      65 packages are installed on the control node.
    • If you use a different remote user than root when you run the playbook, you must have appropriate sudo permissions on the managed node.
    • One or more managed nodes that you configure with the
      # systemctl stop firewalld
      36 RHEL System Role.

    Procedure

    1. If the host on which you want to execute the instructions in the playbook is not yet inventoried, add the IP or name of this host to the

      # firewall-cmd --check-config
      success
      82 Ansible inventory file:

      # systemctl enable firewalld
      42
    2. Create the

      # firewall-cmd --check-config
      success
      83 playbook with the following content:

      # systemctl enable firewalld
      43
    3. Run the playbook:

      1. To connect as root user to the managed node:

        # systemctl enable firewalld
        44
      2. To connect as a user to the managed node:

        # systemctl enable firewalld
        45

        The

        # firewall-cmd --check-config
        success
        84 option makes sure that the
        # firewall-cmd --check-config
        success
        85 command prompts for the sudo password of the user defined in the
        # firewall-cmd --check-config
        success
        86 option.

    If you do not specify the

    # firewall-cmd --check-config
    success
    86 option,
    # firewall-cmd --check-config
    success
    85 connects to the managed node as the user that is currently logged in to the control node.

    Verification

    • Run this command as root on the managed node to check all the zones:

      # systemctl enable firewalld
      46

    Additional resources

    • # firewall-cmd --check-config
      success
      89
    • # firewall-cmd --check-config
      success
      90
    • # firewall-cmd --check-config
      success
      91

    47.15.3. Forwarding incoming traffic from one local port to a different local port

    With the

    # systemctl stop firewalld
    36 role you can remotely configure
    # systemctl enable firewalld
    56 parameters with persisting effect on multiple managed hosts.

    Perform this procedure on the Ansible control node.

    Prerequisites

    • You have prepared the control node and the managed nodes
    • You are logged in to the control node as a user who can run playbooks on the managed nodes.
    • The account you use to connect to the managed nodes has
      # firewall-cmd --check-config
      success
      94 permissions on the them.
    • The hosts or host groups on which you want run this playbook are listed in the Ansible inventory file.

    Procedure

    1. Create a playbook file, for example

      # firewall-cmd --check-config
      success
      95, with the following content:

      # systemctl enable firewalld
      47
    2. Run the playbook:

      # systemctl enable firewalld
      48

    Verification

    • On the managed host, display the

      # systemctl enable firewalld
      56 settings:

      # systemctl enable firewalld
      49

    Additional resources

    • # firewall-cmd --check-config
      success
      89

    47.15.4. Configuring ports using System Roles

    You can use the RHEL

    # systemctl stop firewalld
    36 System Role to open or close ports in the local firewall for incoming traffic and make the new configuration persist across reboots. The example describes how to configure the default zone to permit incoming traffic for the HTTPS service.

    Perform this procedure on the Ansible control node.

    Prerequisites

    • You have prepared the control node and the managed nodes
    • You are logged in to the control node as a user who can run playbooks on the managed nodes.
    • The account you use to connect to the managed nodes has
      # firewall-cmd --check-config
      success
      94 permissions on the them.
    • The hosts or host groups on which you want run this playbook are listed in the Ansible inventory file.

    Procedure

    1. Create a playbook file, for example

      # firewall-cmd --check-config
      Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
      00, with the following content:

      # systemctl enable firewalld
      50

      The

      # firewall-cmd --check-config
      Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
      01 option makes the new settings persistent across reboots.

    2. Run the playbook:

      # systemctl enable firewalld
      51

    Verification

    • On the managed node, verify that the

      # firewall-cmd --check-config
      Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
      02 port associated with the
      # firewall-cmd --check-config
      Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
      03 service is open:

      What are two layer 2 firewall filter types?

      Two-Color and Three-Color Logical Interface Policers..
      Two-Color and Three-Color Physical Interface Policers..

      What is a firewall filter?

      A packet filtering firewall is a network security feature that controls the flow of incoming and outgoing network data. The firewall examines each packet, which comprises user data and control information, and tests them according to a set of pre-established rules.

      Which routing instance type is used for filter based forwarding applications?

      VRF. The VRF instance type is used when creating an L3VPN. This is a VRF (VPN Routing and Forwarding) in the traditional sense of the term.

      What is a valid action for firewall filter?

      Actions include accept, reject, discard, log, count, sample, next-term, and others. The 'reject' action will deny a packet and send an ICMP response. The 'discard' action will deny a packet silently.