Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

Navigation
 

Related Documentation

 

Example: Specifying Access Privileges Using allow/deny-configuration-regexps Statements

This example shows how to set up configuration access privileges using the allow-configuration-regexps and deny-configuration-regexps statements.

Requirements

This example uses the following hardware and software components:

  • One Juniper Networks J Series, M Series, MX Series, or T Series device
  • Junos OS Release 11.2 or later
    • There must be at least one user assigned to a login class.
    • There can be more than one login class, each with varying permission configurations, and more than one user on the device.

Overview

The allow-configuration-regexps and deny-configuration-regexps statements let you explicitly allow or deny users assigned to named user classes access privileges to portions of the configuration hierarchy, giving the system administrator precision control over who can change specific configurations in the system.

Note: The statements allow-configuration-regexps and deny-configuration-regexps perform similar functions as the statements allow-configuration and deny-configuration, except you can configure sets of strings in which the strings include spaces when using the first set of statements. You cannot use the two kinds of statements together.

Configuration

Step-by-Step Procedure

To set up configuration access privileges:

  1. To explicitly allow one or more individual configuration mode hierarchies that would otherwise be denied, include the allow-configuration-regexps statement at the [edit system login class class-name] hierarchy level, configured with the regular expressions to be allowed.
    [edit system login class class-name]user@host# set allow-configuration-regexps "regular expression 1" "regular expression 2" "regular expression 3" "regular expression 4" ...
  2. To explicitly deny one or more individual configuration hierarchies that would otherwise be allowed, include the deny-configuration-regexps statement at the [edit system login class class-name] hierarchy level, configured with the regular expressions to be denied.
    [edit system login class class-name]user@host# set deny-configuration-regexps "regular expression 1" "regular-expression 2" "regular expression 3" "regular expression 4"...
  3. Assign the login class to one or more users.
    [edit system login]user@host# set user username class class-name
  4. Commit your changes.

    Users assigned this login class have the permissions you have set for the class.

Examples

Using Allow or Deny Configurations with Regular Expressions

Purpose

This section provides examples of access privilege configurations to give you ideas for creating configurations appropriate for your system. You can use combinations of privilege statements for configuration access and for operational mode commands to give precise control over classes of access privileges.

Allow Configuration Changes

The following example login class lets the user make changes at the [edit system services] hierarchy level and issue configuration mode commands (such as commit), in addition to the permissions specified by the configure permissions flag, which allows the user to enter configuration mode using the configure command.

[edit system login class class-name]user@host# set permissions configure view view-configurationuser@host# set allow-configuration-regexps "system services"

Deny Configuration Changes

The following example login class lets the user perform all operations allowed by the all permissions flag. However, it denies modifying the configuration at the [edit system services] hierarchy level.

[edit system login class class-name]user@host# set permissions all configure view view-configurationuser@host# set deny-configuration-regexps "system services"

If the following statement is included in the configuration and the user’s login class permission bit is set to all, the user cannot configure telnet parameters:

[edit system login class class-name]user@host# set deny-configuration "system services telnet"

If the following statement is included in the configuration and the user’s login class permission bit is set to all, the user cannot issue login class commands within any login class whose name begins with “m”:

[edit system login class class-name]user@host# set deny-configuration "system login class m .*"

If the following statement is included in the configuration and the user’s login class permission bit is set to all, the user cannot edit the configuration or issue commands (such as commit) at the [edit system login class] or the [edit system services] hierarchy levels:

[edit system login class class-name]user@host# set deny-configuration "system login class" "system services"

Allow and Deny Configuration Changes

The following example login class lets the user perform all operations allowed by the all permissions flag, and explicitly grants configuration access to [system "interfaces .* unit .* family inet address .*" protocols]. However, the user is denied configuration access to the SNMP hierarchy level.

Note: You can use the * wildcard character when denoting regular expressions. However, it must be used as a portion of a regular expression. You cannot use [ * ] or [ .* ] alone.

[edit system login class class-name]user@host# set permissions all configure view view-configurationuser@host# set allow-configuration-regexps system "interfaces .* unit .* family inet address .*" protocolsuser@host# set deny-configuration-regexps snmp

Allow and Deny Multiple Configuration Changes

The following example login class lets the user perform all operations allowed by the all permissions flag, and explicitly grants configuration access to multiple hierarchy levels for interfaces. It denies configuration access to the [edit system] and [edit protocols] hierarchy levels.

Note: You can configure as many regular expressions as needed to be allowed or denied. Regular expressions to be denied take precedence over configurations to be allowed.

[edit system login class class-name]user@host# set permissions all configure view view-configurationuser@host# set allow-configuration-regexps "interfaces .* description .*" "interfaces .* unit .* description .*" "interfaces .* unit .* family inet address .*" "interfaces .* disable" user@host# set deny-configuration-regexps "system" "protocols"

Allow Configuration Changes and Deny Operations Commands

You can combine allow and deny configuration statements with allow and deny operational commands statements to fine-tune access privileges. The following example login class uses a combination of the deny-commands operational permissions statement and the allow-configuration-regexps configuration permissions statement to let the user configure and commit changes to the OSPF and BGP protocols. However, this class of user cannot issue the show system statistics or the show bgp summary commands.

[edit system login class class-name]user@host# set permissions all configure view view-configurationuser@host# set deny-commands "(show system statistics)|(show bgp summary)"user@host# set allow-configuration-regexps "protocols ospf|bgp"

The following shows permissions set for individual configuration mode hierarchies:

[edit]
system {login { # This login class has operator privileges and the additional ability to edit # configuration at the system services hierarchy level.class only-system-services {permissions [ configure ];allow-configuration "system services";}# services commands.class all-except-system-services { # This login class has operator privileges but # cannot edit any system services configuration.permissions [ all ];deny-configuration "system services";}}}

Verification

To verify that you have set the access privileges correctly:

  1. Configure a login class and commit the changes.
  2. Assign the login class to a username.
  3. Log in as the username assigned with the new login class.
  4. Attempt to perform the configurations that have been allowed or denied.
    • You should be able to perform configuration changes to hierarchy levels and regular expressions that have been allowed.
    • You should not be able to perform configuration changes to hierarchy levels and regular expressions that have been denied.
    • Denied expressions should take precedence over allowed expressions.
    • Any allowed or denied expressions should take precedence over any permissions granted with the permissions statement.

Action

 

Related Documentation

 

Published: 2013-03-15

 

Related Documentation

 

Published: 2013-03-15