DHCP configuration script

Suppose you need to add many subnets to the DHCP server configuration file, for example from 172.16.1.0 to 172.16.100.0, in this case this script will help.
Download can be HERE.

The script must be made executable and run from linux:

chmod 755 script_dhcp_conf.php
./script_dhcp_conf.php

The result is copied to the clipboard and pasted into the DHCP configuration file (in putty, the copying is done with the Ctrl+Ins key combination).

Sample script:

#!/usr/bin/php

<?php

for($i=1; $i<=100; $i++)
{
print
("
subnet 172.16.$i.0 netmask 255.255.255.0 {
       option routers 172.16.$i.1;
       option domain-name-servers  8.8.8.8, 8.8.4.4;
       option subnet-mask 255.255.255.0;
       default-lease-time 86400;
       max-lease-time 86400;
       next-server 172.16.$i.1;

{#172.16.$i.2-254#}
}
");
}

?>
Подписаться на IT Blog (RU) по Email
Subscribe to IT Blog (EN) by Email

Did my article help you? How about buying me a cup of coffee as an encouragement? Buy me a coffe.

Leave a Reply