The usage of Junos Commit command

We already know from the previous lessons that the command “commit” allow us to save the configure on the router, specifically to save the candidate configuration to the active configuration.

However, there are many options that we can use with the “commit” command, and in this lesson I am going to explore all of them.

Those can be seen here:

root@R1# commit ?

Possible completions:

<[Enter]>           Execute this command

and-quit              Quit configuration mode if commit succeeds

at                        Time at which to activate configuration changes

check                  Check correctness of syntax; do not apply changes

comment            Message to write to commit log

confirmed           Automatically rollback if not confirmed

|                           Pipe through a command

You can see, we can write many completion commands after the commit, and that’s what I am going to explore in this lesson.

Let’s start by creating a new user and before I create a class for this I will make a commit and see what I will get:

root@R1# edit system login user John

[edit system login user John]

root@R1# set authentication plain-text-password

New password:

Retype new password:

 

[edit system login user John]

root@R1# commit

[edit system login]

‘user John’

Missing mandatory statement: ‘class’

error: commit failed: daemon file propagation failed

 

[edit system login user John]

root@R1#

After I have crated the user John and gave him a password, when I tried to commit I got an error that I should also provide a class to this user. So what we can understand here is that the command “commit” does not only save the candidate configuration to the active configuration, but it also check if the configuration is complete before it commits it.

Now let’s create the class for this user and do “commit check” and see what it is all about:

[edit system login user John]

root@R1# set class super-user

[edit system login user John]

root@R1# commit check

configuration check succeeds

[edit system login user John]

root@R1#

The command “commit check” has a function check if the configuration that we have written is correct. However, a very important note to mention here is that “commit check” command does not save the configuration, meaning that after you apply it you need to follow it with a “commit” command to be able to save the configuration from the candidate configuration to the active configuration on the Juniper router.

The other command that I want to show you about is the “commit at”. Using this command, you can schedule when the commit has to happen by giving a date and time in the future, then once that date/time is reached, the Juniper router will make the commit and copy the candidate configuration to the active configuration.

Let’s say I want the configuration to be saved on 25 February 2024 at 18:00 hour. Let me show you how you can do that:

root@R1# commit at “2024-02-25 18:00”

configuration check succeeds

commit at will be executed at 2024-02-25 18:00:00 UTC

The configuration has been changed but not committed

Exiting configuration mode

root@R1>

The Juniper router does not show you how you can write the format of the date/time, so please use the format that I am showing you here in this example. Now my configuration is scheduled to be saved on 25th of February 2024 at 18:00 hour. Please note that once you use the “commit at” and you apply it, it will take you out to the operational mode.

Let’s say now that for some reason, I have decided to remove the schedule commit that I have created. Let me show you how you can do that:

root@R1> clear system commit

Pending commit cleared

root@R1>

From the operational mode, you need to write the command “clear system commit” and it will clear the schedule commit that we have recently created.

The other command that I want to show you is “commit confirmed”. Using this command, you can commit the configuration for few minutes to test if the changes that you have made is working properly. Then after the minutes are expired, and in case you don’t follow the “commit confirmed” command by another “commit”, then it will revert back to the old configuration that was on the router before you made the changes. This is an ideal solution specifically for Juniper network engineers who sometimes are required to make changes on a Juniper router remotely, sitting very far from them, so in case any mistake is done on the configuration and it is saved, the engineer may lose connectivity to the router which can be a catastrophic problem. Using “commit confirmed” you can do the changes and give it for example 2 minutes as timeout, then the configuration is saved for 2 minutes and in these 2 minutes you can check if everything is working fine, if not then you wait for the 2 minutes to be expired and the Juniper router goes back to the configuration before the changes that you have done, and if yes then you can write “commit” again to save permanently the configuration on the router.

Please note that in case you do not define the timeout for the “commit check”, then Juniper router takes 10 minutes by default.

Let’s apply it for 2 minutes then follow a commit to save everything:

root@R1# commit confirmed 2

commit confirmed will be automatically rolled back in 2 minutes unless confirmed

commit complete

[edit]

root@R1# commit

commit complete

[edit]

root@R1#

One other option that we have with “commit” command is “commit comment”. When using this, I can give a comment to the commit so I know that that commit was done for the following change.

Let’s change the router hostname to R2 and make a “commit comment” and leave a comment that the router name has been changed to R2:

root@R1# set system host-name R2

[edit]

root@R1# commit comment “The router name has been changed to R2”

commit complete

[edit]

root@R2#

This has been done successfully. Now, where I can find the comment? Let me show you that:

root@R2# exit

Exiting configuration mode

root@R2> show system commit

0   2024-02-05 10:02:26 UTC by root via cli

The router name has been changed to R2

1   2024-02-05 09:58:41 UTC by root via cli

2   2024-02-05 09:58:38 UTC by root via cli commit confirmed, rollback in 2mins

3   2024-02-05 09:52:35 UTC by root via cli

4   2024-02-05 09:52:28 UTC by root via cli commit confirmed, rollback in 10mins

5   2024-02-05 09:32:13 UTC by root via cli

6   2024-02-04 13:52:08 UTC by root via cli

root@R2>

You have to go to the operational mode and write “show system commit” then it will show you the comment that you wrote with the commit command.

The last command that I want to show you in this lesson is the “commit and-quit”. Using this command, the Juniper router will save the configuration and in case it is successfully then it will quit from the configuration mode to the operational mode.

Let me show you that:

root@R2# commit and-quit

commit complete

Exiting configuration mode

root@R2>

Indeed, the configuration has been committed successfully and the router went to the operational mode  when using the command “commit and-quit”.

This is all what I wanted to show you in this lesson and in this chapter, I hope you are enjoying the lessons up to now, and see you in the upcoming one 😊

Course Content

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

About