Data convertion and pre-defined variables for Dhcp site.
I try to set up Dhcp Option 120 - freeradius DHCP-SIP-Servers-DHCP-Option and Dhcp Option 43 - DHCP-Vendor using unlang, both are octet type. But is still faulted. I looked into a lot of docs but didn' t find any success resolution. So, how is the best way at unlang to: - convert ipaddr type to octet; - convert string to octet; - convert string to ipaddr ? I tried to use %{hex:192.168.0.254} and %{ipaddr: 192.168.0.254} but there is nothing. Also, I investigate that %{listen:src_ipaddr} is possible to use as some of pre-defined variable with Dcp IP. But its type is string. Also I tried %{hex: :%{listen:src_ipaddr}} and %{ipaddr:%{listen:src_ipaddr}} , there is no positive result. So, is there predefined variables, providing for example IP of Dhcp which I can use anywhere instead of specifying of 192.168.0.254 directly ? For example &DHCP-Domain-Name-Server += %{ipaddr:&some_variable}
On Jun 9, 2019, at 10:15 AM, CpServiceSPb <cpservicespb@gmail.com> wrote:
I try to set up Dhcp Option 120 - freeradius DHCP-SIP-Servers-DHCP-Option and Dhcp Option 43 - DHCP-Vendor using unlang, both are octet type. But is still faulted.
What does that mean?
I looked into a lot of docs but didn' t find any success resolution. So, how is the best way at unlang to: - convert ipaddr type to octet; - convert string to octet; - convert string to ipaddr ?
You don't. The server should automatically do this.
I tried to use %{hex:192.168.0.254} and %{ipaddr: 192.168.0.254} but there is nothing.
Because "192.168.0.256" is a *text string* there. The server has no way to know that it's an IP address.
Also, I investigate that %{listen:src_ipaddr} is possible to use as some of pre-defined variable with Dcp IP. But its type is string.
Yes. That's how the dynamic expansions work.
Also I tried %{hex: :%{listen:src_ipaddr}} and %{ipaddr:%{listen:src_ipaddr}} , there is no positive result. So, is there predefined variables, providing for example IP of Dhcp which I can use anywhere instead of specifying of 192.168.0.254 directly ?
To do what?
For example &DHCP-Domain-Name-Server += %{ipaddr:&some_variable}
The DHCP-Domain-Name-Server attribute is defined to be an IP address. So you just assign an IP address to it: &DHCP-Domain-Name-Server += 192.168.0.254 The server then encodes the IP into a packet. There is no reason for you to encode attributes into raw data manually. The server automatically decodes attributes it receives in packets, and then encodes attributes it sends in replies. If you're not sure how this happens, read the debug output. Note that attributes of type "ipaddr" are printed as IP addresses. They're *not* printed as raw data. Perhaps you also could explain what you're trying to do. What you're doing right now is asking why your solution is wrong. But you should instead be asking about the problem you're trying to solve. See also http://wiki.freeradius.org/list-help/ For more information on asking good questions. Alan DeKok.
* I try to set up Dhcp Option 120 - freeradius DHCP-SIP-Servers-DHCP-Option *
What does that mean?
* and Dhcp Option 43 - DHCP-Vendor using unlang, both are octet type. *>* But is still faulted.
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 } } ........... First value means - order of servers, second - IP of specified address. Dhcpdump shows: OPTION: 120 ( 12) SIP Servers DHCP Option *3131302e31302e302e323534* Sip phone doesn' t accept these setting. The right settings phone accepts is: *01c0a800fe* But I can' t get such result. I specified this option at isc-dhcp-server simply *option sip-pbx-servers 1 192.168.0.254;* Regarding pre-defined or constant variables: I used successfully %{listen:src_ipaddr} in places where string type is acceptable. 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. 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
On Jun 9, 2019, at 12:16 PM, CpServiceSPb <cpservicespb@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.
participants (2)
-
Alan DeKok -
CpServiceSPb