# aflex script requirement to evaluate host status

**URL:** <https://community.a10networks.com/t/aflex-script-requirement-to-evaluate-host-status/675>\
**Category:** aFleX\
**Created:** [September 10, 2021, 12:13pm UTC](https://community.a10networks.com/t/aflex-script-requirement-to-evaluate-host-status/675 "2021-09-10T12:13:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bseppanen](https://avatars.discourse-cdn.com/v4/letter/b/5e9695/32.png) [@bseppanen](https://community.a10networks.com/u/bseppanen)\
**Post date:** [September 10, 2021, 12:13pm UTC](https://community.a10networks.com/t/aflex-script-requirement-to-evaluate-host-status/675/1 "2021-09-10T12:13:50Z")

</div>

I am working on load balancing radius auth/acct to two MS NPS servers. The load balancing works and with radius there is a need to persist a radius client with the server that it happens to communicate with. The starting point for that is an aflex script found at [https://a10support.force.com/customers/articles/KB/Radius-AVP-persistence-with-aFleX/p](https://a10support.force.com/customers/articles/KB/Radius-AVP-persistence-with-aFleX/p) . The persistence works well, but the problem occurs if the radius server it happens to be talking to goes down. I am new to aflex and would like to find a means of evaluating host status in the aflex script and clear the persistence for that/all session(s) if there is a host change.  
Would this be possible? I’ve only started looking for the resources, so any pointers appreciated.  
are there any libraries that might be available to easily do this?

Thanks

---

<div class="post-metadata">

**Author:** ![jserrano](https://avatars.discourse-cdn.com/v4/letter/j/a9a28c/32.png) [@jserrano](https://community.a10networks.com/u/jserrano)\
**Post date:** [September 10, 2021, 1:19pm UTC](https://community.a10networks.com/t/aflex-script-requirement-to-evaluate-host-status/675/2 "2021-09-10T13:19:12Z")

</div>

Hi,  
Server status is always evaluated before any persistence record whenever a new connection arrives so I don´t believe this is a persistence issue. After server selection when session gets stablished it might happens that server goes down and you are not re-balancing udp flow upon failure.  
I would Just make sure:

1. You define vPort as Radius and not raw udp so the A10 is transaction aware:  
!  
slb virtual-server www.a10networks.int 10.108.131.100  
&nbsp;port 1812 **radius**  
&nbsp;&nbsp;&nbsp;template udp Radius

2. You create a udp template with “re-select-if-server-down” option marked. Optionally you can set an aggresive aging to drain session entries faster from memmory.  
!  
slb template udp Radius  
&nbsp;aging short  
&nbsp;re-select-if-server-down  
!

An, of course you can use any aFlex logic to steer and/or persist traffic based on any AVP pattern. This is an example where username is used as persistence token and regex is used to select a backend based in its format:

when CLIENT\_DATA {  
&nbsp;&nbsp;set username [RADIUS::avp 1]  
&nbsp;&nbsp;log “Got Username AVP: $username  
&nbsp;&nbsp;switch -regexp $username {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{^\d{8}\w?$} {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pool Pool\_A\_1812  
&nbsp;&nbsp;&nbsp;&nbsp;log “dni: $username \> Pool\_A\_1812 : [LB::server name]  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{\[1\]+[a-zA-Z0-9]\*$} {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pool Pool\_madrid\_1812  
&nbsp;&nbsp;&nbsp;&nbsp;log “username: $username \> Pool\_B\_1812 : [LB::server name]  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;default {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pool Pool\_CPPM\_1812  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log “default: $username \> Pool\_CPPM\_1812 : [LB::server name]"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
&nbsp;&nbsp;}  
&nbsp;&nbsp;persist uie $username 60  
}

Hope this help!

Regards

* * *

1. a-zA-Z

---

<div class="post-metadata">

**Author:** ![bseppanen](https://avatars.discourse-cdn.com/v4/letter/b/5e9695/32.png) [@bseppanen](https://community.a10networks.com/u/bseppanen)\
**Post date:** [September 10, 2021, 4:25pm UTC](https://community.a10networks.com/t/aflex-script-requirement-to-evaluate-host-status/675/3 "2021-09-10T16:25:13Z")

</div>

in our case we have implemented a direct server return, so I don’t believe the radius option vs just using udp would provide any additional benefits  
slb virtual-server radius.vip1 x.x.x.x  
&nbsp;port 1812 udp  
&nbsp;&nbsp;&nbsp;message-switching  
&nbsp;&nbsp;&nbsp;aflex radius-persist  
&nbsp;&nbsp;&nbsp;service-group radius.udp.1812  
&nbsp;&nbsp;&nbsp;template udp select-host  
&nbsp;&nbsp;&nbsp;no-dest-nat  
&nbsp;port 1813 udp  
&nbsp;&nbsp;&nbsp;message-switching  
&nbsp;&nbsp;&nbsp;aflex radius-persist  
&nbsp;&nbsp;&nbsp;service-group radius.udp.1813  
&nbsp;&nbsp;&nbsp;template udp select-host  
&nbsp;&nbsp;&nbsp;no-dest-nat

The problem seems to have been due to the health-check being disabled for the host.
