0

I'm using FreeRADIUS Version 3.0.13, and am trying to replicate accounting requests to a 3rd party server that uses the packets to do some mapping of IP's to the User-Name. The user-name doesn't really matter to them, it's just something that can be searched against. As such, I want to stick more info in there than just our username (which is essentially a port and vlan). I have written an update query which does what I want, however I can only figure out how to update that on PROXY, not on REPLICATE.

If I update it in the 'preacct' section, it breaks the actual accounting I'm doing locally because my local accounting packets have my altered User-Name.

preacct {
    update request {
      User-Name := "%{User-Name}_%{sql: SELECT b.agreement FROM radcheck a, customer_customer b WHERE a.customer_id = b.id and a.username = '%{User-Name}'}_%{sql: SELECT REPLACE(b.name,' ','_') FROM radcheck a, customer_customer b WHERE a.customer_id = b.id and a.username = '%{User-Name}'}"
    }
    update control {
        #Proxy-To-Realm := r_ca_fa
        Replicate-To-Realm := r_ca_fa
        }
    replicate

If I update the proxy-request in the 'pre-proxy' section, it does what I want, but it seems I can only make that work if I proxy, and not replicate. The proxy works fine, except that my server is waiting for responses that will never come, and then ultimately declares the server dead (I see this in the logs, not sure if there is any actual effect on the service).

Not sure what other info might be relevant to troubleshoot, but I've been working on this for a long time, and looking through boards but cannot seem to figure it out. Any help would be appreciated.

Thanks!

1 Answers1

0

Yeah the replicate module is a bit weird, it bypasses most of the protocol state machine for RADIUS, and just creates new packets on the fly, which it writes directly to an output socket.

The upshot is none of the normal proxy lists function how they would normally do.

If you want to rewrite any of the attributes in the outbound packet, you need to change them in the current request.

update {
    request:Tmp-String-0 := &User-Name
    request:User-Name := "%{User-Name}_%{sql: SELECT b.agreement FROM radcheck a, customer_customer b WHERE a.customer_id = b.id and a.username = '%{User-Name}'}_%{sql: SELECT REPLACE(b.name,' ','_') FROM radcheck a, customer_customer b WHERE a.customer_id = b.id and a.username = '%{User-Name}'}"
    control:Replicate-To-Realm := 'r_ca_fa'
}
replicate
update {
    request:User-Name := &Tmp-String-0
}
Arran Cudbard-Bell
  • 1,514
  • 1
  • 9
  • 18