OPNsense Forum

Archive => 17.7 Legacy Series => Topic started by: xseman on August 12, 2017, 11:40:53 pm

Title: Restart dhcpd server from shell [SOLVED]
Post by: xseman on August 12, 2017, 11:40:53 pm
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.

Code: [Select]
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.

Code: [Select]
#!/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) > && is_numeric($argv[1])) {
    
// starting delayed.
    
sleep($argv[1]);
}

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

And then just run it

Code: [Select]
php 'code.php'