JUNOS: Loading factory default for JUNOS

Hi - so you want to wipe the JUNOS configuration and start again? One option I thought about was to go into configuration mode and delete everything:

root@cpe0-mx5# delete
This will delete the entire configuration
Delete everything under this level? [yes,no] (no) yes

But when I tried to commit that change I got told...no way

[edit]
root@cpe0-mx5# commit
error: cannot commit an empty configuration

So I tried to load the factory default configuration:

root@cpe0-mx5# load factory-default ?
Possible completions:
  <[Enter]>            Execute this command
  |                    Pipe through a command
[edit]
root@cpe0-mx5# load factory-default   
warning: activating factory configuration

But then again I was told that I needed to sat the root authentication password etc.

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

[edit]

So it's not quite a factory default config because I now need to set the root password! Bad news is you can't even choose a basic password like 'password' or toor or root because it has a minimum digits of 6 and requires a change of case and punctuation plus numbers!

Damn - hosed.

so how do you REALLY remove all the configuration? Well it turns out you have to go into the underlying filesystem and use the BSD binaries. so first of all come out of configuration mode. It'll ask you if you want to leave without commiting the changes - you can say yes

root@cpe0-mx5# exit
The configuration has been changed but not committed
Exit with uncommitted changes? [yes,no] (yes) yes

Exiting configuration mode

So now lets start the CLI for BSD.

root@cpe0-mx5> start shell


Go to the config directory using the 'cd' (Change Directory) command

root@cpe0-mx5% cd /config


Here is a listing of the files in there before we delete them.

root@cpe0-mx5% ls
.snap                   juniper.conf.2.gz       juniper.conf.md5
juniper.conf+.gz        juniper.conf.3.gz       usage.db
juniper.conf.1.gz       juniper.conf.gz


So now lets delete (remove - rm) the config files. It'll maybe error about one file because we don't have the rights to delete it...thats a good thing.

root@cpe0-mx5% rm -R *
override rw-r--r--  root/wheel sunlnk for usage.db? y
rm: usage.db: Operation not permitted


Now lets take a look...files gone?

root@cpe0-mx5% ls
.snap           usage.db

OK we're good lets do a reboot and hopefully it'll be a vanilla config now.

root@cpe0-mx5% reboot

So when the router comes back we're looking to see if it has forgotten everything and become an Amnesiac?

----output truncated-----

Amnesiac (ttyu0)

login: root

--- JUNOS 11.2R4.3 built 2011-11-24 07:54:28 UTC

root@%

Job Done!

© 2011 defaultrouteuk.com

Cisco, IOS, CCNA, CCNP, CCIE are trademarks of Cisco Systems Inc.
JunOS, JNCIA, JNCIP, JNCIE are registered trademark of Juniper Networks Inc.