- 17.1. Prerequisites
- 17.2. Setting up the bridge on the authenticator
- 17.3. Certificate requirements by FreeRADIUS
- 17.4. Creating a set of certificates on a FreeRADIUS server for testing purposes
- 17.5. Configuring FreeRADIUS to authenticate network clients securely using EAP
- 17.6. Configuring hostapd as an authenticator in a wired network
- 17.7. Testing EAP-TTLS authentication against a FreeRADIUS server or authenticator
- 17.8. Testing EAP-TLS authentication against a FreeRADIUS server or authenticator
- 17.9. Blocking and allowing traffic based on hostapd authentication events
- 18.1. Configuring 802.1X network authentication on an existing Ethernet connection using nmcli
- 18.2. Configuring a static Ethernet connection with 802.1X network authentication using nmstatectl
- 18.3. Configuring a static Ethernet connection with 802.1X network authentication using RHEL System Roles
- 19.1. Setting the default gateway on an existing connection using nmcli
- 19.2. Setting the default gateway on an existing connection using the nmcli interactive mode
- 19.3. Setting the default gateway on an existing connection using nm-connection-editor
- 19.4. Setting the default gateway on an existing connection using control-center
- 19.5. Setting the default gateway on an existing connection using nmstatectl
- 19.6. Setting the default gateway on an existing connection using RHEL System Roles
- 19.7. Setting the default gateway on an existing connection when using the legacy network scripts
- 19.8. How NetworkManager manages multiple default gateways
- 19.9. Configuring NetworkManager to avoid using a specific profile to provide a default gateway
- 19.10. Fixing unexpected routing behavior due to multiple default gateways
- 20.1. Example of a network that requires static routes
- 20.2. How to use the nmcli command to configure a static route
- 20.3. Configuring a static route using an nmcli command
- 20.4. Configuring a static route using nmtui
- 20.5. Configuring a static route using control-center
- 20.6. Configuring a static route using nm-connection-editor
- 20.7. Configuring a static route using the nmcli interactive mode
- 20.8. Configuring a static route using nmstatectl
- 20.9. Configuring a static route using RHEL System Roles
- 20.10. Creating static routes configuration files in key-value format when using the legacy network scripts
- 20.11. Creating static routes configuration files in ip-command format when using the legacy network scripts
- 21.1. Routing traffic from a specific subnet to a different default gateway using NetworkManager
- 21.2. Routing traffic from a specific subnet to a different default gateway using RHEL System Roles
- 21.3. Overview of configuration files involved in policy-based routing when using the legacy network scripts
- 21.4. Routing traffic from a specific subnet to a different default gateway using the legacy network scripts
- 22.1. Creating a dummy interface with both an IPv4 and IPv6 address using nmcli
- 23.1. Using nmstate-autoconf to automatically configure network interfaces
- 24.1. Debugging an incorrect VLAN configuration using LLDP information
- 25.1. The keyfile format of NetworkManager profiles
- 25.2. Creating a NetworkManager profile in keyfile format
- 25.3. Migrating NetworkManager profiles from ifcfg to keyfile format
- 25.4. Using nmcli to create keyfile connection profiles in offline mode
- 26.1. Configuring the netconsole service to log kernel messages to a remote host
- 27.1. Differences between the network and network-online systemd target
- 27.2. Overview of NetworkManager-wait-online
- 27.3. Configuring a systemd service to start after the network has been started
- 28.1. Overview of queuing disciplines
- 28.2. Available qdiscs in RHEL
- 28.3. Inspecting qdiscs of a network interface using the tc utility
- 28.4. Updating the default qdisc
- 28.5. Temporarily setting the current qdisk of a network interface using the tc utility
- 28.6. Permanently setting the current qdisk of a network interface using NetworkManager
- 29.1. Understanding MPTCP
- 29.2. Preparing RHEL to enable MPTCP support
- 29.3. Using iproute2 to temporarily configure and enable multiple paths for MPTCP applications
- 29.4. Permanently configuring multiple paths for MPTCP applications
- 29.5. Monitoring MPTCP sub-flows
- 29.6. Disabling Multipath TCP in the kernel
- 30.1. How NetworkManager orders DNS servers in /etc/resolv.conf
- 30.2. Setting a NetworkManager-wide default DNS server priority value
- 30.3. Setting the DNS priority of a NetworkManager connection
- 31.1. Configuring an interface with static network settings using ifcfg files
- 31.2. Configuring an interface with dynamic network settings using ifcfg files
- 31.3. Managing system-wide and private connection profiles with ifcfg files
- 32.1. Disabling IPv6 on a connection using nmcli
- 33.1. Disabling DNS processing in the NetworkManager configuration
- 33.2. Replacing /etc/resolv.conf with a symbolic link to manually configure DNS settings
- 34.1. Displaying the number of dropped packets
- 34.2. Increasing the ring buffers to reduce a high packet drop rate
- 35.1. Understanding Auto-negotiation
- 35.2. Configuring 802.3 link settings using the nmcli utility
- 36.1. Offload features supported by NetworkManager
- 36.2. Configuring an ethtool offload feature using NetworkManager
- 36.3. Using RHEL System Roles to set ethtool features
- 37.1. Coalesce settings supported by NetworkManager
- 37.2. Configuring ethtool coalesce settings using NetworkManager
- 37.3. Using RHEL System Roles to configure ethtool coalesce settings
- 38.1. Configuring a MACsec connection using nmcli
- 38.2. Additional resources
- 39.1. Sending DNS requests for a specific domain to a selected DNS server
- 40.1. IPVLAN modes
- 40.2. Comparison of IPVLAN and MACVLAN
- 40.3. Creating and configuring the IPVLAN device using iproute2
- 41.1. Permanently reusing the same IP address on different interfaces
- 41.2. Temporarily reusing the same IP address on different interfaces
- 41.3. Additional resources
- 42.1. Configuring a VRF device
- 42.2. Starting a service within an isolated VRF network
- 43.1. The concept of NetworkManager dispatcher scripts
- 43.2. Creating a NetworkManager dispatcher script that runs dhclient exit hooks
- 44.1. Debugging levels and domains
- 44.2. Setting the NetworkManager log level
- 44.3. Temporarily setting log levels at run time using nmcli
- 44.4. Viewing NetworkManager logs
- 45.1. Using the libnmstate library in a Python application
- 45.2. Updating the current network configuration using nmstatectl
- 45.3. Network states for the network RHEL System role
- 45.4. Additional resources
- 46.1. Using xdpdump to capture network packets including packets dropped by XDP programs
- 46.2. Additional resources
- 47.1. Getting started with firewalldExpand section "47.1. Getting started with firewalld" Collapse section "47.1. Getting started with firewalld"
- 47.1.1. When to use firewalld, nftables, or iptables
- 47.1.2. Zones
- 47.1.3. Predefined services
- 47.1.4. Starting firewalld
- 47.1.5. Stopping firewalld
- 47.1.6. Verifying the permanent firewalld configuration
- 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"
- 47.2.1. Viewing the current status of firewalld
- 47.2.2. Viewing allowed services using GUI
- 47.2.3. Viewing firewalld settings using CLI
- 47.3. Controlling network traffic using firewalldExpand section "47.3. Controlling network traffic using firewalld" Collapse section "47.3. Controlling network traffic using firewalld"
- 47.3.1. Disabling all traffic in case of emergency using CLI
- 47.3.2. Controlling traffic with predefined services using CLI
- 47.3.3. Controlling traffic with predefined services using GUI
- 47.3.4. Adding new services
- 47.3.5. Opening ports using GUI
- 47.3.6. Controlling traffic with protocols using GUI
- 47.3.7. Opening source ports using GUI
- 47.4. Controlling ports using CLIExpand section "47.4. Controlling ports using CLI" Collapse section "47.4. Controlling ports using CLI"
- 47.4.1. Opening a port
- 47.4.2. Closing a port
- 47.5. Working with firewalld zonesExpand section "47.5. Working with firewalld zones" Collapse section "47.5. Working with firewalld zones"
- 47.5.1. Listing zones
- 47.5.2. Modifying firewalld settings for a certain zone
- 47.5.3. Changing the default zone
- 47.5.4. Assigning a network interface to a zone
- 47.5.5. Assigning a zone to a connection using nmcli
- 47.5.6. Manually assigning a zone to a network connection in an ifcfg file
- 47.5.7. Creating a new zone
- 47.5.8. Zone configuration files
- 47.5.9. Using zone targets to set default behavior for incoming traffic
- 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"
- 47.6.1. Adding a source
- 47.6.2. Removing a source
- 47.6.3. Adding a source port
- 47.6.4. Removing a source port
- 47.6.5. Using zones and sources to allow a service for only a specific domain
- 47.7. Filtering forwarded traffic between zonesExpand section "47.7. Filtering forwarded traffic between zones" Collapse section "47.7. Filtering forwarded traffic between zones"
- 47.7.1. The relationship between policy objects and zones
- 47.7.2. Using priorities to sort policies
- 47.7.3. Using policy objects to filter traffic between locally hosted Containers and a network physically connected to the host
- 47.7.4. Setting the default target of policy objects
- 47.8. Configuring NAT using firewalldExpand section "47.8. Configuring NAT using firewalld" Collapse section "47.8. Configuring NAT using firewalld"
- 47.8.1. NAT types
- 47.8.2. Configuring IP address masquerading
- 47.9. Using DNAT to forward HTTPS traffic to a different host
- 47.10. Managing ICMP requestsExpand section "47.10. Managing ICMP requests" Collapse section "47.10. Managing ICMP requests"
- 47.10.1. Listing and blocking ICMP requests
- 47.10.2. Configuring the ICMP filter using GUI
- 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"
- 47.11.1. Configuring IP set options using CLI
- 47.12. Prioritizing rich rulesExpand section "47.12. Prioritizing rich rules" Collapse section "47.12. Prioritizing rich rules"
- 47.12.1. How the priority parameter organizes rules into different chains
- 47.12.2. Setting the priority of a rich rule
- 47.13. Configuring firewall lockdownExpand section "47.13. Configuring firewall lockdown" Collapse section "47.13. Configuring firewall lockdown"
- 47.13.1. Configuring lockdown using CLI
- 47.13.2. Configuring lockdown allowlist options using CLI
- 47.13.3. Configuring lockdown allowlist options using configuration files
- 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"
- 47.14.1. The difference between intra-zone forwarding and zones with the default target set to ACCEPT
- 47.14.2. Using intra-zone forwarding to forward traffic between an Ethernet and Wi-Fi network
- 47.15. Configuring firewalld using System RolesExpand section "47.15. Configuring firewalld using System Roles" Collapse section "47.15. Configuring firewalld using System Roles"
- 47.15.1. Introduction to the firewall RHEL System Role
- 47.15.2. Resetting the firewalld settings using the firewall RHEL System Role
- 47.15.3. Forwarding incoming traffic from one local port to a different local port
- 47.15.4. Configuring ports using System Roles
- 47.15.5. Configuring a DMZ firewalld zone by using the firewalld RHEL System Role
- 47.16. Additional resources
- 48.1. Migrating from iptables to nftablesExpand section "48.1. Migrating from iptables to nftables" Collapse section "48.1. Migrating from iptables to nftables"
- 48.1.1. When to use firewalld, nftables, or iptables
- 48.1.2. Converting iptables and ip6tables rule sets to nftables
- 48.1.3. Converting single iptables and ip6tables rules to nftables
- 48.1.4. Comparison of common iptables and nftables commands
- 48.1.5. Additional resources
- 48.2. Writing and executing nftables scriptsExpand section "48.2. Writing and executing nftables scripts" Collapse section "48.2. Writing and executing nftables scripts"
- 48.2.1. Supported nftables script formats
- 48.2.2. Running nftables scripts
- 48.2.3. Using comments in nftables scripts
- 48.2.4. Using variables in nftables script
- 48.2.5. Including files in nftables scripts
- 48.2.6. Automatically loading nftables rules when the system boots
- 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"
- 48.3.1. Basics of nftables tables
- 48.3.2. Basics of nftables chains
- 48.3.3. Basics of nftables rules
- 48.3.4. Managing tables, chains, and rules using nft commands
- 48.4. Configuring NAT using nftablesExpand section "48.4. Configuring NAT using nftables" Collapse section "48.4. Configuring NAT using nftables"
- 48.4.1. NAT types
- 48.4.2. Configuring masquerading using nftables
- 48.4.3. Configuring source NAT using nftables
- 48.4.4. Configuring destination NAT using nftables
- 48.4.5. Configuring a redirect using nftables
- 48.5. Using sets in nftables commandsExpand section "48.5. Using sets in nftables commands" Collapse section "48.5. Using sets in nftables commands"
- 48.5.1. Using anonymous sets in nftables
- 48.5.2. Using named sets in nftables
- 48.5.3. Additional resources
- 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"
- 48.6.1. Using anonymous maps in nftables
- 48.6.2. Using named maps in nftables
- 48.6.3. Additional resources
- 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"
- 48.7.1. Network conditions
- 48.7.2. Security requirements to the firewall script
- 48.7.3. Configuring logging of dropped packets to a file
- 48.7.4. Writing and activating the nftables script
- 48.8. Configuring port forwarding using nftablesExpand section "48.8. Configuring port forwarding using nftables" Collapse section "48.8. Configuring port forwarding using nftables"
- 48.8.1. Forwarding incoming packets to a different local port
- 48.8.2. Forwarding incoming packets on a specific local port to a different host
- 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"
- 48.9.1. Limiting the number of connections using nftables
- 48.9.2. Blocking IP addresses that attempt more than ten new incoming TCP connections within one minute
- 48.10. Debugging nftables rulesExpand section "48.10. Debugging nftables rules" Collapse section "48.10. Debugging nftables rules"
- 48.10.1. Creating a rule with a counter
- 48.10.2. Adding a counter to an existing rule
- 48.10.3. Monitoring packets that match an existing rule
- 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"
- 48.11.1. Backing up the nftables rule set to a file
- 48.11.2. Restoring the nftables rule set from a file
- 48.12. Additional resources
- 49.1. Dropping network packets that match an xdp-filter rule
- 49.2. Dropping all network packets except the ones that match an xdp-filter rule
- 50.1. Installing the dpdk package
- 50.2. Additional resources
- 51.1. Overview of networking eBPF features in RHEL 8
- 51.2. Overview of XDP features in RHEL 8 by network cards
- 52.1. An introduction to BCC
- 52.2. Installing the bcc-tools package
- 52.3. Displaying TCP connections added to the Kernel’s accept queue
- 52.4. Tracing outgoing TCP connection attempts
- 52.5. Measuring the latency of outgoing TCP connections
- 52.6. Displaying details about TCP packets and segments that were dropped by the kernel
- 52.7. Tracing TCP sessions
- 52.8. Tracing TCP retransmissions
- 52.9. Displaying TCP state change information
- 52.10. Summarizing and aggregating TCP traffic sent to specific subnets
- 52.11. Displaying the network throughput by IP address and port
- 52.12. Tracing established TCP connections
- 52.13. Tracing IPv4 and IPv6 listen attempts
- 52.14. Summarizing the service time of soft interrupts
- 52.15. Additional resources
- 53.1. The architecture of TIPC
- 53.2. Loading the tipc module when the system boots
- 53.3. Creating a TIPC network
- 53.4. Additional resources
- 54.1. Configuring and pre-deploying nm-cloud-setup
- Language: Language:
- 简体中文
- 한국어
- 日本語
- English
- Español
- Português
- Format: Format:
- Multi-page
- Single-page
- ePub
Language and Page Formatting Options
- Language: Language:
- 简体中文
- 한국어
- 日本語
- English
- Español
- Português
- Format: Format:
- Multi-page
- Single-page
- 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 firewalld56 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 firewalld56 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 firewalld56 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 firewalld56 with
# systemctl enable firewalld60 backend does not support passing custom
# systemctl enable firewalld60 rules to
# systemctl enable firewalld56, using the
# systemctl enable firewalld63 option.
47.1. Getting started with # systemctl enable firewalld
56
This section provides information about
# systemctl enable firewalld56.
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 firewalld56 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 firewalld78 notifies
# systemctl enable firewalld56 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 firewalld78 configuration files. If you change the zone of the interface using the web console,
# systemctl enable firewalld82 or
# systemctl enable firewalld81, the request is forwarded to
# systemctl enable firewalld78 and is not handled by
# systemctl enable firewalld56.
The predefined zones are stored in the
# systemctl enable firewalld88 directory and can be instantly applied to any available network interface. These files are copied to the
# systemctl enable firewalld89 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 firewalld91 and icmp6-adm-prohibited for
# systemctl enable firewalld92. Only network connections initiated from within the system are possible.
# systemctl enable firewalld93For computers in your demilitarized zone that are publicly-accessible with limited access to your internal network. Only selected incoming connections are accepted.
# systemctl enable firewalld94Any incoming network packets are dropped without any notification. Only outgoing network connections are possible.
# systemctl enable firewalld95For 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 firewalld96For use at home when you mostly trust the other computers on the network. Only selected incoming connections are accepted.
# systemctl enable firewalld97For use on internal networks when you mostly trust the other computers on the network. Only selected incoming connections are accepted.
# systemctl enable firewalld98For use in public areas where you do not trust other computers on the network. Only selected incoming connections are accepted.
# systemctl enable firewalld99All network connections are accepted.
# systemctl stop firewalld00For 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 firewalld78, they are assigned to the default zone. On installation, the default zone in
# systemctl enable firewalld56 is set to be the
# systemctl enable firewalld98 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 firewalld05 man page. The services are specified by means of individual XML configuration files, which are named in the following format:
# systemctl stop firewalld06. Protocol names are preferred over service or application names in
# systemctl enable firewalld56.
Services can be added and removed using the graphical
# systemctl enable firewalld81 tool,
# systemctl enable firewalld82, and
# systemctl stop firewalld10.
Alternatively, you can edit the XML files in the
# systemctl stop firewalld11 directory. If a service is not added or changed by the user, then no corresponding XML file is found in
# systemctl stop firewalld11. The files in the
# systemctl stop firewalld13 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
To start
# systemctl enable firewalld
56, enter the following command as# systemctl stop firewalld
16:# systemctl unmask firewalld # systemctl start firewalld
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
To stop
# systemctl enable firewalld
56, enter the following command as# systemctl stop firewalld
16:# systemctl stop firewalld
To prevent
# systemctl enable firewalld
56 from starting automatically at system start:# systemctl disable firewalld
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 firewalld56 configuration files, administrators want to verify that the changes are correct. This section describes how to verify the permanent configuration of the
# systemctl enable firewalld56 service.
Prerequisites
- The
# systemctl enable firewalld
56 service is running.
Procedure
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 firewalld
56
This section covers information about viewing current status, allowed services, and current settings of
# systemctl enable firewalld56.
47.2.1. Viewing the current status of # systemctl enable firewalld
56
The firewall service,
# systemctl enable firewalld56, is installed on the system by default. Use the
# systemctl enable firewalld56 CLI interface to check that the service is running.
Procedure
To see the status of the service:
# firewall-cmd --state
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 firewalld36, and press Enter. The firewall-config tool appears. You can now view the list of services under the
# systemctl stop firewalld37 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 firewalld39 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 firewalld40 option shows a complete overview of the
# systemctl enable firewalld56 settings.
# systemctl enable firewalld56 uses zones to manage the traffic. If a zone is not specified by the
# systemctl stop firewalld43 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
0To 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
1To 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
2To 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 firewalld47 service and
# systemctl enable firewalld56 opens the necessary port [22] for the service. Later, if you list the allowed services, the list shows the
# systemctl stop firewalld47 service, but if you list open ports, it does not show any. Therefore, it is recommended to use the
# systemctl stop firewalld40 option to make sure you receive a complete information.
47.3. Controlling network traffic using # systemctl enable firewalld
56
This section covers information about controlling network traffic using
# systemctl enable firewalld56.
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
To immediately disable networking traffic, switch panic mode on:
# systemctl enable firewalld
4Important
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.
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 firewalld56. This opens all necessary ports and modifies other settings according to the service definition file.
Procedure
Check that the service is not already allowed:
# systemctl enable firewalld
7List all predefined services:
# systemctl enable firewalld
8Add the service to the allowed services:
# systemctl enable firewalld
9Make 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
To enable or disable a predefined or custom service:
- Start the firewall-config tool and select the network zone whose services are to be configured.
- Select the
# systemctl stop firewalld
55 tab and then the# systemctl stop firewalld
37 tab below. - 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.
To edit a service:
- Start the firewall-config tool.
- 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. - Select the service you want to configure.
The
# systemctl stop firewalld59,
# systemctl stop firewalld60, and
# systemctl stop firewalld61 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 firewalld62 tab enables limiting traffic to a particular destination address and Internet Protocol [
# systemctl enable firewalld91 or
# systemctl enable firewalld92].
Note
It is not possible to alter service settings in the
# systemctl stop firewalld65 mode.
47.3.4. Adding new services
Services can be added and removed using the graphical firewall-config tool,
# systemctl enable firewalld82, and
# systemctl stop firewalld10. Alternatively, you can edit the XML files in
# systemctl stop firewalld11. If a service is not added or changed by the user, then no corresponding XML file are found in
# systemctl stop firewalld11. The files
# systemctl stop firewalld13 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 firewalld71 [underscore] and
# systemctl stop firewalld72 [dash] characters.
Procedure
To add a new service in a terminal, use
# systemctl enable firewalld82, or
# systemctl stop firewalld10 in case of not active
# systemctl enable firewalld56.
Enter the following command to add a new and empty service:
# systemctl stop firewalld
1To add a new service using a local file, use the following command:
# systemctl stop firewalld
2You can change the service name with the additional
# systemctl stop firewalld
76 option.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 firewalld56 loads files from
# systemctl stop firewalld80 in the first place. If files are placed in
# systemctl stop firewalld81 and they are valid, then these will override the matching files from
# systemctl stop firewalld80. The overridden files in
# systemctl stop firewalld80 are used as soon as the matching files in
# systemctl stop firewalld81 have been removed or if
# systemctl enable firewalld56 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
- Start the firewall-config tool and select the network zone whose settings you want to change.
- Select the
# systemctl stop firewalld
59 tab and click the Add button on the right-hand side. The# systemctl stop firewalld
88 window opens. - Enter the port number or range of ports to permit.
- 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
- Start the firewall-config tool and select the network zone whose settings you want to change.
- 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. - 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
- Start the firewall-config tool and select the network zone whose settings you want to change.
- 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. - 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 firewalld02 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:
List all allowed ports:
# systemctl stop firewalld
4Add a port to the allowed ports to open it for incoming traffic:
# systemctl stop firewalld
5The 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.Make the new settings persistent:
# systemctl stop firewalld
0The 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 firewalld56. 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:
List all allowed ports:
# systemctl stop firewalld
4Warning
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.Remove the port from the allowed ports to close it for the incoming traffic:
# systemctl stop firewalld
8Make 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
To see which zones are available on your system:
# systemctl disable firewalld
0The
# systemctl disable firewalld
14 command displays all zones that are available on the system, but it does not show any details for particular zones.To see detailed information for all zones:
# systemctl disable firewalld
1To 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 firewalld56 service,
# systemctl enable firewalld56 loads the settings for the default zone and makes it active.
Procedure
To set up the default zone:
Display the current default zone:
# systemctl disable firewalld
4Set the new default zone:
# systemctl disable firewalld
5Note
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:
List the active zones and the interfaces assigned to them:
# systemctl disable firewalld
6Assign 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 firewalld56 zone to a
# systemctl enable firewalld78 connection using the
# systemctl disable firewalld22 utility.
Procedure
Assign the zone to the
# systemctl enable firewalld
78 connection profile:# systemctl disable firewalld
8Activate 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 firewalld19 option, otherwise the command does not work.
Procedure
Create a new zone:
# systemctl mask firewalld
1Check if the new zone is added to your permanent settings:
# systemctl mask firewalld
2Make 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 firewalld56 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 firewalld27 where the length of zone-name is currently limited to 17 chars. The zone configuration files are located in the
# systemctl enable firewalld88 and
# systemctl enable firewalld89 directories.
The following example shows a configuration that allows one service [
# systemctl stop firewalld47] and one port range, for both the
# systemctl disable firewalld31 and
# systemctl disable firewalld32 protocols:
# systemctl mask firewalld4
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:
List the information for the specific zone to see the default target:
# systemctl mask firewalld
5Set 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
7To 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 firewalld99 zone:
Procedure
List all available zones:
# systemctl disable firewalld
0Add the source IP to the trusted zone in the permanent mode:
# firewall-cmd --check-config success
0Make 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
List allowed sources for the required zone:
# firewall-cmd --check-config success
2Remove the source from the zone permanently:
# firewall-cmd --check-config success
3Make 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 firewalld45 option. You can also combine this with the
# systemctl disable firewalld46 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 firewalld47 network while any other traffic is blocked.
Warning
When you configure this scenario, use a zone that has the
# systemctl disable firewalld39 target. Using a zone that has the target set to
# systemctl disable firewalld34 is a security risk, because for traffic from
# systemctl disable firewalld47, all network connections would be accepted.
Procedure
List all available zones:
# firewall-cmd --check-config success
7Add 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
8Add the
# systemctl disable firewalld
52 service to the# systemctl enable firewalld
97 zone:# firewall-cmd --check-config success
9Make 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 firewalld56 and
# systemctl disable firewalld57 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
Create a new policy.
# firewall-cmd --check-config Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
4Block all traffic.
# firewall-cmd --check-config Error: INVALID_PROTOCOL: 'public.xml': 'tcpx' not from {'tcp'|'udp'|'sctp'|'dccp'}
5Note
Red Hat recommends that you block all traffic to the host by default and then selectively open the services you need for the host.
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'}
6Define 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 firewalld56, 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 firewalld62. 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.
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
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
1The 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.To enable IP masquerading, enter the following command as
# systemctl stop firewalld
16:# firewall-cmd --state
2- To make this setting persistent, pass the
# systemctl disable firewalld
19 option to the command. To disable IP masquerading, enter the following command as
# systemctl stop firewalld
16:# firewall-cmd --state
3To 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
Create a firewall policy:
# firewall-cmd --state
4The 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.
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
5The
# 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.Add a rich rule that forwards traffic to the web server:
# firewall-cmd --state
6The 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.Reload the firewall configuration files:
# firewall-cmd --state
7Activate routing of 127.0.0.0/8 in the kernel:
# firewall-cmd --state
8
Verification
Connect to the router’s IP address and port that you have forwarded to the web server:
# firewall-cmd --state
9Optional: 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
0Verify 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 firewalld84 [
# systemctl disable firewalld85] 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 firewalld85 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 firewalld85 messages, especially
# systemctl disable firewalld88 and
# systemctl disable firewalld89, to reveal information about your network and misuse such information for various kinds of fraudulent activities. Therefore,
# systemctl enable firewalld56 enables blocking the
# systemctl disable firewalld85 requests to protect your network information.
47.10.1. Listing and blocking ICMP requests
Listing
# systemctl disable firewalld85 requests
The
# systemctl disable firewalld85 requests are described in individual XML files that are located in the
# systemctl disable firewalld94 directory. You can read these files to see a description of the request. The
# systemctl enable firewalld82 command controls the
# systemctl disable firewalld85 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
2The
# 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
3The 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 firewalld85 requests
When your server blocks
# systemctl disable firewalld85 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 firewalld85 request is being blocked [rejected]. Blocking the
# systemctl disable firewalld85 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
4To 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
6To 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 firewalld85 requests without providing any information at all
Normally, if you block
# systemctl disable firewalld85 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 firewalld85 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 firewalld85 requests, is dropped, except traffic which you have explicitly allowed.
To block and drop certain
# systemctl disable firewalld85 requests and allow others:
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
8Add the ICMP block inversion to block all
# systemctl disable firewalld
85 requests at once:$
0firewall-config
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
6Make the new settings persistent:
# systemctl stop firewalld
0
The block inversion inverts the setting of the
# systemctl disable firewalld85 requests blocks, so all requests, that were not previously blocked, are blocked because of the target of your zone changes to
# systemctl disable firewalld37. 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:
Set the target of your zone to
# systemctl disable firewalld
39 or# systemctl disable firewalld
34:$
3firewall-config
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
7Remove the
# systemctl disable firewalld
85 block inversion:$
5firewall-config
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 firewalld
56
To see the list of IP set types supported by
# systemctl enable firewalld56, enter the following command as root.
$ firewall-config
747.11.1. Configuring IP set options using CLI
IP sets can be used in
# systemctl enable firewalld56 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 firewalld56 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:$
8firewall-config
To add a new IP set, use the following command using the permanent environment as
# systemctl stop firewalld
16:$
9firewall-config
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
00To get more information about the IP set, use the following command as
# systemctl stop firewalld
16:# systemctl enable firewalld
01Note 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
02The 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
03Generate a file containing a list of IP addresses, for example:
# systemctl enable firewalld
04The 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
05To see the extended entries list of the IP set, use the following command as
# systemctl stop firewalld
16:# systemctl enable firewalld
06To 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
07You 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
08The
# 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 firewalld19 option.
Warning
Red Hat does not recommend using IP sets that are not managed through
# systemctl enable firewalld56. 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 firewalld56 starts, otherwise
# systemctl enable firewalld56 is not able to add the direct rules using these sets. You can add permanent direct rules with the
# systemctl mask firewalld59 file.
47.12. Prioritizing rich rules
By default, rich rules are organized based on their rule action. For example,
# systemctl mask firewalld60 rules have precedence over
# systemctl mask firewalld61 rules. The
# systemctl mask firewalld62 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 firewalld62 parameter in a rich rule to any number between
# systemctl mask firewalld64 and
# systemctl mask firewalld65, and lower values have higher precedence.
The
# systemctl enable firewalld56 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 firewalld56 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 firewalld62 parameter to log all traffic that is not allowed or denied by other rules. You can use this rule to flag unexpected traffic.
Procedure
Add a rich rule with a very low precedence to log all traffic that has not been matched by other rules:
# systemctl enable firewalld
09The command additionally limits the number of log entries to
# systemctl mask firewalld
74 per minute.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 firewalld16 [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
11The 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
12To 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
14That command returns all running applications. Pipe the output through the grep tool to get the application of interest. For example:
# systemctl enable firewalld
15To list all command lines that are in the allowlist, enter the following command as
# systemctl stop firewalld
16:# systemctl enable firewalld
16To add a command command to the allowlist, enter the following command as
# systemctl stop firewalld
16:# systemctl enable firewalld
17To remove a command command from the allowlist, enter the following command as
# systemctl stop firewalld
16:# systemctl enable firewalld
18To query whether the command command is in the allowlist, enter the following command as
# systemctl stop firewalld
16:# systemctl enable firewalld
19The 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
20To add a context context to the allowlist, enter the following command as
# systemctl stop firewalld
16:# systemctl enable firewalld
21To remove a context context from the allowlist, enter the following command as
# systemctl stop firewalld
16:# systemctl enable firewalld
22To query whether the context context is in the allowlist, enter the following command as
# systemctl stop firewalld
16:# systemctl enable firewalld
23Prints
# 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
24To add a user ID uid to the allowlist, enter the following command as
# systemctl stop firewalld
16:# systemctl enable firewalld
25To remove a user ID uid from the allowlist, enter the following command as
# systemctl stop firewalld
16:# systemctl enable firewalld
26To query whether the user ID uid is in the allowlist, enter the following command:
# systemctl enable firewalld
27Prints
# 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
28To add a user name user to the allowlist, enter the following command as
# systemctl stop firewalld
16:# systemctl enable firewalld
29To remove a user name user from the allowlist, enter the following command as
# systemctl stop firewalld
16:# systemctl enable firewalld
30To query whether the user name user is in the allowlist, enter the following command:
# systemctl enable firewalld
31Prints
# 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 firewalld78 context and the default context of
# firewall-cmd --check-config success15. The user ID 0 is also on the list.
+ The allowlist configuration files are stored in the
# firewall-cmd --check-config success16 directory.
# systemctl enable firewalld32
Following is an example allowlist configuration file enabling all commands for the
# systemctl enable firewalld82 utility, for a user called user whose user ID is
# firewall-cmd --check-config success18:
# systemctl enable firewalld33
This example shows both
# firewall-cmd --check-config success19 and
# firewall-cmd --check-config success20, 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 firewalld34
In that example, only the
# firewall-cmd --check-config success21 command is allowed.
In Red Hat Enterprise Linux, all utilities are placed in the
# firewall-cmd --check-config success22 directory and the
# firewall-cmd --check-config success23 directory is sym-linked to the
# firewall-cmd --check-config success22 directory. In other words, although the path for
# systemctl enable firewalld82 when entered as
# systemctl stop firewalld16 might resolve to
# firewall-cmd --check-config success27,
# firewall-cmd --check-config success28 can now be used. All new scripts should use the new location. But be aware that if scripts that run as
# systemctl stop firewalld16 are written to use the
# firewall-cmd --check-config success27 path, then that command path must be added in the allowlist in addition to the
# firewall-cmd --check-config success28 path traditionally used only for non-
# systemctl stop firewalld16 users.
The
# firewall-cmd --check-config success33 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 success33 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 firewalld56 feature that enables traffic forwarding between interfaces or sources within a
# systemctl enable firewalld56 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 firewalld56 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 firewalld56, it applies only to the interfaces and sources added to the current default zone.
The
# systemctl enable firewalld99 zone of
# systemctl enable firewalld56 uses a default target set to
# systemctl disable firewalld34. 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 firewalld56 zone. For example, use this feature to forward traffic between an Ethernet network connected to
# firewall-cmd --check-config success43 and a Wi-Fi network connected to
# firewall-cmd --check-config success44.
Procedure
Enable packet forwarding in the kernel:
# systemctl enable firewalld
35Ensure 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
36If the interface is currently assigned to a zone other than
# systemctl enable firewalld
97, reassign it:# systemctl enable firewalld
37Add 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
38Enable intra-zone forwarding:
# systemctl enable firewalld
39
Verification
The following verification steps require that the
# firewall-cmd --check-config success50 package is installed on both hosts.
- 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. Start an echo service with
# firewall-cmd --check-config success
52 to test connectivity:# systemctl enable firewalld
40- Log in to a host that is in the same network as the
# firewall-cmd --check-config success
44 interface. 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- 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 firewalld
56 using System Roles
You can use the
# systemctl stop firewalld36 System Role to configure settings of the
# systemctl enable firewalld56 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 firewalld36 role on the control node, the System Role applies the
# systemctl enable firewalld56 parameters to the managed node immediately and makes them persistent across reboots.
47.15.1. Introduction to the # systemctl stop firewalld
36 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 success63 role from the RHEL System Roles was introduced for automated configurations of the
# systemctl enable firewalld56 service. The
# firewall-cmd --check-config success65 package contains this System Role, and also the reference documentation.
To apply the
# systemctl enable firewalld56 parameters on one or more systems in an automated fashion, use the
# systemctl stop firewalld36 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 firewalld36 role you can configure many different
# systemctl enable firewalld56 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 firewalld36 RHEL system role, you can reset the
# systemctl enable firewalld56 settings to their default state. If you add the
# firewall-cmd --check-config success75 parameter to the variable list, the System Role removes all existing user-defined settings and resets
# systemctl enable firewalld56 to the defaults. If you combine the
# firewall-cmd --check-config success75 parameter with other settings, the
# systemctl stop firewalld36 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
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
42Create the
# firewall-cmd --check-config success
83 playbook with the following content:# systemctl enable firewalld
43Run the playbook:
To connect as root user to the managed node:
# systemctl enable firewalld
44To connect as a user to the managed node:
# systemctl enable firewalld
45The
# 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 success86 option,
# firewall-cmd --check-config success85 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 firewalld36 role you can remotely configure
# systemctl enable firewalld56 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
Create a playbook file, for example
# firewall-cmd --check-config success
95, with the following content:# systemctl enable firewalld
47Run 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 firewalld36 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
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
50The
# 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.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.