> For the complete documentation index, see [llms.txt](https://jncia-workbook.gitbook.io/workbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jncia-workbook.gitbook.io/workbook/junos-basics/3-restore-factory-default-config-method-2.md).

# 3) Restore Factory-Default Config (Method 2)

There is another method to reset the configuration that is not as "forceful."

Telnet to R2 (`telnet 10.200.255.3 5000`). (R1 is already on the default configuration if you completed the previous lab, so we'll move to R2 now). Reset the configuration to factory-default, ensuring that all log files, and other settings are kept intact.

### Answer

<details>

<summary>Expand to reveal</summary>

Use the configuration command `load factory-default`

```
admin@R2# load factory-default    
warning: activating factory configuration

[edit]

```

\
You can see what will change by using `show | compare`

```
admin@R2# show | compare 
[edit]
- version 25.4R1.12;
[edit system]
-  host-name R2;
-  root-authentication {
-      encrypted-password "$6$dMRWC12Y$mg8BTFhtlrCH60zYXvFkg92bgAN1du6cszpqnR4Xco3o9JEzQacgWPP1GpFSCL.jQi3HOOTr0uKhjRks98Rh8/"; ## SECRET-DATA
-  }
+  commit {
+      factory-settings;
+  }
-  login {
-      user admin {
-          uid 2000;
-          class super-user;
-          authentication {
-              encrypted-password "$6$XPIIkGMt$qa.TG2jPMIJnd/jGBTbOu.uZwrweJFfoGVMCxtFHX8CTur0hyi7UcJu4TR0DEfvDYgcvwh4dP8zY5mM6hOBkN1"; ## SECRET-DATA
-          }
-      }
-  }
-  services {
-      netconf {
-          ssh;                         
-      }
-      ssh {
-          root-login allow;
-      }
-  }
-  management-instance;
+  syslog {
+      file interactive-commands {
+          interactive-commands any;
+      }
+      file messages {
+          any notice;
+          authorization info;
+      }
+  }
[edit]
-  chassis {
-      fpc 0 {
-          pic 0 {
-              number-of-ports 12;
-          }
-      }
-  }                                    
-  interfaces {
-      fxp0 {
-          unit 0 {
-              family inet {
-                  address 10.0.0.15/24;
-              }
-              family inet6 {
-                  address 2001:db8::2/64;
-              }
-          }
-      }
-  }
-  routing-instances {
-      mgmt_junos {
-          routing-options {
-              rib mgmt_junos.inet6.0 {
-                  static {
-                      route ::/0 next-hop 2001:db8::1;
-                  }
-              }
-              static {
-                  route 0.0.0.0/0 next-hop 10.0.0.2;
-              }                        
-          }
-      }
-  }

[edit]
admin@R2# 

```

\
Enter `commit`**.** Notice that you cannot commit without entering a root password:

```
admin@R2# commit 
[edit]
  'system'
    Missing mandatory statement: 'root-authentication'
error: commit failed: (missing mandatory statements)

[edit]

```

* This is a general rule - you cannot commit any configuration if the root password is not set. As we saw in the previous lab, the default configuration does not have a root password. So we have to set one in order to commit the factory-default config.
* Interestingly, it seems that on some systems, after you reboot, this root password you just set is lost. The factory-default config will be "re-loaded" after the reboot, and the root password you set just now will be gone. On this vJunos-router, this is not the case. The root password is retained upon the first boot on the factory-default config.

\
Enter a new root password, and then `commit`**:**

```
admin@R2# set system root-authentication plain-text-password 
New password:
Retype new password:

[edit]
admin@R2# commit 

```

\
Reboot the router.

```
admin@R2# exit 
Exiting configuration mode

admin@R2> request system reboot 
Reboot the system ? [yes,no] (no) yes
```

\
Notice that since our **admin** user no longer exists, we cannot run this command:

```
mgd: unable to switch user admin: No such file or directory
```

\
If you logged in with **root** instead, you would not see this message, and the reboot would work.

\
If you are logged as **admin**, then `exit`, login as **root** with the password you just set, start the `cli`, and then reboot.

```
admin@R2> exit 


FreeBSD/amd64 (R2) (ttyu0)

login: root
Password:
Last login: Tue Dec 16 17:42:21 on ttyu0

--- JUNOS 25.4R1.12 Kernel 64-bit  JNPR-15.0-20251024.861cae5_buil
root@R2:~ # cli
root@R2> request system reboot 
Reboot the system ? [yes,no] (no) yes 

                                                                               
*** FINAL System shutdown message from root@R2 ***    
```

* Only the root user is presented with the underlying bash shell upon login, requiring you to run the **cli** command. All other users are presented with the Junos cli instead.

\
Notice that the hostname is **Amnesiac** again, like we saw in the previous lab.

```
FreeBSD/amd64 (Amnesiac) (ttyu0)

login: 

```

\
Be aware that this is *not* an acceptable way to wipe a router for decommissioning purposes. We can see that the router still retains logs and configuration files. Try using `show system commit` and `show log` to see that our previous config and log files are still present on the router. (This is *not* the case when using `request system zeroize`).

</details>

### Explanation

<details>

<summary>Expand to reveal</summary>

The `load` command loads configuration from multiple possible sources - a file, the terminal, etc. In addition, you can load the factory-default configuration. This is, as the name suggests, the default configuration as the device would come straight from the factory.

\
As explained above, you the factory default configuration does not contain a root password. However, you cannot commit a configuration that does not have a root password. Therefore, after loading the factory-default config, we must also manually add a root password.

\
Upon committing, the device will be on the factory-default config. However, you will still see the old hostname in the prompt. You would need to fully reboot the device in order to see the **Amnesiac** hostname prompt.

\
Using `load factory-default` is a less-intensive wipe method. With `request system zeroize`, we wipe all files, including the config. With `load factory-default`, we simply wipe the configuration, while retaining all other files on the system.

</details>

### Further Reading

<https://www.juniper.net/documentation/us/en/software/junos/cli/topics/topic-map/junos-factory-default.html>

<https://www.youtube.com/watch?v=LLKXsHx5c7w>
