# BFD Templates

Load **base.ipv4.and.ipv6.cfg**.

```
#IOS-XE
config replace flash:base.ipv4.and.ipv6.cfg

#IOS-XR
configure
load bootflash:base.ipv4.and.ipv6.cfg
commit replace
```

<figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FyG4aachHamRQwZ61iVC7%2Fimage.png?alt=media&#x26;token=f6f2c0f9-c5cd-4b85-bd93-50bc7f541f92" alt=""><figcaption></figcaption></figure>

Configure OSPF bewteen R4 and R6 using BFD. Configure timers as follows:

* R4 and R6 will both transmit and receive at 750msec intervals with a multiplier of 3
* MD5 auth should be used for the BFD session, with BFD\_AUTH as the password
* Echos should be used
* BFD dampening should be used with the default timers

## Answer <a href="#id-3794e275-e56f-4592-a61e-92d794b8bf86" id="id-3794e275-e56f-4592-a61e-92d794b8bf86"></a>

```
#R4, R6
key chain BFD_KEYCHAIN
 key 1
  key-string BFD_AUTH
!
bfd-template single-hop BFD_R4_R6
 interval min-tx 750 min-rx 750 multiplier 3
 authentication md5 keychain BFD_KEYCHAIN
 dampening 3 1500 3000 5
 echo
!
int gi2.46
 ip ospf 1 area 0
 ip ospf bfd
 bfd template BFD_R4_R6
```

## Explanation <a href="#a9e09c7c-3fa0-437e-b624-d76ae817f11d" id="a9e09c7c-3fa0-437e-b624-d76ae817f11d"></a>

BFD templates allow for several features: multi-hop, authentication, microsecond BFD timers, and dampening. We will explore multi-hop BFD sessions in a later lab.

BFD authentication is fairly straightforward. You simply use a keychain and apply it to the template. You can specify md5, sha1, or “meticulous md5/sha1”. I am not clear what the “meticulous” option means. Perhaps stronger keys.

```
key chain BFD_KEYCHAIN
 key 1
  key-string BFD_AUTH
!
bfd-template single-hop BFD_R4_R6
 authentication md5 keychain BFD_KEYCHAIN
```

We can also enable dampening for BFD. This helps when the interface is flapping. We don’t want to continuously establish and tear down the BFD session over and over again. The dampening rules work exactly like BGP dampening. The default values use a half-life time of 3 seconds, unsuppress value of 1500, suppress value of 3000, and max duration to supress a session of 5 seconds.

It is also important to note that the BFD echo function is off by default when using a template. This is very tricky, because echos are *on* by default when you simply use the interface-level **bfd interval** command. So you must ensure to turn echos on under the BFD template.

## Verification <a href="#id-9f55f95c-6a00-4ad3-b8dc-9884c8a61ba2" id="id-9f55f95c-6a00-4ad3-b8dc-9884c8a61ba2"></a>

We can verify dampening and authentication with the **show bfd neighbor detail** command.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2FCDxcu86cDx8qCHpCStHL%2Fimage.png?alt=media&#x26;token=19c7963e-a435-4fba-b144-1ff8464ec7d1" alt=""><figcaption></figcaption></figure></div>

We can cause BFD flaps by turning on uRPF on R6. The BFD session will continually go up and down, as the BFD control packets re-establish the session but the echos never work. After several flaps, the flapping stops for some time. First we will need to greatly increase the dampening half life time. 3 seconds is not long enough to cause flap dampening using this method.

```
#R4
bfd-template single-hop BFD_R4_R6
 dampening 30 1500 3000 50
```

I can get the flap count to increase, but never actually dampen the neighbor. It seems that it simply takes a bit too long to re-establish the BFD session each time.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F5QB8ftbVpGjf67QSSL5j%2Fimage.png?alt=media&#x26;token=995d9d4e-8580-4257-a7e0-bd365eabfae3" alt=""><figcaption></figcaption></figure></div>

Decreasing the suppress threshold should help:

```
#R4
bfd-template single-hop BFD_R4_R6
 dampening 30 750 1500 50
```

Strangely, the BFD session will still never be dampened in the lab.

<div align="left"><figure><img src="https://3072390383-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkUz2C3GqnZcWhoVL6jfk%2Fuploads%2F09MnkHn8Dw1cMPxEy2U9%2Fimage.png?alt=media&#x26;token=c4b560da-63fc-4763-b0a7-758f3413085b" alt=""><figcaption></figcaption></figure></div>

Nevertheless we can at least theoretically understand how this feature works.
