We have a file calle ips and the file contens
00:1c:c4:64:a0:c0;hostname1;
1c:c1:de:0f:f2:c2;hostname2;
create a createdhcpd.pl with this
#!/usr/bin/perl
open (FILE, ‘ips’);
open (MYFILE, ‘>data.txt’);
while () {
chomp;
($mac, $host) = split(“;”);
print MYFILE “host $host { \n hardware ethernet $mac\; \n fixed-address $host\; \n \} \n \n”;
print “\n”;
}
close (FILE);
close (MYFILE);
exit;
Run it, and then check data.txt .
Example data.txt
host hostname1 {
hardware ethernet 00:1c:c4:64:a0:c0;
fixed-address hostname1;
}
host hostname2 {
hardware ethernet 1c:c1:de:0f:f2:c2;
fixed-address hostname2;
}
Advertisement