Dynamic Zones Tom Eastep 2009 Thomas M. Eastep Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover, and with no Back-Cover Texts. A copy of the license is included in the section entitled GNU Free Documentation License.
Overview There is sometimes a need to be able to define a zone whose members are unknown at compile-time. For example, you may wish to require authentication of internal users before allowing them access to the internet. When a user is authenticated, the user's IP address is added to the zone of users permitted web access. Shorewall provides basic support for defining such zones. This support is based on ipset, so to use dynamic zones, you must have installed the xtables-addons.
Defining a Dynamic Zone A dynamic zone is defined by using the keyword dynamic in the zones host list. Example:
/etc/shorewall/zones:#NAME TYPE OPTIONS loc ipv4 webok:loc ipv4/etc/shorewall/interfaces: #ZONE INTERFACE BROADCAST OPTIONS webok eth0 - hosts=dynamic
Once the above definition is added, Shorewall will automatically create an ipset named webok_eth0 the next time that Shorewall is started or restarted. Shorewall will create an ipset of type iphash. If you want to use a different type of ipset, such as macipmap, then you will want to manually create that ipset yourself before the next Shorewall start/restart.
Adding a Host to a Dynamic Zone Adding a host to a dynamic zone is accomplished by adding the host's IP address to the appropriate ipset. Shorewall provldes a command for doing that:
shorewall add interface:address ... zone
Example:
shorewall add eth0:192.168.3.4 webok
Deleting a Host from a Dynamic Zone Deleting a host from a dynamic zone is accomplished by removing the host's IP address from the appropriate ipset. Shorewall provldes a command for doing that:
shorewall delete interface:address ... zone
Example:
shorewall delete eth0:192.168.3.4 webok
Listing the Contents of a Dynamic Zone The shorewall show command may be used to list the current contents of a dynamic zone.
shorewall show dynamic zone
Example:
shorewall show dynamic webok eth0: 192.168.3.4 192.168.3.9