|
|
This chapter describes how to use the Cisco Access Registrar testing command, radclient, to test your RADIUS server.
The radclient command is a RADIUS server test tool. You can use it to create packets, send them to a specific server, and examine the response.
Because the radclient command is Tcl-based, you can use it interactively or you can execute it as a Tcl script file. To run the radclient command, type:
You can invoke the radclient command with any of the arguments listed in Table 6-1.
| Argument | Definition |
|---|---|
-C | Specifies the name of the cluster to log into by default. |
-N | Specifies the name of the administrator. |
-P | Specifies the password. |
-i | Forces interactive mode. |
-n | Does not automatically load radclient.tcl. |
-p <path> | Specifies the path used for radclient.tcl. |
-S <file> | Specifies the source for the file to load after radclient.tcl. |
-v | Prints the version information and then exits. |
Using the radclient command, you can create packets (default or specific packets), view packets, send packets, read the value of packets, and delete packets.
To create a basic RADIUS Access-Request packet, use the radclient command simple. This function creates a packet and fills in basic attributes. The syntax of the simple command is:
For example, to create an Access-Request packet for user bob whose password is bigDog, type:
p001 The radclient command responds with p001, which is the identifier (name) of the newly created packet.
To create a CHAP Access-Request packet, use the radclient command simple_chap. The syntax of the simple_chap command is:
<use_challenge> is a boolean that indicates whether to use the CHAP-Challenge attribute.
For example, to create a CHAP packet and use a <use_challenge>, type:
p002 To view a packet or any other object, type the object identifier at the radclient prompt. For example, to display packet p001, type:
Packet: code=Access-Request,id=0,length=0,\ attributes =
User-Name = bob
User-Password = bigDog
NAS-Identifier = localhost
NAS-Port = 0To send a packet, specify the packet identifier and use the word send. You can optionally specify the host and port to which to send the packet. The default host is localhost, and the default port is 1645.
When you want to send a packet to a different host and different port, you must specify them on the command line. For example, to send a packet to the RADIUS server amazon, at port number 1812, type:
p002When Cisco Access Registrar receives a response to the packet you sent, it prints the response packet's object identifier before the radclient prompt returns.
Using radclient, you can create empty packets you can then modify to contain the appropriate fields.
To create an empty packet, the syntax is:
The optional <packet-type> argument can be the numerical RADIUS packet type identifier, such as 2, or the string representation, such as Access-Accept:
p00dPacket: code = Access-Accept,\
id = 0, length = 0, attributes =You can modify the value of a packet field using the syntax:
<packet-identifier> is the packet number, such as p001. <attrib> is the attribute you want to set. <value> is either a numeric packet-type, the string representation, or the hex string with a colon separating each byte.
For example, to set the identifier field to 99, type:
99Packet: code = Access-Request, id = 99, length = 0,
attributes =
User-Name = bob
User-Password = bigDog
NAS-Identifier = localhost
NAS-Port = 0You can read (get) the value of any of the packet fields by using the syntax:
For example, to get the identifier field, type:
99When you are writing long running or iterating scripts, you might want to conserve memory by deleting packets when you are through with them. To delete a packet, type:
For example, to delete all resources referred to by the packet p001, type:
Using the radclient command you can create attributes, which are specific RFC-defined components of requests and responses.
To create an attribute object, the syntax is:
<attrib> is a recognized RADIUS attribute name. <value> is the value of the attribute.
For example, to create the attribute User-Name and set its value to Bob, type:
a001 Note, a001 is the object identifier for the newly created attribute.
To view an attribute, or any other object, type the object identifier at the radclient prompt. For example, to display attribute a001 created in the example above, type:
User-Name = bobYou can get the name and value of an attribute in various formats:
The following examples show how to get an attribute's name, type, value, and value as integer:
User-Name1boba001: the value is not an intWhen you are writing long running or iterating scripts, you might want to conserve memory by deleting attributes when you are through with them (be sure not to delete attributes being referred to by other objects, like packets.)
To delete all resources referred to by the attribute a001, type:
The following examples show how to use radclient to create, send, and modify packets.
This example creates an Access-Request packet for user jane with password jane, and sends it to the default RADIUS server (localhost).
p001Packet: code = Access-Request, id = 0, length = 0, attributes =
User-Name = jane
User-Password = jane
NAS-Identifier = localhost
NAS-Port = 0p002Packet: code = Access-Accept, id = 1,\
length = 38, attributes = Login-IP-Host = 204.253.96.3 Login-Service = Telnet Login-TCP-Port = 541 The first command (simple jane jane) creates the packet (the packet object identifier is p001). Next, the example displays the packet before sending it (by typing the packet identifier, p001). Next, the packet is sent (p001 send), and radclient prints the response packet object identifier, p002. Finally, the example shows dumping the contents of the response packet (p002).
This example creates a simple Access-Request packet, and adds other attributes to it.
p003a00cService-Type = Frameda00dNAS-Port = 99Packet: code = Access-Request, id = 0,\
length = 0, attributes =User-Name = janeUser-Password = janeNAS-Identifier = localhostService-Type = FramedNAS-Port = 99
This example shows creation of the packet p003 using user-id jane and password jane. Then, creation of the Service-Type attribute (with the object identifier a00c). Next, the attribute object is printed by typing just the object identifier. Then, the new attribute is added to the packet. The same steps are followed for the NAS-Port attribute. And finally, the packet contents are printed.
This example performs the same tasks as Example 2, however, with less steps.
p004Packet: code = Access-Request, id = 0,\
length = 0, attributes = User-Name = jane User-Password = jane NAS-Identifier = localhost Service-Type = Framed NAS-Port = 99When you do not need references to intermediate objects, you can use the command substitution feature of Tcl, which allows you to use the result of one command as an argument to another command. Square brackets invoke command substitution, and everything inside the brackets is evaluated, and the result is substituted in place of the bracketed command.
![]()
![]()
![]()
![]()
![]()
![]()
![]()
Posted: Thu Aug 19 08:14:41 PDT 1999
Copyright 1989-1999©Cisco Systems Inc.