> 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/17-interface-configuration.md).

# 17) Interface Configuration

### Pre-Work

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

```
python3 load_config_on_nodes.py --lab_dir three-routers --config_filename interface.config.cfg
```

### Lab

Connect to R1, and configure ge-0/0/0 as follows:

* IP address `10.1.2.1/24`
* IPv6 address `2001:db8:1:2::1/64`
* L2 MTU `9000`
* Description `"Connection to R2"`

Configure the loopback as follows:

* IP address `1.1.1.1/32`
* IPv6 address `2001:db8::1/128`

### Answer

<details>

<summary>Expand to reveal</summary>

```
set interfaces ge-0/0/0 description "Connection to R2"
set interfaces ge-0/0/0 mtu 9000
set interfaces ge-0/0/0 unit 0 family inet address 10.1.2.1/24
set interfaces ge-0/0/0 unit 0 family inet6 address 2001:db8:1:2::1/64

set interfaces lo0 unit 0 family inet address 1.1.1.1/32
set interfaces lo0 unit 0 family inet6 address 2001:db8::1/128
```

</details>

### Explanation

<details>

<summary>Expand to reveal</summary>

In Junos, interface configuration is split into physical configuration and logical configuration. Items such as the description and L2 MTU are configured on the physical interface.

```
set interfaces ge-0/0/0 description "Connection to R2"
set interfaces ge-0/0/0 mtu 9000
```

\
L3 items such as the IPv4/IPv6 address are configured on the logical interface. (This should intuitively make sense - physical config goes on the physical interface, and logical config goes on the logical interface/unit). In Junos, the logical interface must have a `unit` number, which is similar to a subinterface in Cisco. Typically you will use `unit 0` when there is no VLAN encapsulation. Additionally, logical configuration goes under the corresponding `family`, for example `family inet` for IPv4 and `family inet6` for IPv6.

```
set interfaces ge-0/0/0 unit 0 family inet address 10.1.2.1/24
set interfaces ge-0/0/0 unit 0 family inet6 address 2001:db8:1:2::1/64
```

\
Also note that as a shorthand, you can do `ge-0/0/0.0` instead of `ge-0/0/0 unit 0`.

```
set interfaces ge-0/0/0.0 family inet address 10.1.2.1/24
set interfaces ge-0/0/0.0 family inet6 address 2001:db8:1:2::1/64
```

\
These same principles apply to the loopback interface.

```
set interfaces lo0.0 family inet address 1.1.1.1/32
set interfaces lo0.0 family inet6 address 2001:db8::1/128
```

\
Unlike on IOS, we cannot create multiple loopback interfaces.

```
[edit]
admin@R1# set interfaces lo1 uni
                         ^
device value outside range 0..0 for '1' in 'lo1'.
```

\
Nor can we assign multiple units to the loopback. (However, we can have multiple units on Lo0 if they are in different routing-instances. You will see routing-instances in the *Junos Routing* section).

```
admin@R1# set interfaces lo0 unit 1 family inet address 1.2.3.4/24 

[edit]
admin@R1# commit 
[edit interfaces lo0]
  'unit 1'
    if_instance: Multiple loopback interfaces not permitted in master routing instance
error: configuration check-out failed

```

\
If you need more loopback IP addresses, you would just assign multiple IPs to lo0.0. (There is no such thing as a secondary address in Junos. See the previous lab, *Editing Configuration (Part 1)* for more details).

```
set interfaces lo0 unit 0 family inet address 1.1.1.1/32
set interfaces lo0 unit 0 family inet address 1.2.3.4/24
```

\
We should now be able to ping R2:

```
admin@R1> ping 10.1.2.2 
PING 10.1.2.2 (10.1.2.2): 56 data bytes
64 bytes from 10.1.2.2: icmp_seq=0 ttl=64 time=28.333 ms
64 bytes from 10.1.2.2: icmp_seq=1 ttl=64 time=1.626 ms

admin@R1> ping 2001:db8:1:2::2 
PING6(56=40+8+8 bytes) 2001:db8:1:2::1 --> 2001:db8:1:2::2
16 bytes from 2001:db8:1:2::2, icmp_seq=0 hlim=64 time=486.540 ms
16 bytes from 2001:db8:1:2::2, icmp_seq=1 hlim=64 time=1.557 ms
```

\
We can also check the MTU. Note that the L3 MTU (`protocol inet` and `inet6`) are automatically 14 bytes less than the L2 (Ethernet) MTU.

```
admin@R1> show interfaces ge-0/0/0 | match "ge-0/0/0|MTU"     
Physical interface: ge-0/0/0, Enabled, Physical link is Up
  Link-level type: Ethernet, MTU: 9000, MRU: 9008, LAN-PHY mode, Speed: 1000mbps, BPDU Error: None,
  Logical interface ge-0/0/0.0 (Index 345) (SNMP ifIndex 552)
    Protocol inet, MTU: 8986
    Protocol inet6, MTU: 8986
    Protocol multiservice, MTU: Unlimited

```

\
We can also see interface descriptions:

```
admin@R1> show interfaces descriptions 
Interface       Admin Link Description
ge-0/0/0        up    up   Connection to R2
```

</details>

### Further Reading

<https://community.juniper.net/discussion/what-is-the-concept-and-meaning-of-unit0-in-configuring-the-interfaces>

<https://juliopdx.com/2021/12/06/my-journey-learning-about-juniper-junos/#configuring-junos>

<https://www.dasblinkenlichten.com/interface-basics-on-the-juniper-mx/>
