Data convertion and pre-defined variables for Dhcp site.

Alan DeKok aland at deployingradius.com
Sun Jun 9 16:41:24 CEST 2019


On Jun 9, 2019, at 10:15 AM, CpServiceSPb <cpservicespb at 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.




More information about the Freeradius-Users mailing list