5.16. Configuring Firewall Lockdown
			Local applications or services are able to change the firewall configuration if they are running as 
root (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 whitelist 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.
		5.16.1. Configuring Lockdown with the Command-Line Client
Copy linkLink copied to clipboard!
				To query whether lockdown is enabled, use the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
				 The command prints 
root: 
firewall-cmd --query-lockdown
~]# firewall-cmd --query-lockdownyes with exit status 0 if lockdown is enabled. It prints no with exit status 1 otherwise.
			
				To enable lockdown, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
root: 
firewall-cmd --lockdown-on
~]# firewall-cmd --lockdown-on
				To disable lockdown, use the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
root: 
firewall-cmd --lockdown-off
~]# firewall-cmd --lockdown-off5.16.2. Configuring Lockdown Whitelist Options with the Command-Line Client
Copy linkLink copied to clipboard!
				The lockdown whitelist can contain commands, security contexts, users and user IDs. If a command entry on the whitelist 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: 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
				 That command returns all running applications. Pipe the output through the grep tool to get the application of interest. For example: 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
ps -e --context
~]$ ps -e --contextps -e --context | grep example_program
~]$ ps -e --context | grep example_program
				To list all command lines that are on the whitelist, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
root: 
firewall-cmd --list-lockdown-whitelist-commands
~]# firewall-cmd --list-lockdown-whitelist-commands
				To add a command command to the whitelist, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
root: 
firewall-cmd --add-lockdown-whitelist-command='/usr/bin/python -Es /usr/bin/command'
~]# firewall-cmd --add-lockdown-whitelist-command='/usr/bin/python -Es /usr/bin/command'
				To remove a command command from the whitelist, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
root: 
firewall-cmd --remove-lockdown-whitelist-command='/usr/bin/python -Es /usr/bin/command'
~]# firewall-cmd --remove-lockdown-whitelist-command='/usr/bin/python -Es /usr/bin/command'
				To query whether the command command is on the whitelist, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
				 The command prints 
root: 
firewall-cmd --query-lockdown-whitelist-command='/usr/bin/python -Es /usr/bin/command'
~]# firewall-cmd --query-lockdown-whitelist-command='/usr/bin/python -Es /usr/bin/command'yes with exit status 0 if true. It prints no with exit status 1 otherwise.
			
				To list all security contexts that are on the whitelist, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
root: 
firewall-cmd --list-lockdown-whitelist-contexts
~]# firewall-cmd --list-lockdown-whitelist-contexts
				To add a context context to the whitelist, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
root: 
firewall-cmd --add-lockdown-whitelist-context=context
~]# firewall-cmd --add-lockdown-whitelist-context=context
				To remove a context context from the whitelist, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
root: 
firewall-cmd --remove-lockdown-whitelist-context=context
~]# firewall-cmd --remove-lockdown-whitelist-context=context
				To query whether the context context is on the whitelist, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
				 Prints 
root: 
firewall-cmd --query-lockdown-whitelist-context=context
~]# firewall-cmd --query-lockdown-whitelist-context=contextyes with exit status 0, if true, prints no with exit status 1 otherwise.
			
				To list all user IDs that are on the whitelist, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
root: 
firewall-cmd --list-lockdown-whitelist-uids
~]# firewall-cmd --list-lockdown-whitelist-uids
				To add a user ID uid to the whitelist, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
root: 
firewall-cmd --add-lockdown-whitelist-uid=uid
~]# firewall-cmd --add-lockdown-whitelist-uid=uid
				To remove a user ID uid from the whitelist, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
root: 
firewall-cmd --remove-lockdown-whitelist-uid=uid
~]# firewall-cmd --remove-lockdown-whitelist-uid=uid
				To query whether the user ID uid is on the whitelist, enter the following command: 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
				 Prints 
firewall-cmd --query-lockdown-whitelist-uid=uid
~]$ firewall-cmd --query-lockdown-whitelist-uid=uidyes with exit status 0, if true, prints no with exit status 1 otherwise.
			
				To list all user names that are on the whitelist, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
root: 
firewall-cmd --list-lockdown-whitelist-users
~]# firewall-cmd --list-lockdown-whitelist-users
				To add a user name user to the whitelist, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
root: 
firewall-cmd --add-lockdown-whitelist-user=user
~]# firewall-cmd --add-lockdown-whitelist-user=user
				To remove a user name user from the whitelist, enter the following command as 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
root: 
firewall-cmd --remove-lockdown-whitelist-user=user
~]# firewall-cmd --remove-lockdown-whitelist-user=user
				To query whether the user name user is on the whitelist, enter the following command: 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
				 Prints 
firewall-cmd --query-lockdown-whitelist-user=user
~]$ firewall-cmd --query-lockdown-whitelist-user=useryes with exit status 0, if true, prints no with exit status 1 otherwise.
			5.16.3. Configuring Lockdown Whitelist Options with Configuration Files
Copy linkLink copied to clipboard!
				The default whitelist configuration file contains the NetworkManager context and the default context of libvirt. The user ID 0 is also on the list. 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
			
				Following is an example whitelist configuration file enabling all commands for the 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
				 This example shows both 
 
Copy to Clipboard
Copied!
 
 
Toggle word wrap
Toggle overflow
 
 
 In that example, only the 
firewall-cmd utility, for a user called user whose user ID is 815: 
user id and user name, 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: /usr/bin/python /bin/firewall-cmd --lockdown-on
/usr/bin/python /bin/firewall-cmd --lockdown-on--lockdown-on command is allowed. 
				Note
						In Red Hat Enterprise Linux 7, all utilities are placed in the 
/usr/bin/ directory and the /bin/ directory is sym-linked to the /usr/bin/ directory. In other words, although the path for firewall-cmd when run as root might resolve to /bin/firewall-cmd, /usr/bin/firewall-cmd can now be used. All new scripts should use the new location. But be aware that if scripts that run as root have been written to use the /bin/firewall-cmd path, then that command path must be whitelisted in addition to the /usr/bin/firewall-cmd path traditionally used only for non-root users.
					
						The “*” at the end of the name attribute of a command means that all commands that start with this string will match. If the “*” is not there then the absolute command including arguments must match.