]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
re-add src_ipaddr configuration
authorAlan T. DeKok <aland@freeradius.org>
Thu, 24 May 2018 12:53:52 +0000 (08:53 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 28 May 2018 00:37:14 +0000 (20:37 -0400)
raddb/sites-available/dhcp
src/modules/proto_dhcpv4/proto_dhcpv4_udp.c

index 215c40d3f1e3d21d048aff5764e05e1a83b22aff..e3ba49f9a7b768323eb60a5c17faf98340b87a65 100644 (file)
@@ -58,6 +58,20 @@ listen {
                #  Interface name we are listening on. See comments above.
 #              interface = lo0
 
+               #  source IP address for unicast packets sent by the
+               #  DHCP server.
+               #
+               #  The source IP for unicast packets is chosen from the first
+               #  one of the following items which returns a valid IP
+               #  address:
+               #
+               #       src_ipaddr
+               #       ipaddr
+               #       reply:DHCP-Server-IP-Address
+               #       reply:DHCP-DHCP-Server-Identifier
+               #
+               src_ipaddr = 127.0.0.1
+
                # The DHCP server defaults to allowing broadcast packets.
                # Set this to "no" only when the server receives *all* packets
                # from a relay agent.  i.e. when *no* clients are on the same
index 7feace433ed738fd7d9fef745ca2df7e04e5db87..58599daf5a0e915b3fdd092cb96115c36ef51907 100644 (file)
@@ -46,6 +46,8 @@ typedef struct proto_dhcpv4_udp_t {
 
        fr_ipaddr_t                     ipaddr;                 //!< IP address to listen on.
 
+       fr_ipaddr_t                     src_ipaddr;             //!< IP address to source replies
+
        char const                      *interface;             //!< Interface to bind to.
        char const                      *port_name;             //!< Name of the port for getservent().
 
@@ -86,6 +88,8 @@ static const CONF_PARSER udp_listen_config[] = {
        { FR_CONF_OFFSET("ipv4addr", FR_TYPE_IPV4_ADDR, proto_dhcpv4_udp_t, ipaddr) },
        { FR_CONF_OFFSET("ipv6addr", FR_TYPE_IPV6_ADDR, proto_dhcpv4_udp_t, ipaddr) },
 
+       { FR_CONF_OFFSET("src_ipaddr", FR_TYPE_COMBO_IP_ADDR, proto_dhcpv4_udp_t, src_ipaddr) },
+
        { FR_CONF_OFFSET("interface", FR_TYPE_STRING, proto_dhcpv4_udp_t, interface) },
        { FR_CONF_OFFSET("port_name", FR_TYPE_STRING, proto_dhcpv4_udp_t, port_name) },
 
@@ -400,6 +404,15 @@ static int mod_bootstrap(void *instance, CONF_SECTION *cs)
                return -1;
        }
 
+       /*
+        *      If src_ipaddr is defined, it must be of the same address family as "ipaddr"
+        */
+       if ((inst->src_ipaddr.af != AF_UNSPEC) &&
+           (inst->src_ipaddr.af != inst->ipaddr.af)) {
+               cf_log_err(cs, "Both 'ipaddr' and 'src_ipaddr' must be from the same address family");
+               return -1;
+       }
+
        if (inst->recv_buff_is_set) {
                FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, >=, 32);
                FR_INTEGER_BOUND_CHECK("recv_buff", inst->recv_buff, <=, INT_MAX);