News: This forum is now permanently frozen.
Pages: [1]
Topic: More options for DHCP  (Read 2589 times)
« on: July 19, 2010, 02:57:08 »
momothefox *
Posts: 49

i hope to have different pools each with specific parameters such as Gateway,DNS,SubnetMask.

Best Regards,
Mohammed Ismail

Mohammed Ismail
« Reply #1 on: August 03, 2010, 03:52:17 »
momothefox *
Posts: 49

after reading and asking on the mailing list abut adding more options to DHCP server in m0n0wall. i managed with the help of my friend who knows php4 a little.
to add the option of subnetmask in the services_dhcp.php which is working by editing /etc/inc/services.inc and adding simple lines for testing.
Quote
        $dhcpdifs = array();
        foreach ($dhcpdcfg as $dhcpif => $dhcpifconf) {

                $ifcfg = $config['interfaces'][$dhcpif];

                if (!isset($dhcpifconf['enable']) ||
                        (($dhcpif != "lan") &&
                        (!isset($ifcfg['enable']) || !$ifcfg['if'] || $ifcfg['bridge'])))
                        continue;

                $subnet = gen_subnet($ifcfg['ipaddr'], $ifcfg['subnet']);
                $subnetmask = gen_subnet_mask($ifcfg['subnet']);

                $dnscfg = "";

                if ($dhcpifconf['domain']) {
                        $dnscfg .= "    option domain-name \"{$dhcpifconf['domain']}\";\n";
                }

                if (is_array($dhcpifconf['dnsserver']) && ($dhcpifconf['dnsserver'][0])) {
                        $dnscfg .= "    option domain-name-servers " . join(",", $dhcpifconf['dnsserver']) . ";";
                } else if (isset($config['dnsmasq']['enable'])) {
                        $dnscfg .= "    option domain-name-servers " . $ifcfg['ipaddr'] . ";";
                } else if (is_array($syscfg['dnsserver']) && ($syscfg['dnsserver'][0])) {
                        $dnscfg .= "    option domain-name-servers " . join(",", $syscfg['dnsserver']) . ";";
                }

                $dhcpdconf .= "subnet $subnet netmask $subnetmask {\n";
                $dhcpdconf .= " pool {\n";
                if (isset($dhcpifconf['denyunknown']))
                   $dhcpdconf .= "              deny unknown clients;\n";

                if ($dhcpifconf['gateway']){
                        $routers = $dhcpifconf['gateway'];
                        $subnetm = $dhcpifconf['subnetmask'];
                }
                else{
                        $routers = $ifcfg['ipaddr'];
                        $subnetm = gen_subnet_mask($ifcfg['subnet']);
                }
                $dhcpdconf .= <<<EOD
                range {$dhcpifconf['range']['from']} {$dhcpifconf['range']['to']};
        }
        option routers {$routers};
        option subnet-mask {$subnetm};
$dnscfg

and it worked fine, after editing services_dhcp.php which is attached.
this option i managed to put it inside m0n0wall using workon.sh
i hope m0n0wall developers write this in the right way to have this option in m0n0wall.

Regards.
Mohammed

* services_dhcp.txt (22.54 KB - downloaded 195 times.)

Mohammed Ismail
« Reply #2 on: August 03, 2010, 04:26:22 »
momothefox *
Posts: 49

i did testing for this custom image applying it for 10 m0n0wall boxes varies in the number of clients between 60 and 200
but as new version arrive i hate my custom image which i hardly built.
hope this sees the light.


Mohammed Ismail
 
Pages: [1]
 
 
Powered by SMF 1.1.20 | SMF © 2013, Simple Machines