OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • Archive »
  • 17.7 Legacy Series »
  • Restart dhcpd server from shell [SOLVED]
« previous next »
  • Print
Pages: [1]

Author Topic: Restart dhcpd server from shell [SOLVED]  (Read 5884 times)

xseman

  • Newbie
  • *
  • Posts: 4
  • Karma: 0
    • View Profile
Restart dhcpd server from shell [SOLVED]
« 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
<?phprequire_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

Code: [Select]
php 'code.php'
« Last Edit: August 13, 2017, 02:08:51 pm by xseman »
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • Archive »
  • 17.7 Legacy Series »
  • Restart dhcpd server from shell [SOLVED]
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2