Support Support Downloads Knowledge Base Juniper Support Portal Community

Knowledge Base

Search our Knowledge Base sites to find answers to your questions.

Ask All Knowledge Base Sites All Knowledge Base Sites JunosE Defect (KA)Knowledge BaseSecurity AdvisoriesTechnical BulletinsTechnotes Sign in to display secure content and recently viewed articles

[MX] SLAX script to clear PPPoE subscribers in a specific IP Pool



Article ID: KB36267 KB Last Updated: 20 Oct 2020Version: 1.0

This article provides a script intended for use to clear a specific IP Pool in a router with BNG/PPPoE functions.


SLAX script:

version 1.1;
ns junos = "*/junos";

ns xnm = "";
ns jcs = "";
import "../import/junos.xsl";
var $arguments = {
    <argument> {
        <name> "pool";
        <description> "Address Pool";

param $pool;
var $con = jcs:open();
match / {
        <op-script-results> {
                if ($pool = '') {
                        <xnm:error> {
                                <message> "Missing mandatory argument 'pool'";
                else {
                        var $show_aaa_pool = {<command>"show network-access address-assignment pool " _ $pool;}
                        var $result = jcs:execute($con,$show_aaa_pool);
                        var $res_show_sub_cli_pppoe := {call get_show_sub_cli_pppoe();}
                        for-each($result/address-assignment-pool-table/address-assignment-pool-entry) {
                                var $sub_add = ip-address;
                                var $ppp_int = $res_show_sub_cli_pppoe//subscriber[ip-address == $sub_add]/interface;
                                call clear-ppp-sess($ppp_int);
template clear-ppp-sess ($ppp_int)
var $rpc2 = {<command>"clear pppoe sessions " _ $ppp_int;}
expr jcs:execute($con,$rpc2);
template get_show_sub_cli_pppoe() {
  var $res= jcs:execute($con,<command>"show subscribers client-type pppoe");
  for-each($res//subscriber/ip-address) {
    <subscriber> {
      <ip-address> .;
      <interface> ../interface;

The slax script must be saved in /var/db/scripts/op using root and given read and execute permissions. 

Under the configuration, add the next line,

          set system scripts op file <.slax script>

If you have primary RE and backup RE, remember to create the slax file under the mentioned directory in the backup RE.

To execute the slax script:
  1. Configure the "hold-down" to the IP pool to be cleared. Configuring Address-Assignment Pool Hold-Down

    set access address-assignment pool <POOL> hold-down 
  2. Once the "hold-down" is set, execute the slax script.

    labroot@router> op <slax script.slax> pool <configured pool name>

The script will take approximately 5-10 minutes to clear a /20 IP pool.  

The scope of this script is to work only for PPPoE v4 and dual stack subscribers. 
Comment on this article > Affected Products Browse the Knowledge Base for more articles related to these product categories. Select a category to begin.

Getting Up and Running with Junos

Getting Up and Running with Junos Security Alerts and Vulnerabilities Product Alerts and Software Release Notices Problem Report (PR) Search Tool EOL Notices and Bulletins JTAC User Guide Customer Care User Guide Pathfinder SRX High Availability Configurator SRX VPN Configurator Training Courses and Videos End User Licence Agreement Global Search