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] Commit script to prevent interface deletion



Article ID: KB32973 KB Last Updated: 09 Jan 2020Version: 2.0

During provisioning on MX Series routers, users may accidentally delete a router's interface hierarchy by using delete interfaces, causing the entire router to be impacted. To prevent this accidental deletion of interfaces via misconfiguration, a commit script can be used.

This article gives the script that can be used to prevent such accidental deletion.



Deletion of all interfaces and potential loss of router



Accidental deletion due to misconfiguration


  1. Create a new file under /var/db/scripts/commit. Root access would be required.

cd /var/db/scripts/commit
vi interface.slax 

Paste and save the below lines:
version 1.0;
ns junos = "*/junos";
ns xnm = "";
ns jcs = "";
import "../import/junos.xsl";
match configuration {
call error-if-missing($must =
                        $statement = 'interfaces lo0 unit 0 family inet address');
error-if-missing ($must, $statement = "unknown", $message = "You deleted the interfaces, not allowed, go sit in your corner. Aborting! Missing mandatory configuration statement") {
    if (not($must)) {
        <xnm:error> {
            <edit-path> {
                copy-of $statement;
            <message> {
                copy-of $message;
  1. Apply the commit script to the configuration under system scripts:

system {
scripts {
    commit {
        file interface.slax;


lab@router-01# delete interfaces
lab@router-01# commit
interfaces lo0 unit 0 family inet address
  You deleted the interfaces, not allowed, go sit in your corner. Aborting! Missing mandatory configuration statement
error: 1 error reported by commit scripts
error: commit script failure


Modification History:

2020-01-09: Modified solution and added some changes to script


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