> 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/8-selective-redistribution-part-2.md).

# 8) Selective Redistribution (Part 2)

### 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/c0CYd0NvRUNudU0KS6dR" alt=""><figcaption></figcaption></figure>

Create a route-policy that redistributes static routes `10.0.1.0/24` and `10.2.0.0/16` into OSPF on R1. You are not allowed to use a `then` statement.

### Answer

<details>

<summary>Expand to reveal</summary>

```
edit policy-options policy-statement STATIC_TO_OSPF
set from protocol static
set from route-filter 10.0.1.0/24 exact accept
set from route-filter 10.2.0.0/16 exact accept

top
set protocols ospf export STATIC_TO_OSPF
```

</details>

### Explanation

<details>

<summary>Expand to reveal</summary>

This is a quick lab that tests your understanding of using `accept` or `reject` in-line on route-filters.

```
set from route-filter <prefix> <match> accept|reject
```

\
This allows you to create interesting one-term policies, such as a policy that accepts certain routes and rejects all others:

```
[edit]
admin@R1# show policy-options 
policy-statement NAME {
    from {
        route-filter 10.0.0.0/8 exact accept;
    }
    then reject;
}
```

\
Note that since our route policy in this lab does not have a terminating action (`then accept` or `then reject`), all other routes not matching the two `route-filter` lines are then processed by the default OSPF export policy, which rejects all. The above example with a separate `then reject` might be used under BGP for example, where the default would otherwise be to advertise all BGP routes.

\
In general, I find it more readable and understandable to only include the action in a separate `then` statement, instead of in-line on the `route-filter`, but you need to be aware that this functionality is available as well.

\
We should see that only these two static routes are in the OSPF database:

```
[edit]
admin@R1# run show ospf database 

    OSPF database, Area 0.0.0.0
 Type       ID               Adv Rtr           Seq      Age  Opt  Cksum  Len 
Router  *10.0.0.1         10.0.0.1         0x80000004     6  0x22 0xc033  84
Router   10.0.0.2         10.0.0.2         0x80000002    24  0x22 0xfa0e  72
Summary  2.2.2.2          10.0.0.2         0x80000002    24  0x22 0xc463  28
    OSPF AS SCOPE link state database
 Type       ID               Adv Rtr           Seq      Age  Opt  Cksum  Len 
Extern  *10.0.1.0         10.0.0.1         0x80000001     6  0x22 0x1389  36
Extern  *10.2.0.0         10.0.0.1         0x80000001     6  0x22 0x695   36

```

</details>

### Further Reading

<https://www.juniper.net/documentation/us/en/software/junos/routing-policy/topics/concept/policy-configuring-route-lists-for-use-in-routing-policy-match-conditions.html#understanding-route-filters-for-use-in-routing-policy-match-conditions__id-10253170>
