cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
142
Views
1
Helpful
0
Comments
alanssie
Cisco Employee
Cisco Employee

Purpose
=======
This EEM script provide possibilities to clear the subscriber based on different filter
This script also answer the confirmation enforced in the latest IOS-XR released.

Steps to activate
=================
1 create a directory
2 Upload the script to the device
3 configure EEM user authorization
4 register the script

Create a directory scripts under harddisk:
------------------------------------------
cd harddisk:
mkdir EEM

Upload the script to the device
----------------------------------
Use SCP, ftp, TFTP to copy the script in harddisk:EEM
Example with scp
scp clear_sub.tcl [asr9k-IP]:harddisk:/EEM/clear_sub.tcl

Configure EEM user authorization
--------------------------------
Local
conf t
aaa authorization eventmanager default local
!
username EEM
group root-lr
group cisco-support
!
vty-pool eem 100 105
commit

Note: in case the authorization is provided through tacacs+, correct the aaa configuration line
There is no need to use a password as this only concern authorization use by the script.

register the script
-------------------
conf t

event manager directory user policy harddisk:EEM
event manager policy clear_sub.tcl username EEM persist-time 3600 type user
commit


Create an alias to run the script
-----------------------------------
conf t
alias exec clsub event manager run clear_sub.tcl
commit

 

Options
=======
Clearing the users
clsub VRF=[vrf name] MAXD=[maximum subscriber to clear(default 1000)]
clsub INTF=L2TP [username of end user (client name in show subscriber)] VER=2
clsub INTF=[subscriber interface]
clsub MAC=1666.0317.0a46
clsub IP=[subscriber ip address]
clsub [username] (using default verbosity)
clsub [username] (using info verbosity)
clsub [username] (using debug verbosity)


There is an additional option using VER=
VER=0 Will display error message (default)
VER=1 Will display error message as well as Information
VER=2 Will display error message, Information, Debug


Note: even though command of few of those clear command could be available today
as mentioned earlier later release will ask a confirmation which could break some application
This script will take care of the confirmation question


tests
=====


Clearing in vrf
===============

default value 1000


RP/0/RSP0/CPU0:shudder#clsub VRF=VRF-PPP2 MAXD=10 VER=2
RP/0/RSP0/CPU0:shudder#event manager run clear_sub.tcl VRF=VRF-PPP2 MAXD=10 VER=2
Fri Nov 24 17:33:54.209 UTC
CLEARSUB-2024-Nov-1-DEBUG:INTF = Clearing all in vrf VRF-PPP2
CLEARSUB-2024-Nov-1-DEBUG:executing sh subscriber session filter vrf VRF-PPP2 | utility head count 16

CLEARSUB-2024-Nov-1-DEBUG:executing clear subscriber session identifier interface PE2.501.pppoe46157 force
Y

CLEARSUB-2024-Nov-1-DEBUG:executing clear subscriber session identifier interface PE2.501.pppoe46158 force
Y

CLEARSUB-2024-Nov-1-DEBUG:executing clear subscriber session identifier interface PE2.501.pppoe46059 force
Y

CLEARSUB-2024-Nov-1-DEBUG:executing clear subscriber session identifier interface PE2.501.pppoe46060 force
Y

CLEARSUB-2024-Nov-1-DEBUG:executing clear subscriber session identifier interface PE2.501.pppoe46061 force
Y

CLEARSUB-2024-Nov-1-DEBUG:executing clear subscriber session identifier interface PE2.501.pppoe46062 force
Y

CLEARSUB-2024-Nov-1-DEBUG:executing clear subscriber session identifier interface PE2.501.pppoe46063 force
Y

CLEARSUB-2024-Nov-1-DEBUG:executing clear subscriber session identifier interface PE2.501.pppoe46064 force
Y

CLEARSUB-2024-Nov-1-DEBUG:executing clear subscriber session identifier interface PE2.501.pppoe46065 force
Y

CLEARSUB-2024-Nov-1-DEBUG:executing clear subscriber session identifier interface PE2.501.pppoe46066 force
Y

 

 


L2tp User
========

RP/0/RSP0/CPU0:shudder#sh subscriber session filter inter PE2.501.pppoe34998 det int
Thu Nov 23 16:49:09.093 UTC
Interface: PW-Ether2.501.pppoe34998
Circuit ID: Unknown
Remote ID: Unknown
Type: PPPoE:LAC
Tunnel Info: LNS Address: 10.74.128.1, LAC Address: 10.74.128.103
Server-Auth-id: BSNS-ASR1002-1, Client-Auth-id: PALTEL
Mac Address: 1666.0317.0a43
Account-Session Id: 0000a551
Nas-Port: Unknown
User name: cisco
Formatted User name: cisco
Client User name: testuser2628-501@cisco
Outer VLAN ID: 501
Subscriber Label: 0x000004d0
Created: Tue Nov 21 14:43:20 2023
State: Activated, Thu Jan 1 00:00:00 1970

