> 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-routing/1-static-routing.md).

# 1) Static Routing

### Pre-Work

Load the config called **basic.addressing.cfg** 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 configure two static routes so that R1 can ping R2's loopback addresses:

* `2.2.2.2/32` via `10.1.2.2`
* `2001:db8::2/128` via `2001:db8:1:2::2`

### Answer

<details>

<summary>Expand to reveal</summary>

```
set routing-options static route 2.2.2.2/32 next-hop 10.1.2.2
set routing-options rib inet6.0 static route 2001:db8::2/128 next-hop 2001:db8:1:2::2
```

</details>

### Explanation

<details>

<summary>Expand to reveal</summary>

On Junos, static routes are not configured under the `protocols` section. Instead they are configured under the `routing-options` section. For IPv6 routes, we must specify that the rib is inet6.0. By default, the rib is inet.0 (IPv4).

\
Using `show route`, we can see all routing tables in total. This even includes other routing-instances, such as the mgmt\_junos routing instance which is used for clab management. (We will look at routing-instances in a later lab).

```
admin@R1> show route 

inet.0: 4 destinations, 4 routes (4 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

1.1.1.1/32         *[Direct/0] 00:01:03
                    >  via lo0.0
2.2.2.2/32         *[Static/5] 00:00:31
                    >  to 10.1.2.2 via ge-0/0/0.0
10.1.2.0/24        *[Direct/0] 00:01:03
                    >  via ge-0/0/0.0
10.1.2.1/32        *[Local/0] 00:01:03
                       Local via ge-0/0/0.0

mgmt_junos.inet.0: 3 destinations, 3 routes (3 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

0.0.0.0/0          *[Static/5] 00:02:04
                    >  to 10.0.0.2 via fxp0.0
10.0.0.0/24        *[Direct/0] 00:02:05
                    >  via fxp0.0
10.0.0.15/32       *[Local/0] 00:02:05
                       Local via fxp0.0

inet6.0: 7 destinations, 7 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

2001:db8::1/128    *[Direct/0] 00:01:03
                    >  via lo0.0
2001:db8::2/128    *[Static/5] 00:00:31
                    >  to 2001:db8:1:2::2 via ge-0/0/0.0
2001:db8:1:2::/64  *[Direct/0] 00:00:52
                    >  via ge-0/0/0.0
2001:db8:1:2::1/128*[Local/0] 00:00:52
                       Local via ge-0/0/0.0
fe80::e00:150f:fc29:1800/128
                   *[Direct/0] 00:01:03
                    >  via lo0.0
fe80::aac1:abff:fe1a:b8ba/128
                   *[Local/0] 00:00:52
                       Local via ge-0/0/0.0
ff02::2/128        *[INET6/0] 00:01:03
                       MultiRecv

mgmt_junos.inet6.0: 4 destinations, 4 routes (4 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

::/0               *[Static/5] 00:02:04
                    >  to 2001:db8::1 via fxp0.0
2001:db8::/64      *[Direct/0] 00:02:05
                    >  via fxp0.0
2001:db8::2/128    *[Local/0] 00:02:05
                       Local via fxp0.0
fe80::e00:15ff:fe29:1800/128
                   *[Local/0] 00:02:05
                       Local via fxp0.0
```

\
R1 should now be able to ping R2's loopback addresses:

```
admin@R1> ping 2.2.2.2 
PING 2.2.2.2 (2.2.2.2): 56 data bytes
64 bytes from 2.2.2.2: icmp_seq=0 ttl=64 time=1.698 ms
64 bytes from 2.2.2.2: icmp_seq=1 ttl=64 time=1.685 ms

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

\
Junos stores routes for each protocol in a separate table. IPv4 goes in the `inet.0` table, IPv6 in the `inet6.0` table, multicast in the `inet.1` table, MPLS forwarding in the `mpls.0` table, etc. We can filter the `show route` output to only show one particular table/address-family using `show route table`:

```
admin@R1> show route table inet.0 

