--- bin/dhcpd.pl 2009/07/27 11:46:44 8 +++ bin/dhcpd.pl 2009/07/27 22:18:51 12 @@ -14,8 +14,7 @@ my $debug = shift @ARGV; -our ( $server_ip, $next_file ); -require "config.pl"; +our ( $server_ip, $file, $next_file ); my $sock = IO::Socket::INET->new( LocalPort => 67, @@ -53,6 +52,8 @@ while (1) { + require "config.pl"; # refresh config + print "waiting for DHCP requests on ",$sock->sockhost,":",$sock->sockport,"\n"; my $buf; @@ -73,8 +74,13 @@ my $mac = substr($dhcp->chaddr(),0,$dhcp->hlen()*2); my $ip = client_ip($mac); - my $file = $next_file; - $file = 'undionly.kpxe' if ! $file || $dhcp->getOptionValue(DHO_USER_CLASS()) ne 'gPXE'; + if ( ! $file ) { + if ( $dhcp->getOptionValue(DHO_USER_CLASS()) ne 'gPXE' ) { + $file = 'undionly.kpxe'; + } else { + $file = $next_file; + } + } my $packet = new Net::DHCP::Packet( Op => BOOTREPLY(),