> 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/14-editing-configuration-part-1.md).

# 14) Editing Configuration (Part 1)

### Pre-Work

Load the config called **wrong.addressing.cfg** using the **load\_config\_on\_nodes.py** script.

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

### Lab

Currently, R1 cannot ping R2 at 10.1.2.2.

```
admin@R1> ping 10.1.2.2 
PING 10.1.2.2 (10.1.2.2): 56 data bytes
ping: sendto: No route to host
```

The interface is set incorrectly:

```
admin@R1> show interfaces ge-0/0/0.0 terse   
Interface               Admin Link Proto    Local                 Remote
ge-0/0/0.0              up    up   inet     10.100.2.1/24   
                                   inet6    2001:db8:1:2::1/64
                                            fe80::aac1:abff:fefa:30ab/64
                                   multiservice

admin@R1> 
```

Change the interface address to 10.1.2.1/24.

### Answer

<details>

<summary>Expand to reveal</summary>

Make sure to `delete` the existing address and `set` the new one:

```
admin@R1> configure 
Entering configuration mode

[edit]
admin@R1# delete interfaces ge-0/0/0.0 family inet address 10.100.2.1/24 

[edit]
admin@R1# set interfaces ge-0/0/0.0 family inet address 10.1.2.1/24 

[edit]
admin@R1# show | compare 
[edit interfaces ge-0/0/0 unit 0 family inet]
+       address 10.1.2.1/24;
-       address 10.100.2.1/24;

[edit]
admin@R1# commit 
commit complete

[edit]
admin@R1# 

```

</details>

### Explanation

<details>

<summary>Expand to reveal</summary>

Junos allows multiple IP addresses on an interface. You don't need the **secondary** keyword like in IOS. It is a common mistake to think that just using a `set` command will change the address. What will actually happen is you will add another address alongside the existing one:

```
admin@R1> configure 
Entering configuration mode

[edit]
admin@R1# set interfaces ge-0/0/0.0 family inet address 10.1.2.1/24 

[edit]
admin@R1# show | compare 
[edit interfaces ge-0/0/0 unit 0 family inet]
        address 10.100.2.1/24 { ... }
+       address 10.1.2.1/24;

[edit]
admin@R1# commit 
commit complete

[edit]
admin@R1# exit  
Exiting configuration mode

admin@R1> show interfaces ge-0/0/0.0 terse    
Interface               Admin Link Proto    Local                 Remote
ge-0/0/0.0              up    up   inet     10.1.2.1/24     
                                            10.100.2.1/24   
                                   inet6    2001:db8:1:2::1/64
                                            fe80::aac1:abff:fefa:30ab/64
                                   multiservice

admin@R1> 

```

\
For this reason, we must `delete` the existing address and then `set` the new address.

\
The CLI context-sensitive help actually tells you whether a configuration setting takes multiple values or one value. A `>` symbol means that the command creates a lower level in the hierarchy. From what I understand, you can assume that there can be multiple of these. For example, `address` is actually a lower hierarchy, underneath `family inet`:

```
amdin@R1# set interfaces ge-0/0/0 unit 0 family inet ?
Possible completions:
  <[Enter]>            Execute this command
> address              Interface address/destination prefix

[edit]
admin@R1# show interfaces 
ge-0/0/0 {
    unit 0 {
        family inet {
            address 1.1.1.1/32;
            address 1.1.1.2/32;
        }
    }
}

```

\
The `+` symbol means that you can have multiple values, and they will all be at the same hierarchy:

```
[edit]
admin@R1# set system ?                              
+ authentication-order  Order in which authentication methods are invoked

[edit]
admin@R1# set system authentication-order radius     

[edit]
admin@R1# set system authentication-order tacplus      

[edit]
admin@R1# show system authentication-order 
authentication-order [ radius tacplus ];

```

\
An absence of a `>` or `+` symbol means you can only have one single value:

```
root@R1# set system ?
  host-name            Hostname for this router

[edit]
root@R1# set system host-name NAME1 

[edit]
root@R1# set system host-name NAME2    

[edit]
root@R1# show system host-name 
host-name NAME2;
```

\
Note that having multiple addresses on an interface can cause some ambiguity when the system has to choose only one address to source traffic from. There are two keywords to control this:

* `preferred` - When you have multiple addresses in the same subnet, this is the address used when sourcing traffic on that subnet. In other words, this controls the source when the destination is on the same subnet.
* `primary` - The source used when traffic is sent to a different subnet.

\
By default, the lowest IP address overall is the primary address, and the lowest IP address for a given subnet is the preferred address for that subnet.

</details>

### Further Reading

<https://supportportal.juniper.net/s/article/Multiple-address-on-a-single-logical-interface>

<https://fryguy.net/2019/09/30/junos-primary-and-preferred-interface-commands/>
