Показать полную графическую версию : Сервер DHCP
Admiral83
18-01-2006, 16:38
Есть проблемки с работой DHCP.
У меня Федора 4. При установке dhcpd не поставился. Ставлю его с диска федоры:
rpm -ihv dhcp-3.0.2-12.rpm
он опять ругается что нет цифровой подписи, но все ставит.
Файл /etc/dhcpd.conf почему-то не создал. Ладно создаю его сам:
subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.50 192.168.2.150
}
Запускаю
# /etc/rc.d/init.d/dhcpd start
Запускается dhcpd [сбой]
И ничего он не запускается. Что делать?
запусти dhcpd из консоли и посмотри на что он ругается
Admiral83
19-01-2006, 09:53
3kLiN
А где его логи? В папке /var искал поиском "dhcp*" - нет логов.
BuGfiX
---------------------------------------------------------------
[root@localhost sbin]# /usr/sbin/dhcpd
Internet Systems Consortium DHCP Server V3.0.2
Copyright 2004 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
/etc/dhcpd.conf line 3: semicolon expected.
}
^
/etc/dhcpd.conf line 3: unexpected end of file
}
^
Configuration file errors encountered -- exiting
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.
--------------------------------------------------------------------------
Похоже проблемы в 3-ей строке, но там только "}" стоит. Файл точно такой же, как описывал в начале.
Admiral83
19-01-2006, 10:54
Так, я разобрался в 3-ей строчке - забыл ; поставить.
Теперь запускаю:
---------------------------------------------------------------------------------------------
[root@localhost sbin]# /usr/sbin/dhcpd
Internet Systems Consortium DHCP Server V3.0.2
Copyright 2004 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
** You must add a global ddns-update-style statement to /etc/dhcpd.conf.
To get the same behaviour as in 3.0b2pl11 and previous
versions, add a line that says "ddns-update-style ad-hoc;"
Please read the dhcpd.conf manual page for more information. **
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.
------------------------------------------------------------------------------
Что это? "ddns-update-style ad-hoc;" В MANе про него ничего нет. У меня пока нет DNS-сервера.
если использовать dynamic dns не нужно, то можно прописать:
ddns-update-style none;
ddns-updates off;
Admiral83
19-01-2006, 15:41
Спасибо, теперь начал запускаться:
[root@localhost init.d]# /usr/sbin/dhcpd
Internet Systems Consortium DHCP Server V3.0.2
Copyright 2004 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
Wrote 0 leases to leases file.
Listening on LPF/eth0/00:50:22:8f:a0:49/192.168.2/24
Sending on LPF/eth0/00:50:22:8f:a0:49/192.168.2/24
Sending on Socket/fallback/fallback-net
Но когда пытаюсь запустить скрипт - ругается и в логах ничего нет:
[root@localhost init.d]# /etc/rc.d/init.d/dhcpd start
Запускается dhcpd: [ СБОЙ ]
В чем может быть проблема?
а в скрипте как вызывается? возможно там конфиг неправильно указан или путь... посмотри вобщем
Admiral83
20-01-2006, 12:58
Я нашел, куда DHCPD пишет логи.
Вот запускаю /etc/rc.d/init.d/dhcpd start
И вот что он пишет:
Jan 20 11:51:07 localhost dhcpd: Can't open lease database /var/lib/dhcp/dhcpd.leases: Permission denied --
Jan 20 11:51:07 localhost dhcpd: check for failed database rewrite attempt!
Jan 20 11:51:07 localhost dhcpd: Please read the dhcpd.leases manual page if you
Jan 20 11:51:07 localhost dhcpd: don't know what to do about this.
Jan 20 11:51:07 localhost dhcpd:
--Вырезано--
Jan 20 11:51:07 localhost dhcpd:
Jan 20 11:51:07 localhost dhcpd: exiting.
Что делать? Файл /var/lib/dhcp/dhcpd.leases существует. Если просто запустить /usr/sbin/dhcpd то прога работает нормально и туда пишет свою информацию о выданных адресах. Доступ к файлу dhcpd.leases -rw-r--r--
Guest 80 247 100
20-01-2006, 13:46
Admiral83
раз ругается на отсутствие прав, значит их ему не хватает :О)
может из скрипта он запускается не по root -ом?
хотя странно, dhcpd всегда под ним стартовал..
Admiral83
20-01-2006, 15:14
Поставил на файл права -rw-rw-rw- все равно пишет в логах то же самое.
Вот файл /etc/rc.d/init.d/dhcpd:
# 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
CF='/etc/dhcpd.conf'
if [[ "$DHCPDARGS" = *-cf* ]]; then
CF=`echo $DHCPDARGS | sed 's/^.*-cf[\ \ ]*//;s/[\ \ ].*$//';`;
fi;
[ -f "$CF" ] || exit 0
if [ ! -f /var/lib/dhcp/dhcpd.leases ] ; then
touch /var/lib/dhcp/dhcpd.leases
[ -x /sbin/restorecon ] && [ -d /selinux ] && /sbin/restorecon /var/lib/dhcp/dhcpd.leases
fi
RETVAL=0
prog="dhcpd"
configtest()
{
CFA=''
if [[ "$DHCPDARGS" = *-cf* ]]; then
CFA=`echo $DHCPDARGS | sed 's/^.*-cf[\ \ ]*/-cf/;s/[\ \ ].*$//;s/-cf/-cf /'`;
fi;
/usr/sbin/dhcpd -t $CFA
return $?
}
start() {
# Start daemons.
echo -n $"Starting $prog: "
daemon /usr/sbin/dhcpd ${DHCPDARGS} 2>/dev/null
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
touch /var/lock/subsys/dhcpd
if [ -x /usr/bin/logger ]; then
/usr/bin/logger -t dhcpd 'dhcpd startup succeeded'
fi;
else
if [ -x /usr/bin/logger ]; then
/usr/bin/logger -t dhcpd 'dhcpd startup failed'
fi;
fi
return $RETVAL
}
stop() {
# Stop daemons.
echo -n $"Shutting down $prog: "
killproc dhcpd
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
rm -f /var/lock/subsys/dhcpd
if [ -x /usr/bin/logger ]; then
/usr/bin/logger -t dhcpd 'dhcpd shutdown succeeded'
fi;
else
if [ -x /usr/bin/logger ]; then
/usr/bin/logger -t dhcpd 'dhcpd shutdown failed'
fi;
fi
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
configtest || exit $?
stop
start
RETVAL=$?
;;
condrestart)
if [ -f /var/lock/subsys/dhcpd ]; then
stop
start
RETVAL=$?
fi
;;
configtest)
configtest
RETVAL=$?
;;
status)
status dhcpd
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|configtest|status}"
exit 1
esac
exit $RETVAL
Причем, если запустить /usr/sbin/dhcpd а потом /etc/rc.d/init.d/dhcpd stop , то он нормально останавливается.
Что тут может быть неправильного?
а может нет прав на чтение/запись в папку /var/lib/dhcp ?
Admiral83
20-01-2006, 15:54
нет, все есть drwxr-xr-x
Просто не понять: сам по себе файл /usr/sbin/dhcpd запускается, и работает - раздает айпишники, редактирует файл /var/lib/dhcp/dhcpd.leases, а скрипт почему-то не запускается.
Что может быть?
Admiral83 мне вот интересно еще что такое ${DHCPDARGS} ? попробуй распечатать чтоли его, а вообще стучи в ась, мне самому интересно стало :)
нет, все есть drwxr-xr-x
данные права дают право на запись только для владельца папки. проверьте, запускаете ли вы dhcpd от пользователя, являющегося владельцем /var/lib/dhcp/
+ действительно было бы интересно посмотреть на значение переменной $DHCPDARGS. вполне возможно, что именно из-за использованя некоторых ключей запуска dhcpd из скрипта init.d и происходят ошибки.
Admiral83
23-01-2006, 09:43
В файле #!/bin/sh, причем sh - это ссылка на /bin/bash.
Причем замечено (спасибо 3kLiN), что если сделать скрипт dhcpd не исполняемым а текстовым
chmod -x /etc/rc.d/init.d/dhcpd
, а затем
sh /etc/init.d/dhcpd start
то все нормально запускается.
Так же как исполняемый файл он работает, т.к. если в него поместь строчку echo "TEST", то он выводит его.
Где могут быть грабли?
вообще, тут организовалось такое предложение: поставить официальный федоровский dhcpd ( берём здесь (http://download.fedora.redhat.com/pub/fedora/linux/core/updates/4/i386/dhcp-3.0.2-28.FC4.i386.rpm) ). только что себе на fc3 поставил dhcpd и всё нормально работает. =)
Admiral83
23-01-2006, 17:25
Поставил новую - те же самые грабли.
Кто подскажет, почему такая фигня? :o :
[root@localhost etc]# /bin/sh /etc/rc.d/init.d/dhcpd start
Запускается dhcpd: [ ОК ]
[root@localhost etc]# /bin/sh /etc/rc.d/init.d/dhcpd stop
Останавливается dhcpd: [ ОК ]
[root@localhost etc]# /etc/rc.d/init.d/dhcpd start
Запускается dhcpd: [ СБОЙ ]
Вот лог:
Jan 23 16:21:44 localhost dhcpd: Internet Systems Consortium DHCP Server V3.0.2-RedHat
Jan 23 16:21:44 localhost dhcpd: Copyright 2004 Internet Systems Consortium.
Jan 23 16:21:44 localhost dhcpd: All rights reserved.
Jan 23 16:21:44 localhost dhcpd: For info, please visit http://www.isc.org/sw/dhcp/
Jan 23 16:21:44 localhost dhcpd: Wrote 0 leases to leases file.
Jan 23 16:21:44 localhost dhcpd: Listening on LPF/eth0/00:50:22:8f:a0:49/192.168.2/24
Jan 23 16:21:44 localhost dhcpd: Sending on LPF/eth0/00:50:22:8f:a0:49/192.168.2/24
Jan 23 16:21:44 localhost dhcpd: Sending on Socket/fallback/fallback-net
Jan 23 16:21:44 localhost dhcpd: dhcpd startup succeeded
Jan 23 16:21:49 localhost dhcpd: dhcpd shutdown succeeded
Jan 23 16:22:03 localhost dhcpd: Internet Systems Consortium DHCP Server V3.0.2-RedHat
Jan 23 16:22:03 localhost dhcpd: Copyright 2004 Internet Systems Consortium.
Jan 23 16:22:03 localhost dhcpd: All rights reserved.
Jan 23 16:22:03 localhost dhcpd: For info, please visit http://www.isc.org/sw/dhcp/
Jan 23 16:22:03 localhost dhcpd: Can't open lease database /var/lib/dhcp/dhcpd.leases: Permission denied --
Jan 23 16:22:03 localhost dhcpd: check for failed database rewrite attempt!
Jan 23 16:22:03 localhost dhcpd: Please read the dhcpd.leases manual page if you
Jan 23 16:22:03 localhost dhcpd: don't know what to do about this.
Jan 23 16:22:03 localhost dhcpd:
Jan 23 16:22:03 localhost dhcpd: If you did not get this software from ftp.isc.org, please
Jan 23 16:22:03 localhost dhcpd: get the latest from ftp.isc.org and install that before
Jan 23 16:22:03 localhost dhcpd: requesting help.
Jan 23 16:22:03 localhost dhcpd:
Jan 23 16:22:03 localhost dhcpd: If you did get this software from ftp.isc.org and have not
Jan 23 16:22:03 localhost dhcpd: yet read the README, please read it before requesting help.
Jan 23 16:22:03 localhost dhcpd: If you intend to request help from the dhcp-server@isc.org
Jan 23 16:22:03 localhost dhcpd: mailing list, please read the section on the README about
Jan 23 16:22:03 localhost dhcpd: submitting bug reports and requests for help.
Jan 23 16:22:03 localhost dhcpd:
Jan 23 16:22:03 localhost dhcpd: Please do not under any circumstances send requests for
Jan 23 16:22:03 localhost dhcpd: help directly to the authors of this software - please
Jan 23 16:22:03 localhost dhcpd: send them to the appropriate mailing list as described in
Jan 23 16:22:03 localhost dhcpd: the README file.
Jan 23 16:22:03 localhost dhcpd:
Jan 23 16:22:03 localhost dhcpd: exiting.
Jan 23 16:22:03 localhost dhcpd: dhcpd startup failed
Admiral83
24-01-2006, 10:04
Попробовал удалить dhcpd.leases, при следующем запуске /etc/rc.d/init.d/dhcpd start файл заново создался и теперь вот что получается:
[root@localhost init.d]# /etc/init.d/dhcpd start
Запускается dhcpd: [ СБОЙ ]
[root@localhost etc]# sh /etc/init.d/dhcpd start
Запускается dhcpd: [ ОК ]
[root@localhost etc]# sh /etc/init.d/dhcpd stop
Останавливается dhcpd: [ ОК ]
[/qoute]
А вот логи:
[quote]
Jan 24 08:53:37 localhost dhcpd: Internet Systems Consortium DHCP Server V3.0.2-RedHat
Jan 24 08:53:37 localhost dhcpd: Copyright 2004 Internet Systems Consortium.
Jan 24 08:53:37 localhost dhcpd: All rights reserved.
Jan 24 08:53:37 localhost dhcpd: For info, please visit http://www.isc.org/sw/dhcp/
Jan 24 08:53:37 localhost dhcpd: Wrote 0 leases to leases file.
Jan 24 08:53:38 localhost dhcpd: Listening on LPF/eth0/00:50:22:8f:a0:49/192.168.2/24
Jan 24 08:53:38 localhost dhcpd: Sending on LPF/eth0/00:50:22:8f:a0:49/192.168.2/24
Jan 24 08:53:38 localhost dhcpd: Can't bind to dhcp address: Permission denied
Jan 24 08:53:38 localhost dhcpd: Please make sure there is no other dhcp server
Jan 24 08:53:38 localhost dhcpd: running and that there's no entry for dhcp or
Jan 24 08:53:38 localhost dhcpd: bootp in /etc/inetd.conf. Also make sure you
Jan 24 08:53:38 localhost dhcpd: are not running HP JetAdmin software, which
Jan 24 08:53:38 localhost dhcpd: includes a bootp server.
Jan 24 08:53:38 localhost dhcpd:
Jan 24 08:53:38 localhost dhcpd: If you did not get this software from ftp.isc.org, please
Jan 24 08:53:38 localhost dhcpd: get the latest from ftp.isc.org and install that before
Jan 24 08:53:38 localhost dhcpd: requesting help.
Jan 24 08:53:38 localhost dhcpd:
Jan 24 08:53:38 localhost dhcpd: If you did get this software from ftp.isc.org and have not
Jan 24 08:53:38 localhost dhcpd: yet read the README, please read it before requesting help.
Jan 24 08:53:38 localhost dhcpd: If you intend to request help from the dhcp-server@isc.org
Jan 24 08:53:38 localhost dhcpd: mailing list, please read the section on the README about
Jan 24 08:53:38 localhost dhcpd: submitting bug reports and requests for help.
Jan 24 08:53:38 localhost dhcpd:
Jan 24 08:53:38 localhost dhcpd: Please do not under any circumstances send requests for
Jan 24 08:53:38 localhost dhcpd: help directly to the authors of this software - please
Jan 24 08:53:38 localhost dhcpd: send them to the appropriate mailing list as described in
Jan 24 08:53:38 localhost dhcpd: the README file.
Jan 24 08:53:38 localhost dhcpd:
Jan 24 08:53:38 localhost dhcpd: exiting.
Jan 24 08:53:38 localhost dhcpd: dhcpd startup failed
Jan 24 08:54:10 localhost dhcpd: Internet Systems Consortium DHCP Server V3.0.2-RedHat
Jan 24 08:54:10 localhost dhcpd: Copyright 2004 Internet Systems Consortium.
Jan 24 08:54:10 localhost dhcpd: All rights reserved.
Jan 24 08:54:10 localhost dhcpd: For info, please visit http://www.isc.org/sw/dhcp/
Jan 24 08:54:10 localhost dhcpd: Wrote 0 leases to leases file.
Jan 24 08:54:10 localhost dhcpd: Listening on LPF/eth0/00:50:22:8f:a0:49/192.168.2/24
Jan 24 08:54:10 localhost dhcpd: Sending on LPF/eth0/00:50:22:8f:a0:49/192.168.2/24
Jan 24 08:54:10 localhost dhcpd: Sending on Socket/fallback/fallback-net
Jan 24 08:54:10 localhost dhcpd: dhcpd startup succeeded
Jan 24 08:54:14 localhost dhcpd: dhcpd shutdown succeeded
Мне кажеться, что проблемы с вызовом функции daemon из файла /etc/rc.d/init.d/functions. Только не понятно, почему из командной строки нормально она запускается, а из автозагрузки - нет. Так же не понятно, почему все остальные серверы нормально запускаются, к примеру ssh или samba.
© OSzone.net 2001-2012
vBulletin v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.