IP Filter allows both active and inactive packet filtering rule sets to reside in the kernel. The active rule set determines what filtering is being done on incoming packets and outgoing packets. The inactive rule set also stores rules. These rules are not used unless you make the inactive rule set the active rule set. You can manage, view, and modify both active and inactive packet filtering rule sets.
Before You Begin
You must become an administrator who is assigned the IP Filter Management rights profile. For more information, see Using Your Assigned Administrative Rights in Securing Users and Processes in Oracle Solaris 11.3.
The following example shows output from the active packet filtering rule set that is loaded in the kernel.
# ipfstat -io empty list for ipfilter(out) pass in quick on net1 from 198.51.100.0/27 to any pass in all block in on net1 from 198.51.100.10/27 to any
Before You Begin
You must become an administrator who is assigned the IP Filter Management rights profile. For more information, see Using Your Assigned Administrative Rights in Securing Users and Processes in Oracle Solaris 11.3.
The following example shows output from the inactive packet filtering rule set.
# ipfstat -I -io pass out quick on net1 all pass in quick on net1 all
Use the following procedure if you want to perform either of the following tasks:
Activate a packet filtering rule set other than the one that is currently in use by IP Filter.
Reload the same filtering rule set that has been newly updated.
Before You Begin
You must become an administrator who is assigned the IP Filter Management rights profile. For more information, see Using Your Assigned Administrative Rights in Securing Users and Processes in Oracle Solaris 11.3.
Create a new rule set in a separate file if you want to activate an entirely different rule set.
Update the current rule set in your configuration file.
# ipf -Fa -f filename
The rules in filename replace the active rule set.
The following example shows how to replace one packet filtering rule set with a different rule set.
# ipfstat -io empty list for ipfilter(out) pass in quick on net0 all # ipf -Fa -f /etc/ipf/ipfnew.conf # ipfstat -io empty list for ipfilter(out) block in log quick from 192.0.2.0/27 to anyExample 10 Reloading an Updated Packet Filtering Rule Set
The following example shows how to reload a packet filtering rule set that is currently active and which is then updated.
Optionally, list the active rule set.
# ipfstat -io empty list for ipfilter (out) block in log quick from 192.0.2.0/27 to any
Then, edit the /etc/ipf/myorg.ipf.conf configuration file, refresh the service, and list the active rule set again.
# svcadm refresh network/ipfilter # ipfstat -io empty list for ipfilter (out) block in log quick from 192.0.2.0/27 to any block in quick on net1 from 198.51.100.64/27 to any
Before You Begin
You must become an administrator who is assigned the IP Filter Management rights profile. For more information, see Using Your Assigned Administrative Rights in Securing Users and Processes in Oracle Solaris 11.3.
# ipf -F [a|i|o]
Removes all filtering rules from the rule set.
Removes the filtering rules for incoming packets.
Removes the filtering rules for outgoing packets.
The following example shows how to remove all filtering rules from the active filtering rule set.
# ipfstat -io block out log on net0 all block in log quick from 192.0.2.0/27 to any # ipf -Fa # ipfstat -io empty list for ipfilter(out) empty list for ipfilter(in)
Appending rules to an existing rule set can be useful when testing or troubleshooting. The IP Filter service remains enabled when the rules are added. However, when the service is refreshed, restarted, or enabled, the rules are lost, unless they exist in files that are a property of the IP Filter service.
Before You Begin
You must become an administrator who is assigned the IP Filter Management rights profile. For more information, see Using Your Assigned Administrative Rights in Securing Users and Processes in Oracle Solaris 11.3.
Append rules to the rule set at the command line using the ipf -f - command.
# echo "block in on net1 proto tcp from 192.0.2.64/27 to any" | ipf -f -
These appended rules are not part of IP Filter configuration when the service is refreshed, restarted, or enabled.
Perform the following commands:
Create a rule set in a file of your choice.
Add the rules that you have created to the active rule set.
# ipf -f filename
The rules in filename are added to the end of the active rule set. Because IP Filter uses a "last matching rule" algorithm, the added rules determine filtering priorities, unless you use the quick keyword. If the packet matches a rule containing the quick keyword, the action for that rule is taken, and no subsequent rules are checked.
If filename is the value of one of the IP Filter configuration file properties, then the rules are reloaded when the service is enabled, restarted, or refreshed. Otherwise, the appended rules provide a temporary rule set.
The following example shows how to add a rule to the active packet filtering rule set from the command line.
# ipfstat -io empty list for ipfilter(out) block in log quick from 192.0.2.0/27 to any # echo "block in on net1 proto tcp from 192.0.2.64/27 to any" | ipf -f - # ipfstat -io empty list for ipfilter(out) block in log quick from 192.0.2.0/27 to any block in on net1 proto tcp from 192.0.2.64/27 to any
Creating an inactive rule set in the kernel can be useful when testing or troubleshooting. The rule set can be switched with the active rule set without stopping the IP Filter service. However, when the service is refreshed, restarted, or enabled, the inactive rule set must be added.
Before You Begin
You must become an administrator who is assigned the IP Filter Management rights profile. For more information, see Using Your Assigned Administrative Rights in Securing Users and Processes in Oracle Solaris 11.3.
# ipf -I -f filename
The rules in filename are added to the end of the inactive rule set. Because IP Filter uses a "last matching rule" algorithm, the added rules determine filtering priorities, unless you use the quick keyword. If the packet matches a rule containing the quick keyword, the action for that rule is taken, and no subsequent rules are checked.
The following example shows how to add a rule to the inactive rule set from a file.
# ipfstat -I -io pass out quick on net1 all pass in quick on net1 all # ipf -I -f /etc/ipf/ipftrial.conf # ipfstat -I -io pass out quick on net1 all pass in quick on net1 all block in log quick from 192.0.2.0/27 to any
Switching to a different rule set in the kernel can be useful when testing or troubleshooting. The rule set can be made active without stopping the IP Filter service.
Before You Begin
You must become an administrator who is assigned the IP Filter Management rights profile. For more information, see Using Your Assigned Administrative Rights in Securing Users and Processes in Oracle Solaris 11.3.
# ipf -s
This command enables you to switch between the active and inactive rule sets in the kernel. Note that if the inactive rule set is empty, there is no packet filtering.
The following example shows how using the ipf -s command results in the inactive rule set becoming the active rule set and the active rule set becoming the inactive rule set.
Before running the ipf -s command, the output from the ipfstat -I -io command shows the rules in the inactive rule set. The output from the ipfstat -io command shows the rules in the active rule set.
# ipfstat -io empty list for ipfilter(out) block in log quick from 192.0.2.0/27 to any block in on net1 proto tcp from 192.0.2.64/27 to any # ipfstat -I -io pass out quick on net1 all pass in quick on net1 all block in log quick from 192.0.2.0/27 to any
After running the ipf -s command, the output from the ipfstat -I -io and the ipfstat -io command show that the content of the two rules sets have switched.
# ipf -s Set 1 now inactive # ipfstat -io pass out quick on net1 all pass in quick on net1 all block in log quick from 192.0.2.0/27 to any # ipfstat -I -io empty list for inactive ipfilter(out) block in log quick from 192.0.2.0/27 to any block in on net1 proto tcp from 192.0.2.64/27 to any
Before You Begin
You must become an administrator who is assigned the IP Filter Management rights profile. For more information, see Using Your Assigned Administrative Rights in Securing Users and Processes in Oracle Solaris 11.3.
# ipf -I -Fa
The following example shows how to flush the inactive packet filtering rule set so that all rules have been removed.
# ipfstat -I -io empty list for inactive ipfilter(out) block in log quick from 192.0.2.0/27 to any block in on net1 proto tcp from 192.0.2.64/27 to any # ipf -I -Fa # ipfstat -I -io empty list for inactive ipfilter(out) empty list for inactive ipfilter(in)