LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   not getting /etc/dhcpd.conf (https://www.linuxquestions.org/questions/linux-general-1/not-getting-etc-dhcpd-conf-165589/)

sixth_sense 04-02-2004 11:24 PM

not getting /etc/dhcpd.conf
 
Hi,

I was trying to install dhcp-2.0-5.i386.rpm from my Redhat Installation CD with the command rpm -Uvh dhcp-2.0-5.i386 and it was installed but .. i m not sure...:scratch: why i am not getting the file dhcp.conf on its default location /etc/dhcpd.conf.


note, I am using redhat 6.2

any idea ? plz help.

thanks,

DavidPhillips 04-03-2004 02:09 AM

There is no way a generic one would work, so it's not supplied. You need to create one.

sixth_sense 04-03-2004 03:41 AM

Thanks for reply, My DHCP is now running ... :D I've made one conf. file and its running ok...but can you plz share an idea ?? I think DHCP server create broadcast...is it right ?

bye.

DavidPhillips 04-03-2004 01:12 PM

I don't understand the question.

DHCP is a broadcast protocol

The dhcp client uses ip 0.0.0.0 udp port 68 for its source
address and ip 255.255.255.255 and udp port 67 for its destination
address.


You do not want these getting to the outside interface. I suppose you put all interfaces in the dhcp config file as that is how it's instructed in most of what I've seen, and it's running so you must have created a leases file.


One alternative is to only put the subnets for your local lan. This will result in an error when you try to start the dhcp server normally. Here is how to fix it.


For an example lets say you have three interfaces.

eth0 internet
eth1 local
eth2 local

edit the script file in /etc/rc.d/init.d dhcpd

look for a line like this in start()

daemon /usr/sbin/dhcpd ${DHCPDARGS}


change the line to this

daemon /usr/sbin/dhcpd eth1 eth2

or set "eth1 eth2" to the variable directly above the dhcpd line.

DHCPDARGS="eth1 eth2"
daemon /usr/sbin/dhcpd ${DHCPDARGS}

then it will only use those interfaces, if you start it some other way just add the interfaces to the command as shown.

daemon /usr/sbin/dhcpd eth1 eth2

restart the dhcpd service if your using the init.d script

service dhcpd restart

Now check the file /var/log/messages

grep dhcpd /var/log/messages

Apr 3 13:07:11 www dhcpd: Listening on Socket/eth1/192.168.1.0
Apr 3 13:07:11 www dhcpd: Sending on Socket/eth1/192.168.1.0
Apr 3 13:07:11 www dhcpd: Listening on Socket/eth2/192.168.2.0
Apr 3 13:07:11 www dhcpd: Sending on Socket/eth2/192.168.2.0
Apr 3 13:07:11 www dhcpd: dhcpd startup succeeded

:)




If your dhcpd is not your router you probably can't use this. Just block the broadcast in your firewall.

shmude 04-07-2004 10:41 PM

I hate to jump into your thread but im having a problem with my dhcpd server. Im using Fedora Core 1 and installed dhcp-3.0.1rc13.tar.gz from isc.org (i think its the latest version). I got the dhcpd.conf file up and going and can start the dhcpd server by just typing in 'dhcpd' but if i try to do a 'service dhcpd start' it will tell me that the service isunrecognized. I want this to start on startup so i checked /etc/rc.d/init.d and there is no dhcpd in there. I am curious what happend and what i did wrong. Did i not install it right and if thats the case how do i uninstall a tar.gz file. Should i just use the .rpm package that came with the Fedora disks?

ShmUDE

DavidPhillips 04-07-2004 11:55 PM

try this first..

chkconfig add dhcpd

still nothing? Try this one..


Code:

#!/bin/sh
#
# dhcpd        This shell script takes care of starting and stopping
#              dhcpd.
#
# chkconfig: - 65 35
# description: dhcpd provide access to Dynamic Host Control Protocol.
 
# Source function library.
. /etc/rc.d/init.d/functions
 
# Source networking configuration.
. /etc/sysconfig/network
. /etc/sysconfig/dhcpd
 
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
 
[ -f /usr/sbin/dhcpd ] || exit 0
[ -f /etc/dhcpd.conf ] || exit 0
[ -f /var/lib/dhcp/dhcpd.leases ] || exit 0
 
RETVAL=0
prog="dhcpd"

start() {
        # Start daemons.
        echo -n $"Starting $prog: "
        daemon /usr/sbin/dhcpd ${DHCPDARGS}
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcpd
        return $RETVAL
}
 
stop() {
        # Stop daemons.
        echo -n $"Shutting down $prog: "
        killproc dhcpd
        RETVAL=$?
        echo
        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/dhcpd
        return $RETVAL
}
 
# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        stop
        start
        RETVAL=$?
        ;;
  condrestart)
        if [ -f /var/lock/subsys/dhcpd ]; then
            stop
            start
            RETVAL=$?
        fi
        ;;
  configtest)
        dhcpd -t
        RETVAL=$?
        ;;
  status)
        status dhcpd
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $0 {start|stop|restart|condrestart|configtest|status}"
        exit 1
esac
 
exit $RETVAL





