Restart dhcpd server from shell [SOLVED]

Started by xseman, August 12, 2017, 11:40:53 PM

Previous topic - Next topic
August 12, 2017, 11:40:53 PM Last Edit: August 13, 2017, 02:08:51 PM by xseman
Hello,

Is it possible to restart dhcpd server via shell?
I've tried 'service dhcpd restart' but got this error:

dhcpd does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable
------------------------------------------------------------
edit:
so i foud out, all I need is to kill dhcpd process and start dhcpd again.


ps -A | grep /usr/local/sbin/dhcpd
kill 'PID'
/usr/local/sbin/dhcpd -user dhcpd -group dhcpd -chroot /var/dhcpd -cf /etc/dhcpd.conf -pf /var/run/dhcpd.pid


But still after restart, dhcp don't get new addresses from edited conf.xml.

Ok so after some digging in '/usr/local/etc/rc.initial' i found this php code that will restart dhcpd server.


#!/usr/local/bin/php
<?php

require_once("config.inc");
require_once(
"interfaces.inc");
require_once(
"filter.inc");
require_once(
"auth.inc");
require_once(
'rrd.inc');
require_once(
"util.inc");
require_once(
"system.inc");
require_once(
"services.inc");
require_once(
"interfaces.inc");

if (
count($argv) > 1 && is_numeric($argv[1])) {
   
// starting delayed.
   
sleep($argv[1]);
}

services_dhcpd_configure('all', array(), true);


And then just run it


php 'code.php'