Authentication: unauthenticated
Authorization: authorized
Ifhandle: 0x020e46a0
Session History ID: 2
Access-interface: PW-Ether2.501
iEdge Oper Flags: 0x00000002
SRG Flags: 0x00004000(M)
SRG Group ID: 4
Prepaid State: (Disabled)
Policy Executed:

event Session-Start match-first [at 1700577800]
class type control subscriber PPP do-until-failure [Succeeded]
10 activate dynamic-template PPP_BASE_TPL [cerr: Success][aaa: Success]
event Session-Activate match-first [at 1700577800]
class type control subscriber CLASS-LAC-cisco do-until-failure [Succeeded]
10 authorize aaa list DSL [cerr: Success][aaa: Success]
Session Accounting: disabled
Last COA request received: unavailable
User Profile received from AAA:
Attribute List: 0x557b033beb20
1: service-type len= 4 value= Outbound
2: sub-qos-policy-out len= 20 value= __sub_78ffffffce4152
Services:
Name : PPP_BASE_TPL
Service-ID : 0x4000003
Type : Multi Template
Status : Applied
[Event History]
Nov 21 14:43:20.576 Service status update [many]
-------------------------
[Event History]
Nov 21 14:43:18.528 SUBDB session create
Nov 21 14:43:18.784 Session activate
Nov 21 14:43:18.784 Authorization req
Nov 21 14:43:18.784 Authorization res
Nov 21 14:43:18.784 SUBDB produce done Start [many]
Nov 21 14:43:18.912 SUBDB produce done [many]
Nov 21 14:43:31.840 Session Update
Nov 21 14:43:31.840 Session Up


RP/0/RSP0/CPU0:shudder#clsub INTF=L2TP testuser2628-501@cisco VER=2
RP/0/RSP0/CPU0:shudder#event manager run clear_sub.tcl INTF=L2TP testuser2628-501@cisco VER=2
Thu Nov 23 16:50:07.944 UTC
CLEARSUB-2024-Nov-1-DEBUG:no key must be an username
CLEARSUB-2024-Nov-1-INFO:testuser2628-501@cisco used as client name
CLEARSUB-2024-Nov-1-DEBUG:CLIENT = clearing a client name
CLEARSUB-2024-Nov-1-DEBUG:executing show l2tpv2 session state | inc testuser2628-501@cisco

CLEARSUB-2024-Nov-1-DEBUG:Capturing l2tp info
CLEARSUB-2024-Nov-1-DEBUG:executing sh l2tpv2 session detail id 5128 38948
CLEARSUB-2024-Nov-1-DEBUG:executing sh l2tpv2 session detail id 5128 38948
CLEARSUB-2024-Nov-1-DEBUG:executing clear subscriber session identifier interface PW-Ether2.501.pppoe34998 force
Y

CLEARSUB-2024-Nov-1-INFO:L2Tp subscriber testuser2628-501@ciscocleared on interface PW-Ether2.501.pppoe34998

 

P/0/RSP0/CPU0:shudder#
RP/0/RSP0/CPU0:shudder#sh l2tpv2 session detail id 5128 38948
Thu Nov 23 16:51:14.414 UTC
% Requested item(s) not available
RP/0/RSP0/CPU0:shudder#
RP/0/RSP0/CPU0:shudder#show l2tpv2 session state | inc testuser2628-501@cisco
Thu Nov 23 16:51:30.333 UTC
9258 5449 5128 testuser2628-501@cisco, est 00:00:57 45937
RP/0/RSP0/CPU0:shudder#sh l2tpv2 session detail id 5128 9258
Thu Nov 23 16:51:44.509 UTC


Session id 9258 is up, tunnel id 5128, logical session id 53616
Remote session id is 5449, remote tunnel id 33333
Locally initiated session
Call serial number is 2028310848
Remote tunnel name is BSNS-ASR1002-1
Internet address is 10.74.128.1:1701
Local tunnel name is PALTEL
Internet address is 10.74.128.103:1701
IP protocol 17
Session is L2TP signaled
Session state is established, time since change 00:01:10
UDP checksums are enabled
Tie breaker is 0xa00e4e85704b0a02, enabled FALSE.
Sequencing is off
Conditional debugging is disabled
Unique ID is 45937
Session username is testuser2628-501@cisco
Interface PW-Ether2.501.pppoe45937

RP/0/RSP0/CPU0:shudder#

 

clear subscriber interface
==========================
RP/0/RSP0/CPU0:shudder#
RP/0/RSP0/CPU0:shudder#clsub INTF=PW-Ether2.501.pppoe45935 VER=2
RP/0/RSP0/CPU0:shudder#event manager run clear_sub.tcl INTF=PW-Ether2.501.pppoe45935 VER=2
Thu Nov 23 16:46:37.930 UTC
CLEARSUB-2024-Nov-1-DEBUG:INTF = Clearing interface
CLEARSUB-2024-Nov-1-DEBUG:executing clear subscriber session identifier interface PW-Ether2.501.pppoe45935 force
Y

CLEARSUB-2024-Nov-1-INFO:Subscriber cleared on interface PW-Ether2.501.pppoe45935