Also if you notice how I said to edit the initd script before, you should probably create the file and just put the line in it at /etc/sysconfig/dhcpd just to keep things standard.


DHCPDARGS="eth1 eth2"

or whatever args are needed if any. If the dhcpd.conf contains a subnet declaration for all active interfaces then you probably can leave the file like this...


DHCPDARGS=

shmude 04-08-2004 12:03 AM

Awsome, thanks for the script how ever i still am having some issues.
First off the

chkconfig --add dhcpd

didn't work and said "error reading information on service dhcpd: No such file or directory" For some reason i dont think it got installed properly. I was looking through that script and noticed the

# Source networking configuration.
. /etc/sysconfig/network
. /etc/sysconfig/dhcpd

part and look in my /etc/sysconfig folder and did not have a dhcpd file in there. Is that going to be a big problem? again i can get the server to start by simply typing in 'dhcpd' and it will start for me but i dont understand why im missing these files. Thanks for the support

ShmUDE

DavidPhillips 04-08-2004 12:14 AM

No problem creating that file, the default contents of that file are shown above..


and below


DHCPDARGS=


:)

shmude 04-08-2004 01:04 AM

Ok, im kinda confused now. This is EXACTLY what i have done.

I touched a dhcpd file inside of /etc/rc.d/init.d and coppied the script you posted into that file. i did a chmod 755 dhcpd to make it have the same permissions as the other files in that directory. When i tried to run service dhcpd restart it said

[root@FC1 init.d]# service dhcpd restart
/etc/init.d/dhcpd: line 14: /etc/sysconfig/dhcpd: No such file or directory

so i went back and reviewed your posts again and touched a dhcpd file in the /etc/sysconfig directory and the only thing i put in there was DHCPDARGS="wlan0" (because i would only like it to run on my wireless connection, im creating an AP), is that right? i got confused with what is suposed to be in the /etc/sysconfig/dhcpd file. When i created that file and put in the DHCPDARGS="wlan0" then i could do a service dhcpd restart, but it didn't give me the green 'OK's like it does on all the other services. It also didn't seem like it did anything. It didn't create any logs in /var/log/messages so im pretty sure that it wasn't working. Any ideas?

DavidPhillips 04-08-2004 11:45 PM

That sounds ok, except the fact that it's not working is what would happen if there is no dhcpd.conf file.

shmude 04-09-2004 12:20 AM

this is what happends if there is no dhcpd.conf file (i just renamed it)

[root@FC1 etc]# dhcpd
Internet Software Consortium DHCP Server V3.0.1rc13
Copyright 1995-2003 Internet Software Consortium.
All rights reserved.
For info, please visit http://www.isc.org/products/DHCP
Can't open /etc/dhcpd.conf: No such file or directory

If you did not get this software from ftp.isc.org, please
get the latest from ftp.isc.org and install that before
requesting help.

If you did get this software from ftp.isc.org and have not
yet read the README, please read it before requesting help.
If you intend to request help from the dhcp-server@isc.org
mailing list, please read the section on the README about
submitting bug reports and requests for help.

Please do not under any circumstances send requests for
help directly to the authors of this software - please
send them to the appropriate mailing list as described in
the README file.

exiting.
[root@FC1 etc]# service dhcpd start
[root@FC1 etc]#

The last part is if i try to start it with 'service dhcpd start' notice how it doesn't do anything. im completly lost with this problem.

Thanks for the support! :)

***EDIT***
again what should be in the /etc/sysconfig/dhcpd file? just

DHCPDARGS="wlan0"

Thats all i have in there. Is that correct?

shmude 04-09-2004 01:17 AM

Well if i would have RTFM like i should have, i would have noticed this section in the dhcpd manpage

"Whenever changes are made to the dhcpd.conf file, dhcpd must be restarted. To restart dhcpd, send a SIGTERM (signal 15) to the process ID contained in /var/run/dhcpd.pid, and then re-invoke dhcpd. Because the DHCP server database is not as lightweight as a BOOTP database, dhcpd does not automatically restart itself when it sees a change to the dhcpd.conf file."

apparently it doesn't run like the other sevices and you CANT do a 'service dhcpd start'

Thanks for all the help you have given me on this topic

See ya around.

ShmUDE

DavidPhillips 04-09-2004 06:15 PM

There is a service dhcpd restart, which is the same as service dhcpd stop followed by service dhcpd start.

It may be version specific as to how it would react, here is what mine does.

[root@zeus root]# service dhcpd status
dhcpd (pid 2176) is running...
[root@zeus root]# mv /etc/dhcpd.conf /etc/dhcpdconf.bak
[root@zeus root]# service dhcpd restart
[root@zeus root]# service dhcpd stop
[root@zeus root]# service dhcpd start
[root@zeus root]# service dhcpd status
[root@zeus root]# mv /etc/dhcpdconf.bak /etc/dhcpd.conf
[root@zeus root]# service dhcpd restart
Shutting down dhcpd: [ OK ]
Starting dhcpd: [ OK ]
[root@zeus root]# service dhcpd status
dhcpd (pid 5598) is running...


All times are GMT -5. The time now is 08:14 PM.