> 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/12-loading-configuration.md).

# 12) Loading Configuration

### Pre-Work

If you made any changes, you can quickly revert the lab using the **load\_config\_on\_nodes.py** script.

```
python3 load_config_on_nodes.py --lab_dir three-routers --config_filename basic.addressing.cfg
```

### Lab

Connect to R1, and apply the following changes to the candidate config file:

* Remove the inet6 address-family from ge-0/0/0
* Add two name-servers: 10.0.0.1 and 10.0.0.2

```
admin@R1> configure 
Entering configuration mode

[edit]
admin@R1# delete interfaces ge-0/0/0.0 family inet6   

[edit]
admin@R1# set system name-server 10.0.0.1 

[edit]
admin@R1# set system name-server 10.0.0.2    

[edit]
admin@R1# 

```

Do not commit yet. Just do a `show | compare`.

```
[edit]
admin@R1# show | compare 
[edit system]
+  name-server {
+      10.0.0.1;
+      10.0.0.2;
+  }
[edit interfaces ge-0/0/0 unit 0]
-      family inet6 {
-          address 2001:db8:1:2::1/64;
-      }

[edit]
admin@R1# 
```

Apply these changes to both R2 and R3 by applying the output from the `show | compare` taken on R1. (Do not apply the `set`/`delete` commands to R2 and R3 like you did on R1.)

### Answer

<details>

<summary>Expand to reveal</summary>

To load configuration from one router's `show | compare` output to another router, we must use `load patch terminal`:

```
admin@R2> configure 
Entering configuration mode

[edit]
admin@R2# load patch terminal 
[Type ^D at a new line to end input]

```

\
You must copy and paste the entire output, including the path in brackets (\[edit...]), +/- symbols, curly braces, etc.&#x20;

```
[edit]
admin@R2# load patch terminal 
[Type ^D at a new line to end input]
[edit system]
+  name-server {
+      10.0.0.1;
+      10.0.0.2;
+  }
[edit interfaces ge-0/0/0 unit 0]
-      family inet6 {
-          address 2001:db8:1:2::1/64;
-      }
[edit interfaces ge-0/0/0 unit 0 family inet6]
  'address 2001:db8:1:2::1/64'
    warning: statement does not exist
[edit interfaces ge-0/0/0 unit 0 family inet6]
  'address'
    warning: patch removes statement that is not empty
load complete (2 errors)

[edit]
admin@R2# 
```

\
We can verify the `load patch` worked using `show | compare` on R2:

```
[edit]
admin@R2# show | compare 
[edit system]
+  name-server {
+      10.0.0.1;
+      10.0.0.2;
+  }
[edit interfaces ge-0/0/0 unit 0]
-      family inet6 {
-          address 2001:db8:1:2::2/64;
-      }

[edit]
admin@R2# 
```

\
Note that there is a warning because the specific IPv6 address on ge-0/0/0.0 is different, but the result is still the same. Since we are deleting `family inet6`, the address will be deleted too.

</details>

### Explanation

<details>

<summary>Expand to reveal</summary>

There are many `load` options/types that Junos offers. The one we are using for this lab is `load patch`. The term "patch" comes from the diff output that is generated when using `show | compare`.

\
Using the `terminal` option with `load patch` allows us to paste the patch output directly into the terminal. The other option would be to load in the text from a file. The file could be local on the device, or loaded through the network (scp, http, etc.).

\
There are many `load` options, and it can get a bit confusing. I would highly recommend reading through this resource: <https://www.networkcuriosity.com/junos-load-command/>

\
Below is a summary of the `load` options. I feel it would be a bit tedious to have separate labs for each of these in this workbook, but feel free to test these out yourself in your own lab.

<table><thead><tr><th width="98">Load type</th><th width="116">Requires a full config</th><th>Behavior</th><th>Notes</th></tr></thead><tbody><tr><td><code>override</code></td><td>Yes</td><td>Discards the entire configuration, and replaces it with the loaded configuration.</td><td>Often used when loading a full configuration file onto the device.</td></tr><tr><td><code>merge</code></td><td>No</td><td>Merges changes from the provided configuration into the existing configuration. Existing configuration is retained if the provided configuration does not update it.</td><td>Be careful when using this, as the behavior could be different than you expect. For example, instead of replacing an interface address, you can have a second address added alongside the existing interface address.</td></tr><tr><td><code>patch</code></td><td>No</td><td>Uses a patch file, generated from <strong>show | compare</strong>, to quickly apply the equivalent of <strong>set</strong> and <strong>delete</strong> commands from one device to another.</td><td>This is the mode we learned in this lab. It makes it easy to copy/paste config changes from one device to another.</td></tr><tr><td><code>replace</code></td><td>No</td><td>Overrides a specific section of the config, looking for a <em>replace</em> tag in the provided configuration file. Where there is no <em>replace</em> tag, the behavior is the same as merge.</td><td>This can be useful to control which sections of the config are replaced, and which sections behave as a merge instead. This could be used to fix the issue with the interface address noted above in the <strong>merge</strong> type.</td></tr><tr><td><code>update</code></td><td>Yes</td><td>Similar to override, but does not fully discard the existing config. It will update the existing configuration where there is any difference in the provided configuration.</td><td>I don't see a major use case for this over the override type. There is a small difference in how Junos will parse the config upon commit. With <strong>override</strong>, everything is processed. With <strong>update</strong>, only the changes are processed. So if only one section is different, then <strong>update</strong> can be more efficient. I'm also not sure if it helps prevent resetting protocols/etc, which maybe could happen with <strong>override</strong>?</td></tr></tbody></table>

</details>

### Further Reading

[https://www.juniper.net/documentation/us/en/software/junos/cli/topics/topic-map/junos-config-files-loading.html](<https://www.juniper.net/documentation/us/en/software/junos/cli/topics/topic-map/junos-config-files-loading.html&#xA;&#xA;https://community.juniper.net/discussion/load-replace-load-override&#xA;>)

[https://community.juniper.net/discussion/load-replace-load-override](<https://www.juniper.net/documentation/us/en/software/junos/cli/topics/topic-map/junos-config-files-loading.html&#xA;&#xA;https://community.juniper.net/discussion/load-replace-load-override&#xA;>)
