Data convertion and pre-defined variables for Dhcp site.

Alan DeKok aland at deployingradius.com
Sun Jun 9 18:25:35 CEST 2019


On Jun 9, 2019, at 12:16 PM, CpServiceSPb <cpservicespb at gmail.com> wrote:
> 
> That is:
> switch "%{string:&DHCP-Vendor-Class-Identifier}" {
>        case "sip Phone ID" {
>              update reply {
>                     &DHCP-TFTP-Server-Name =
> "tftp://%{listen:src_ipaddr}" - works fine
>                     &DHCP-Vendor =
> "http://user:pass@%{listen:src_ipaddr}/pbx" - I made it working a few
> time ago - works fine
>                     &DHCP-SIP-Servers-DHCP-Option =
> "*1**192.168.0.254*" - does not work

  Because DHCP-SIP-Servers-DHCP-Option is an "octets" data type, so you have to feed it octets.  e.g.

		&DHCP-SIP-Servers-DHCP-Option = 0x01c0a800fe

  That will work.

> Dhcpdump shows:
> 
> OPTION: 120 ( 12) SIP Servers DHCP Option *3131302e31302e302e323534*

  Because you gave the attribute a text string.  Which isn't hex, and it isn't an IP address.

> Sip phone doesn' t accept these setting.
> 
> The right settings phone accepts is: *01c0a800fe*
> But I can' t get such result.

  You just typed it there.  You can add that as hex to the "update" statement.

> I specified this option at isc-dhcp-server simply
> *option sip-pbx-servers 1 192.168.0.254;*

  That's nice for them.

> Regarding pre-defined or constant variables: I used successfully
> %{listen:src_ipaddr} in places where string type is acceptable.

  Sure.

> It is very convenient for particular for me, to specify the same
> repeating value for all necessary attributes and it will not be
> necessary to change it for each of
> many attributes when IP of dhcp is changed.

  That's true.

> And I would use it variable for ipaddr attributes also but I don' t
> know how to convert string variable to ipaddr, to get working:
> &DHCP-Domain-Name-Server += %{ipaddr:%{listen:src_ipaddr}} instead of
> &DHCP-Domain-Name-Server += 192.168.0.254

  That's unfortunately more difficult to do in FreeRADIUS.  Your best bet is to just use hex.

  Alan DeKok.





More information about the Freeradius-Users mailing list