inet.0: 4 destinations, 4 routes (4 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

1.1.1.1/32         *[Direct/0] 00:01:33
                    >  via lo0.0
2.2.2.2/32         *[Static/5] 00:01:01
                    >  to 10.1.2.2 via ge-0/0/0.0
10.1.2.0/24        *[Direct/0] 00:01:33
                    >  via ge-0/0/0.0
10.1.2.1/32        *[Local/0] 00:01:33
                       Local via ge-0/0/0.0
```

\
We can also filter on the protocol. To see static routes we would use protocol static:

```
admin@R1> show route table inet.0 protocol static 

inet.0: 4 destinations, 4 routes (4 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

2.2.2.2/32         *[Static/5] 00:01:15
                    >  to 10.1.2.2 via ge-0/0/0.0
```

\
Junos has some nice shortcuts built-in to the show route command. For example, on IOS we have to use `longer-prefixes` to see all routes for longer prefixes within a given prefix. But this is the default behavior on Junos. (To avoid this, you can use the `exact` keyword).

```
admin@R1> show route table inet.0 10.1.0.0/16 

inet.0: 4 destinations, 4 routes (4 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.1.2.0/24        *[Direct/0] 00:02:09
                    >  via ge-0/0/0.0
10.1.2.1/32        *[Local/0] 00:02:09
                       Local via ge-0/0/0.0
```

\
We can also do some shortcuts like `show route 10/8`:

```
admin@R1> show route table inet.0 10/8           

inet.0: 4 destinations, 4 routes (4 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

10.1.2.0/24        *[Direct/0] 00:02:21
                    >  via ge-0/0/0.0
10.1.2.1/32        *[Local/0] 00:02:21
                       Local via ge-0/0/0.0
```

\
Similar to other vendors, `show route` views the RIB which holds all possible routes. The FIB is viewed via `show route forwarding-table`, which displays the best routes which were sent from the RIB to the FIB. By default, there is no ECMP on Junos. Instead, if there are two equal cost routes for a destination, one is installed at random into the forwarding-table.

\
Note that when viewing the forwarding-table, the table becomes `default.inet` and `default.inet6` instead of `inet.0` and `inet6.0`.

```
admin@R1> show route forwarding-table                  
Routing table: default.inet
Internet:
Destination        Type RtRef Next hop           Type Index    NhRef Netif
default            perm     0                    rjct       36     1
0.0.0.0/32         perm     0                    dscd       34     1
1.1.1.1/32         intf     0 1.1.1.1            locl      596     1
2.2.2.2/32         user     0 10.1.2.2           ucst      600     3 ge-0/0/0.0
10.1.2.0/24        intf     0                    rslv      587     1 ge-0/0/0.0
10.1.2.0/32        dest     0 10.1.2.0           recv      585     1 ge-0/0/0.0
10.1.2.1/32        intf     0 10.1.2.1           locl      586     2
10.1.2.1/32        dest     0 10.1.2.1           locl      586     2
10.1.2.2/32        dest     0 aa:c1:ab:89:9a:61  ucst      600     3 ge-0/0/0.0
10.1.2.255/32      dest     0 10.1.2.255         bcst      584     1 ge-0/0/0.0
224.0.0.0/4        perm     0                    mdsc       35     1
224.0.0.1/32       perm     0 224.0.0.1          mcst       31     1
255.255.255.255/32 perm     0                    bcst       32     1

<snip>
```

</details>

### Further Reading

<https://www.youtube.com/watch?v=D8YZmg0ywW0&list=PLDQaRcbiSnqHAGz-wapjtd3zQxUg-a8dU&index=15&pp=iAQB>

<https://networkengineering.stackexchange.com/questions/22505/difference-between-show-route-forwarding-table-and-show-pfe-route-ip-in-juno>

<https://www.juniper.net/documentation/us/en/software/junos/cli-reference/topics/ref/command/show-route-forwarding-table.html>

<https://www.juniper.net/documentation/us/en/software/junos/junos-overview/topics/concept/junos-software-routing-forwarding-table-overview.html>