RP/0/RSP0/CPU0:shudder#
RP/0/RSP0/CPU0:shudder#
RP/0/RSP0/CPU0:shudder#show subscriber session filter username local30-501@pta detail
Thu Nov 23 16:47:15.982 UTC
Interface: PW-Ether2.501.pppoe45936
Circuit ID: Unknown
Remote ID: Unknown
Type: PPPoE:PTA
IPv4 State: Up, Thu Nov 23 16:46:52 2023
IPv4 Address: 77.92.169.62, VRF: default
Mac Address: 0011.0100.001e
Account-Session Id: 0000f780
Nas-Port: Unknown
User name: local30-501@pta
Formatted User name: unknown
Client User name: unknown
Outer VLAN ID: 501
Subscriber Label: 0x0001545c
Created: Thu Nov 23 16:46:52 2023

 

clear subscriber mac address
============================
RP/0/RSP0/CPU0:shudder#sh subscriber session filter mac-address 1666.0317.0a46 detail | inc Cre
Thu Nov 23 16:36:29.134 UTC
Created: Thu Nov 23 16:34:29 2023
RP/0/RSP0/CPU0:shudder#clsub MAC=1666.0317.0a46


RP/0/RSP0/CPU0:shudder#event manager run clear_sub.tcl MAC=1666.0317.0a46
Thu Nov 23 16:36:33.013 UTC

 

RP/0/RSP0/CPU0:shudder#sh subscriber session filter mac-address 1666.0317.0a46 detail | inc Cre
Thu Nov 23 16:37:25.623 UTC
Created: Thu Nov 23 16:36:47 2023


RP/0/RSP0/CPU0:shudder#clsub MAC=1666.0317.0a46 VER=1
RP/0/RSP0/CPU0:shudder#event manager run clear_sub.tcl MAC=1666.0317.0a46 VER=1
Thu Nov 23 16:38:09.265 UTC
CLEARSUB-2024-Nov-1-INFO:Subscriber with mac=1666.0317.0a46 cleared


Clear subscriber IP
====================

P/0/RSP0/CPU0:shudder#sh subscriber session filter interface PE2.501.pppoe45934
Thu Nov 23 16:45:30.774 UTC
Codes: IN - Initialize, CN - Connecting, CD - Connected, AC - Activated,
ID - Idle, DN - Disconnecting, ED - End

Type Interface State Subscriber IP Addr / Prefix
LNS Address
--------------------------------------------------------------------------------
RP/0/RSP0/CPU0:shudder#show subscriber session filter username local30-501@pta detail
Thu Nov 23 16:45:36.785 UTC
Interface: PW-Ether2.501.pppoe45935
Circuit ID: Unknown
Remote ID: Unknown
Type: PPPoE:PTA
IPv4 State: Up, Thu Nov 23 16:44:51 2023
IPv4 Address: 77.92.169.63, VRF: default
Mac Address: 0011.0100.001e
Account-Session Id: 0000f77f
Nas-Port: Unknown
User name: local30-501@pta
Formatted User name: unknown
Client User name: unknown
Outer VLAN ID: 501
Subscriber Label: 0x0001545b
Created: Thu Nov 23 16:44:50 2023
State: Activated, Thu Nov 23 16:44:51 2023

Authentication: authenticated
Authorization: unauthorized
Access-interface: PW-Ether2.501


clear subscriber username with default verbosity
=================================================
RP/0/RSP0/CPU0:shudder#clsub local21-501@pta
RP/0/RSP0/CPU0:shudder#event manager run clear_sub.tcl local21-501@pta
Sun Nov 26 20:18:11.686 UTC

RP/0/RSP0/CPU0:shudder#

clear subscriber username with info verbosity
=================================================
RP/0/RSP0/CPU0:shudder#clsub local21-501@pta VER=1
RP/0/RSP0/CPU0:shudder#event manager run clear_sub.tcl local21-501@pta VER=1
Sun Nov 26 20:20:54.812 UTC
CLEARSUB-2024-Nov-1-INFO:Subscriber local21-501@pta cleared on interface PE2.501.pppoe46169


RP/0/RSP0/CPU0:shudder#

clear subscriber username with debug verbosity
===============================================
RP/0/RSP0/CPU0:shudder#clsub local21-501@pta VER=2
RP/0/RSP0/CPU0:shudder#event manager run clear_sub.tcl local21-501@pta VER=2
Sun Nov 26 20:22:07.926 UTC
CLEARSUB-2024-Nov-1-DEBUG:no key must be an username
CLEARSUB-2024-Nov-1-DEBUG:Clearing subscriber local21-501@pta
CLEARSUB-2024-Nov-1-DEBUG:executing show subscriber session filter username local21-501@pta

CLEARSUB-2024-Nov-1-DEBUG:clearing interface PE2.501.pppoe46170
CLEARSUB-2024-Nov-1-DEBUG:executing clear subscriber session identifier interface PE2.501.pppoe46170 force
Y

CLEARSUB-2024-Nov-1-INFO:Subscriber local21-501@pta cleared on interface PE2.501.pppoe46170

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: