Rechercher une page de manuel

Chercher une autre page de manuel:


Langue: en

Version: 2004-08-05 (debian - 07/07/09)

Section: 1 (Commandes utilisateur)


ncat - Network Config Audit Tool for IOS (and other) configs


ncat [OPTIONS] config [config ...]


ncat reads a rules file (default /etc/ncat.conf) and checks one or more config files specified on the command line against rules found in the rules file. Rules specify that a particular chunk of text is either required or forbidden. Once all rules have been checked, a report is output listing violations.

There are some special features that apply if the file being checked is a CISCO IOS configuration. There are special rules (see below) that allow for parsing of per-interface and per-line configurations.


-r, --rules
The "--rules" flag allows the specification of an alternate rules config file.
-l, --limitrulesto
The "--limitrulesto" allows the commandline specification of a regular expression to limit the rules that are checked. The name of the rule must match the regexp specified or the rule is skipped. You might try something like


-c, --limitclassto
The "--limitclassto" allows the command line specification of a regular expression to limit the rules that are checked. The class of the rule must match the regexp specified or the rule is skipped. You might try something like

See the rules file for definition of rule classes. By default, only rules matching the class ``default'' are checked. ``all'' is synonym for ``.*''. You can give a ``normal'' comma separated list of classes that you want to check because ``,'' is treated as a synonym for the regular expression or (``|'').

-p, --onlypass
The "--onlypass" flag indicates flag indicates that only passing rules should be reported. It may not be combined with "--onlyfail"
-f, --onlyfail
The "--onlyfail" flag indicates flag indicates that only failing rules should be reported. It may not be combined with "--onlypass"
-V, --version
The "--version" option displays the current program version.


The ncat config file or ``rules file'' (ncat.conf/ncat.conf.MASTER) contains four different types of information. ``Rules'' define rules to be checked, ``ConfigClass'' specifies groups of optional rules, ``ConfigLocal'' specified local configuration value, and ``ConfigGlobal'' specifies global configuration options.

Rules Syntax
The rules file contains a series of records defining rules to be checked. Each Record begins with ``RuleName:...'' field and continues until the next ``RuleName:..'' field or end-of-file. Each record consists of a number of named fields. The fields begin with an alphanumeric keyword followed by a colon and then a value. Values may be continued across multiple lines by ending the line with a backslash (\). The following is the list of valid field names and permissible values.

  RuleName:unique rule name
  [RuleFix:Text...] "
   * RuleName specifies a unique name for the rule.
   * RuleClass specifies a class or classes to which the rule belongs.  Every rule
     is a member of the class "default" unless otherwise specified.   A rule can
     be a member of multiple classes.  The list of member classes is a comma separated list.
   * RuleVersion specifies a pattern that indicates which config file
     version a rules applies to.
     For example, if RuleVersion is "1[12].*" then the rule will apply
     to all IOS 11 and 12 configurations.
   * RuleContext lists the context of the rule.  Possible values are
     - Global - The rule must match anywhere in the config.
     - IOSInterface - The rule must match in the context of an IOS interface definition
     - IOSLine - The rule must match in the context of an IOS line definition.
   * RuleType determines if the match should be required or forbidden
   * RuleMatch specifies a regular expression to match within the given context.
   * RuleInstance defines the instance of the rule that must match, for instance
     "Serial0/0","Vlan\d+","vty", or "aux".
   * RuleImportance specifies a number indicating the relative importance
     of a rule.  The higher the number, the more important it is.
   * RuleDescription contains a description/justification of the rule.
   * RuleFix contains text to be applied to make the config "correct"
   * regular-expression is a Perl regular expression
   * rules and values enclosed in "[...]" are optional.

Rules Example

Here is an example of a rules file

     RuleName:enable secret
     RuleVersion:version 1[12]\.*
     RuleMatch:enable secret \d \S+
     RuleDescription:Require enable secret.\
     See rules.html#enablesecret for details.
     RuleFix:enable secret EDIT-BY-HAND
     RuleName:Apply VTY ACL
     RuleVersion:version 1[12]\.*
     RuleMatch: access-class 92 in
     RuleDescription:Require ACL 92 to be applied to VTYs\
     See rules.html#ApplyVTYACL for details.
     line vty 0 4\
     access-class 92 in\
     RuleName:no ip directed broadcast
     RuleVersion:version 11\.*
     RuleMatch:no ip directed-broadcast
     RuleDescription:Disallow directed broadcasts by default.\
     See rules.html#noipdirectedbroadcast for details.
     int INSTANCE\
     no ip directed-broadcast\

In the above example, the rules have the following meaning

     Rule 1 requires a global (anywhere in the config) rule matching
     "enable secret" followed by a non-blank string.
     Rule 2 requires that all vty lines have "access-class 92 in". It lists the commands
     that need to be entered to add the rule.
     Rule 3 requires that all Vlan interfaces have "no ip directed
     broadcast" set and lists the commands needed to set it.  This rule applies 
     only to IOS version 11.

Global Config Options Syntax and Example

In addition, there are several global rules file options:


  ConfigOrganization:My Organization
  ConfigDocumentType:Security Audit Rules
  ConfigPlatforms:Cisco IOS Routers
  ConfigGuidePath:/usr/doc /usr/local/doc ~/doc ./doc
  ConfigIntroText:Text (html)...
  ConfigTrailingText:Text (html)...
  ConfigOutputGroups:value [value ...]
  ConfigLineSkip:pattern[:pattern...] "


   * ConfigVersion defines the version number of the rules
   * ConfigOrganziation describes the auditing organization
   * ConfigDocumentType describes the type of document (e.g. "rules", "benchmark"...)
   * ConfigPlatforms describes the type of systems being audited ("production routers...")
   * ConfigFeedback lists contact info (e.g "")
   * ConfigGuide defines the name of a "configuration guide" to be symlinked into
     the directory where the audits are run.  This is useful because it allows the
     description portion of individual rules to make hyperlinks to a document
     containing a more complete justification for the rule.
   * ConfigGuidePath defines the path to search for the guide.
   * ConfigLineSkip defines a list of one or more patterns that causes
     checking to be skipped.  The default is "^ shutdown".
   * ConfigRulesAlias defines an alias for the rules.html file.  A symlink
     from this name to "rules.html" will be created.
   * ConfigIntroText defines text (HTML) to be inserted before the list
     of individual rules.
   * ConfigTrailingText defines text (HTML) to be inserted after the list
     of individual rules.
   * ConfigOutputGroups specifies groups (such as datacenter names) by which
     output is grouped in index.html.  The groups are space separated and
     are regular expressions.  The regular expressions are matched against
     the names of the configurations being checked.

These global rules file options are mostly used during report generation.

Local Configuration Options Syntax

ConfigLocal options allow the specification simple text substitution macros, i.e. a string that will be replaced with a given value. The syntax is                                                                           

In addition, there are several global rules file options:


  [ConfigLocalDescription:COMMENT] "


     * KEY is a keyword (e.g. "EternalInterface") that will
       be replaced by VALUE in the resulting config file.
     * VALUE is a value ("Ethernet0") that will be substituted.
     * CLASS_NAME is a list of one or more classes to which use the option
     * COMMENT is a description of the option
     * comments may be continued across several lines by ending
       each line to be continued with "\".

Local Configuration Options Example

Here is an example of a local configuration option:

        Specify the name of the timezone to be used.  For example, GMT,EST, etc.

In the above example, the fields have the following meaning

     * ConfigLocalName specifies "Local_Timezone" as the name of the local option
     * ConfigLocalValue specifies the value "GMT"
     * ConfigLocalClassPrereq says that this option only applies if the class
       "localtime" is selected (this sets the "local" timezone to "GMT")
     * ConfigLocalDescription specifies text to describe the option

Optional Rule Class Syntax

The master file may also contain ConfigClass: rules, which describe groups of configuration options. ncat_config will prompt for inclusion/exclusion of classes ConfigClass: entries. They are of the form:


  . "


     * CLASS_NAME is the name of the rule class.  It should correspond to
       one rules having the same value for RuleClass.
     * COMMENT is a description of the option
     * Comments may be continued across several lines by ending
       each line to be continued with "\".
     * ConfigClassClassPrereq: is a comma-separated list of classes
       that are prerequisites of the class being defined
    * ConfigClassConflictsWith: is a comma-separated list of classes
      that are incompatible with this class.

Optional Rule Class Example

Here is an example of a rule class:

         Define a second external interface.

In this example

     * ConfigClass specified the name of the config class as "2nd_External_Interface"
     * ConfigClassPrereq says that this rule only applies of the ruleclass
       exterior_router is specified.
     * ConfigClassDescription describes the purpose of the second ruleclass.


0 - success >0 - some error occurred


/etc/ncat.conf - The rules file.
a config file - At least one config file on the                  command line (required)


Rules themselves may not contain colon (``:'') characters.




George M. Jones <>


John Stewart has helped with the code in numerous ways. It's much cleaner, and the install process is better thanks to his efforts.

Rob Thomas collected and wrote an excellent baseline IOS 12 secure configuration which is used as the basis for the example ncat.conf. The first version of that config provided the ``ah ha'' insight that ``config checking can be simple'' and thus the impetus for the creation of this script.

Eric Brandwine has written a much more elegant and complete config checker. Some of the features of this script are inspired by his work. In particular, the size and complexity of that program inspired the (at least initial) simplicity of this one.

Joshua Wright did the port for ActiveState on Windows.

Le bonheur et le malheur des hommes ne dépend
pas moins de leur humeur que de la fortune.
-+- François de La Rochefoucauld (1613-1680), Maximes 61 -+-