This Knowledge Base article applies to: Clavister FWCtl (all versions) |
The word Firewall can be replaced with "Security Gateway" to apply to later releases (CorePlus 8.70.00 and newer, as well as 8.65 and 8.67 series).
FWCtl is a tool to perform various automated or batch firewall control tasks, such as periodic statistics polling, automated configuration changes, etc. It is currently available for the Win32 command-line console and Linux x86.
This overview describes FWCtl. It works with CorePlus version 8 management Datasources, and adds the following features from the previous version that worked with v7 Datasources:
Under windows, FWCtl will use the same datasource settings that the Firewall Manager uses. These settings are stored in the registry, under HKEY_CURRENT_USER.
Under unix, FWCtl stores these settings in ~/.fwctlrc
.
--adddsn - Add (attach) a new datasource Syntax: --adddsn <dsn name> "<connect string>" Example: fwctl --adddsn mydsn "c:\path\to\my\datasource" Note that adddsn does not verify that the given directy actually contains firewalls or namespaces; only that it exists. |
--rmdsn - Remove (detach) an existing datasource Syntax: --rmdsn <dsn name> Example: fwctl --rmdsn mydsn Note that rmdsn only disconnects fwctl from the datasource; it does not delete the actual contents. |
--listdsn - List attached datasources Syntax: --listdsn [--plain] [-d "<delim>"] Examples:
|
--list (-l) - List all firewalls in all attached datasources Syntax: --list [--plain] [-d "<delim>"] ["<pattern>"] Example:
|
--dumpdsn (-d) - Display the contents of a DSN in a tree view, much the same
as the Security Editor tree view in the Firewall Manager Syntax: --dumpdsn <dsn name> Example: fwctl --dumpdsn mydsn |
--console (-c) - Attach to the firewall console Syntax: --console [-t <seconds>] <firewall> Examples:
|
--rtlog (-r) - Display the real-time log of the firewall Syntax: --rtlog <firewall> Examples:
|
--ping (-p) - "Ping" the firewall - retreive uptime and basic stats Syntax: --ping [-t <timeoutsecs>] <firewall> Example:
|
--cfgupload (-u) - Upload a configuration file to the firewall Syntax: --cfgupload [-v <version> | -f <file>] <firewall> Examples:
A complete configuration upload procedure:
|
--cfgdownload (-w) - Download the configuration file from the firewall Syntax: --cfgdownload [-f <file>] <firewall> Examples:
|
--coreupload - Upload a new firewall core to the firewall Syntax: --coreupload <core file> <firewall> Examples:
|
--fileupload - Upload an arbitrary file to the firewall Syntax: --fileupload "<source>" "<destination>" <firewall> Example: fwctl --fileupload x:\path\to\fwldr-1.01.cfx fwldr.cfx mygw
Note that, while it is possible to do so, it is not recommended to upload
"fwcore.cfg" nor "fwcore.cfx" this way. For these files, "--cfgupload"
and "--coreupload", respectively, are the recommended methods. |
--reconfigure (-e) - Instruct the firewall to re-read its configuration Syntax: --reconfigure <firewall> Example: fwctl --reconfigure mygw Using fwctl --reconfigure is not quite the same as typing "reconfigure" on the firewall console. In addition to instructing the firewall to re-read its configuration, fwctl will also attempt to reconnect to the firewall when the new configuration has been parsed, and confirm that bi-directional management communication is possible using the new configuration. This is what the Firewall Manager does when it uploads configurations. |
--restart - Instruct the firewall to exit the firewall core (and restart) Syntax: --restart [--nobidir] <firewall> Examples:
|
--reboot - Instruct the firewall to perform a full reboot Syntax: --reboot <firewall> Example: fwctl --reboot mygw Performing a full reboot of a firewall is normally not necessary. An obvious exception to this rule is when the boot loader (fwldr.cfx) has been upgraded. |
--changekeys - Negotiate new keys to use for remote management of a firewall Syntax: --changekeys <firewall> Example: fwctl --changekeys mygw Note that you do not specify what you want the keys to be. They are generated using random data from fwctl and from the firewall itself. The negotiated keys are automatically stored in the firewall (in the binary file security.bin), and in the local management database (in e.g. mygw.efw). |
--stats (-s) - Perform real-time statistics polling
Examples:
Note that both "Gauge" and "Count" type values are normally displayed as gauges. That is,
for counters, you will see the difference between two polls, divided by the polling interval.
With the "--rawcounters" switch, the counters will be displayed without postprocessing. This
is useful for e.g. feeding values to graphing and statistics tools like
rrdtool. |
--cfginfo - Display database information about a firewall configuration Syntax: --cfginfo [-v <version>] <firewall> Examples:
|
--checkout (-o) - Mark a firewall's configuration as "checked out" Syntax: --checkout <firewall> Example: fwctl8 --checkout mygw "Checking out" the configuration of a firewall means that it is locked for editing by you. No one else is allowed to edit it. It can only be checked back in by yourself, using the same tool (fwctl vs. fwmgr), on the same computer. See working with configurations for more information. |
--printcfg (-t) - Print the configuration file of a firewall on screen Syntax: --printcfg [-v <version>] <firewall> Example: fwctl8 --printcfg mygw > mygw-config.txt |
--checkin (-i) - Check a firewall configuration back in Syntax: --checkin [-c "<comments>"] <file> <firewall> Example: fwctl8 --checkin -c "some changes" x:\path\to\config.txt mygw The configuration you wish to check in must have previously been checked out by you, using fwctl, on the same computer. After the configuration has been checked back in, others are allowed to check it out and make changes to it. See working with configurations for more information. |
--undocheckout - Undo a "check out" operation Syntax: --undocheckout <firewall> Example: fwctl8 --undocheckout mygw See working with configurations for more information. |
--checkoutlist - List checked-out firewalls in all datasources Syntax: --checkoutlist [-u <user>] [-d "<delim>"] Example: fwctl8 --checkoutlist -u bob |
This small guide assumes that fwctl is already downloaded, and perhaps also added to your system path.
You may need to attach to the datasources you want to work with. If you are using fwctl on the computer where you use Firewall Manager, you can likely skip this step; fwctl uses the same datasource settings that the Firewall Manager does.
fwctl --adddsn mydsn "c:\Program Files\Clavister\Firewall Manager\Default"
Use "--list" to see the list of firewalls available in your DSNs.
fwctl --list
Name IP Address Status Core Type
Default:mygw 192.168.0.1 ACTIVE 8.00.04 VPN
At this point, you'll be able to use all the
basic communications commands like ping, console, etc.
Also see working with configurations.
Working with configurations
The first thing you'll need to do is to check out the firewall
configuration so that no one else can edit it simltaneously.
fwctl --checkout mygw
If this is done in an automated script, it may be useful to know that fwctl always returns proper return codes. If the check-out operation fails, the script will be able to tell by checking the return value of the command (i.e. checking "ERRORLEVEL" under windows and normal "if" clauses under unix). See notes on automation / scripting.
After this, you'll want a copy of the actual configuration to work with:
fwctl --printcfg mygw > config.txt
At this point, you can make changes to config.txt, or perhaps filter it
and store the results in "newconfig.txt". If the (automatic) configuration
editing procedure fails, you should use
When editing is done, save the changes with:
fwctl --checkin newconfig.txt mygw
And then you'll want to upload the changes to the firewall and activate them:
fwctl --cfgupload mygw
fwctl --reconfigure mygw
This concludes the normal configuration management procedure.
At this point, we would like to note that it is entirely possible to forego the management database, and use only externally generated configurations through using the "-f" switch of cfgupload to upload arbitrary configuration files. Doing so, however, means that the firewall really cannot be managed through the firewall manager. The firewall manager always works with the data stored in the management database.
Notes on automation / scripting
FWCtl is designed with automated scripting in mind. Below are a few key points to keep in mind when using FWCtl in scripts.
It is always a good idea to check the process return codes, e.g.:
Windows: | :tryagain
|
Unix shell: |
while ! fwctl --checkout mygw; do
|
Use the console "-t" switch, e.g.:
C:\> echo conn | fwctl --console -t 2 mygw
|
Note that diagnostic messages such as "Connection closed." are not output if you redirect the output to a file. They are only displayed if fwctl is being run "interactive".
Use only ";" and "\t" separators in delimited output
If the ";" separator is used, fwctl will automatically replace any
occurence of ";" within the output fields to ",".
The "\t" (tab) separator is always safe. Output fields never contain tabs.
One exception is for "--stats", where it makes sense to use ":" separators,
since rrdtool wants colon separated input. If you use colon separators, avoid
outputting formatted times, e.g. fwctl/localtime/rfc3339
GNU (text) utilities under windows
Utilities like "sleep", "head" and "tail" are nearly
indispensible when writing automated batch scripts.
Pick up a copy at
http://unxutils.sourceforge.net/