> 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-policy/9-selective-redistribution-part-3.md).

# 9) Selective Redistribution (Part 3)

### Pre-Work

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

```
python3 load_config_on_nodes.py --lab_dir three-routers --config_filename policy.cfg
```

### Lab

<figure><img src="/files/hT9phUe7AGNPecRdaAML" alt=""><figcaption></figcaption></figure>

All routing (static routes, OSPFv2, and BGP) is already setup.

Configure R1 to redistribute all static routes into OSPF. Use a route policy that only permits prefixes 10.0.0.0/16 and 10.0.1.0/24. **This time, use a method that does not define the route-filter within the policy.**

### Answer

<details>

<summary>Expand to reveal</summary>

```
set policy-options prefix-list STATIC_TO_OSPF 10.0.0.0/16 
set policy-options prefix-list STATIC_TO_OSPF 10.0.1.0/24  

edit policy-options policy-statement STATIC_TO_OSPF 
set from protocol static
set from prefix-list STATIC_TO_OSPF
set then accept

top
set protocols ospf export STATIC_TO_OSPF
```

</details>

### Explanation

<details>

<summary>Expand to reveal</summary>

Besides using an inline `route-filter`, we can also use a `prefix-list`. The prefix-list is defined under `routing-options`, outside of the route-filter. The prefix-list can be reused among multiple route policies, as well as firewall filters. The benefit is that when you need to update the prefix-list, you only have to do it in one place. With inline route-filters, you may have to update multiple policies.

```
set policy-options prefix-list STATIC_TO_OSPF 10.0.0.0/16 
set policy-options prefix-list STATIC_TO_OSPF 10.0.1.0/24 
```

\
Notice that we cannot define any mask range in the prefix-list, like you may be used to in IOS:

```
[edit]
admin@R1# set policy-options prefix-list STATIC_TO_OSPF 10.0.0.0/16 ?  
Possible completions:
  <[Enter]>            Execute this command
+ apply-groups         Groups from which to inherit configuration data
+ apply-groups-except  Don't inherit configuration data from these groups
  |                    Pipe through a command
[edit]
admin@R1# set policy-options prefix-list STATIC_TO_OSPF 10.0.0.0/16   
```

\
In Junos, the prefix-list simply contains a list of prefixes, not mask ranges. When applying the prefix-list to the route policy, we are essentially only matching exact masks.

```
set policy-options policy-statement STATIC_TO_OSPF from prefix-list STATIC_TO_OSPF
```

\
There is another way to match ranges with prefix-lists, which we will see in the next lab.

\
We should see that R1 is only redistributing these two prefixes:

```
admin@R1> show ospf database external    
    OSPF AS SCOPE link state database
 Type       ID               Adv Rtr           Seq      Age  Opt  Cksum  Len 
Extern  *10.0.0.0         10.0.0.1         0x80000001     2  0x22 0x1e7f  36
Extern  *10.0.1.0         10.0.0.1         0x80000001     2  0x22 0x1389  36
```

</details>

### Further Reading

<https://www.juniper.net/documentation/us/en/software/junos/routing-policy/topics/concept/policy-configuring-prefix-lists-for-use-in-routing-policy-match-conditions.html>

<https://www.juniper.net/documentation/us/en/software/junos/routing-policy/topics/example/policy-prefix-list.html>
