# LDP Local Allocation Filtering

Load **isis.cfg**

```
#IOS-XE
config replace flash:isis.cfg

#IOS-XR
configure
load bootflash:isis.cfg
commit replace
y
```

* Configure LDP using IGP autoconfig on routers R1-R6 and XR1-2
* On R1-R3 and XR1, allocate labels only for host routes using a prefix-list/ACL
* On R4-R6 and XR2, allocate labels only for host routes *without* using a prefix-list or ACL

## Answer <a href="#eb63e9cd-9500-4f1e-9d3c-f8dc77248fab" id="eb63e9cd-9500-4f1e-9d3c-f8dc77248fab"></a>

```
#R1-R3
router isis
 mpls ldp autoconfig
!
ip prefix-list HOST_ROUTES permit 0.0.0.0/0 ge 32 le 32
!
mpls ldp label
 allocate global prefix-list HOST_ROUTES

#R4-R6
router isis
 mpls ldp autoconfig
!
mpls ldp label
 allocate global host-routes

#XR1
router isis 1
 add ipv4
  mpls ldp auto-config
!
mpls ldp
 address-family ipv4
  label
   local
    allocate for HOST_ROUTES
!
ipv4 access-list HOST_ROUTES
 permit ipv4 host 1.1.1.1 any
 permit ipv4 host 2.2.2.2 any
 permit ipv4 host 3.3.3.3 any
 permit ipv4 host 4.4.4.4 any
 permit ipv4 host 5.5.5.5 any
 permit ipv4 host 6.6.6.6 any
 permit ipv4 host 19.19.19.19 any
 permit ipv4 host 20.20.20.20 any

#XR2
router isis 1
 add ipv4
  mpls ldp auto-config
!
mpls ldp
 address-family ipv4
  label
   local
    allocate for host-routes
```

## Explanation <a href="#id-21d76674-699c-441c-ab7f-52843f3a90b7" id="id-21d76674-699c-441c-ab7f-52843f3a90b7"></a>

By default, LDP will locally allocate labels for every non-BGP prefix in the RIB. However, generally LSPs are only formed on the loopbacks, so there is no reason to allocate labels for every transit prefix in the IGP. By allocating labels only for host routes, we can save some memory and better scale LDP.

To selectively allocate labels, we have two options. First, we can use a prefix-list/ACL to have granular control over what prefixes will be allocated a label.

```
#IOS-XE
mpls ldp label
 allocate global prefix-list PREFIX_LIST

#IOS-XR
mpls ldp
 address-family ipv4
  label
   local
    allocate for ACL
```

The IOS-XR method is quite burdensome, because we cannot use a mask filter like we can with a prefix-list. This is the reason that we had to manually specify every host route in the ACL on XR1:

```
mpls ldp
 address-family ipv4
  label
   local
    allocate for HOST_ROUTES
!
ipv4 access-list HOST_ROUTES
 permit ipv4 host 1.1.1.1 any
 permit ipv4 host 2.2.2.2 any
 permit ipv4 host 3.3.3.3 any
 permit ipv4 host 4.4.4.4 any
 permit ipv4 host 5.5.5.5 any
 permit ipv4 host 6.6.6.6 any
 permit ipv4 host 19.19.19.19 any
 permit ipv4 host 20.20.20.20 any
```

The second method is the built-in **host-routes** option. This instructs LDP to only allocate labels for /32 prefixes, and does not require any prefix-list or ACL.

```
#IOS-XE
mpls ldp label
 allocate global host-routes

#IOS-XR
mpls ldp
 address-family ipv4
  label
   local
    allocate for host-routes
```

## Verification <a href="#id-940a8fc5-f9cb-42e5-9445-38733b234ff6" id="id-940a8fc5-f9cb-42e5-9445-38733b234ff6"></a>

On any router in the topology, we should only see /32 prefixes in the LFIB and LIB. It does not matter which router we look at, because both the ACL/prefix-list method, and the built-in **for host-routes** method, have the exact same effect.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F2d4B8AxgG0yn7V7dMdoA%2Fimage.png?alt=media&#x26;token=1a312028-cc77-4b28-b499-e034d5990db1" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FbyOLakGfjgoI25ktiPP5%2Fimage.png?alt=media&#x26;token=bec36404-c80a-4c72-895f-2bd0b81e1e3a" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F4iTU3ncB71MVyemm6WDT%2Fimage.png?alt=media&#x26;token=880e7530-e1ef-4189-9bad-51559b141941" alt=""><figcaption></figcaption></figure></div>

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FohHYf5ELqJmVyqlxC6zn%2Fimage.png?alt=media&#x26;token=6cc5897f-aa72-49c7-a690-0edd824b7b26" alt=""><figcaption></figcaption></figure></div>
