isc-dhcp-server安装和运行问题


8

我试图按照Adafruit的指示将pi设置为访问点。但是,由于某种原因,sudo apt-get install isc-dhcp-server总是会失败。我看过此链接,但是在dhcpd.conf中定义了一个子网(来自Adafruit):

/etc/dhcp/dhcpd.conf

              .
              .
              .
#    range 10.0.29.10 10.0.29.230;
#  }
#}

subnet 192.168.42.0 netmask 255.255.255.0 {
range 192.168.42.10 192.168.42.50;
option broadcast-address 192.168.42.255;
option routers 192.168.42.1;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}

当我这样做时sudo apt-get install isc-dhcp-server,我得到:

Generating /etc/default/isc-dhcp-server...
[FAIL] Starting ISC DHCP server: dhcpd[....] check syslog for diagnostics. ... failed!
 failed!

pi@raspberrypi ~ $ sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
pi@raspberrypi ~ $ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
pi@raspberrypi ~ $ sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED \
> -j ACCEPT
pi@raspberrypi ~ $ sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
pi@raspberrypi ~ $ sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
pi@raspberrypi ~ $ sudo service hostapd start
[ ok ] Starting advanced IEEE 802.11 management: hostapd.
pi@raspberrypi ~ $ sudo service isc-dhcp-server start
[FAIL] Starting ISC DHCP server: dhcpd[....] check syslog for diagnostics. ... failed!
 failed!

/ var / log / syslog:

Jul 26 03:05:25 raspberrypi dhcpd: Wrote 0 leases to leases file.
Jul 26 03:05:25 raspberrypi dhcpd:
Jul 26 03:05:25 raspberrypi dhcpd: No subnet declaration for wlan0 (192.168.42.\
1).
Jul 26 03:05:25 raspberrypi dhcpd: ** Ignoring requests on wlan0.  If this is n\
ot what
Jul 26 03:05:25 raspberrypi dhcpd:    you want, please write a subnet declarati\
on
Jul 26 03:05:25 raspberrypi dhcpd:    in your dhcpd.conf file for the network s\
egment
Jul 26 03:05:25 raspberrypi dhcpd:    to which interface wlan0 is attached. **
Jul 26 03:05:25 raspberrypi dhcpd:
Jul 26 03:05:25 raspberrypi dhcpd:
Jul 26 03:05:25 raspberrypi dhcpd: Not configured to listen on any interfaces!

我该如何解决?


我在最新的Raspbian上仍然遇到问题。似乎与该错误有关:bugs.debian.org/cgi-bin/bugreport.cgi? bug= 590641它似乎尚未修复,并且可能还会影响Raspbian
coolnodje 2014年

Answers:


11

如果您确定dhpcd配置中设置的子网属于已经配置的接口(我想是wlan0)。比较/ etc / network / interfaces和/etc/dhcp/dhcpd.conf中的IP子网。

另外,在Debian(以及Raspbian)上,检查/ etc / default / isc-dhcp-server,因为它应该包含您的接口名称,如下所示:

# Defaults for dhcp initscript
# sourced by /etc/init.d/dhcp
# installed at /etc/default/isc-dhcp-server by the maintainer scripts

#
# This is a POSIX shell fragment
#

# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
#   Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES="wlan0"

这两件事都是在教程中设置的,因此我假设您忽略其中至少之一。


我检查了所有内容,并且一切似乎都正确,但是某些方法起作用了
calccrypto

2
这是错的!您需要具有INTERFACES=""出厂默认设置!您所需要做的就是通过subnet {}子句定义所有/ etc / network / interfaces子网。对于不需要DHCPD服务的子网,您需要一个空subnet子句。如此处建议的那样,将接口名称放在INTERFACES中会破坏DHCPD。在Raspbian Jessie上验证。
Alexey Vesnin

5

您需要在出厂时将INTERFACES =“”设置为默认值!甚至更多-自动更新可以覆盖它。此问题与DHCPD有关,而不与操作系统有关。您需要做的是通过一个子网{}子句定义所有/ etc / network / interfaces子网。对于不需要由DHCPD服务的子网,您需要一个空白的子网子句,如下所示:

# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.

subnet 192.168.0.0 netmask 255.255.255.0 {
}

上面的注释来自出厂原始配置示例。以我为例,在这个网络上,不需要处理任何IP请求,但是如果没有这个 subnet子句,DHCPD就会像这样拒绝启动:

Jan 29 19:08:44 pi dhcpd: Internet Systems Consortium DHCP Server 4.3.1
Jan 29 19:08:44 pi dhcpd: Copyright 2004-2014 Internet Systems Consortium.
Jan 29 19:08:44 pi dhcpd: All rights reserved.
Jan 29 19:08:44 pi dhcpd: For info, please visit https://www.isc.org/software/dhcp/
Jan 29 19:08:44 pi dhcpd: Internet Systems Consortium DHCP Server 4.3.1
Jan 29 19:08:44 pi dhcpd: Copyright 2004-2014 Internet Systems Consortium.
Jan 29 19:08:44 pi dhcpd: All rights reserved.
Jan 29 19:08:44 pi dhcpd: For info, please visit https://www.isc.org/software/dhcp/
 Jan 29 19:08:44 pi dhcpd: Wrote 2 leases to leases file.
 Jan 29 19:08:44 pi dhcpd:
 Jan 29 19:08:44 pi dhcpd: No subnet declaration for wlan0 (no IPv4 addresses).
 Jan 29 19:08:44 pi dhcpd: ** Ignoring requests on wlan0.  If this is not what
 Jan 29 19:08:44 pi dhcpd:    you want, please write a subnet declaration
 Jan 29 19:08:44 pi dhcpd:    in your dhcpd.conf file for the network segment
 Jan 29 19:08:44 pi dhcpd:    to which interface wlan0 is attached. **
 Jan 29 19:08:44 pi dhcpd:
 Jan 29 19:08:44 pi dhcpd:
 Jan 29 19:08:44 pi dhcpd: Not configured to listen on any interfaces!
 Jan 29 19:08:44 pi dhcpd:
 Jan 29 19:08:44 pi dhcpd: If you think you have received this message due to a bug rather
 Jan 29 19:08:44 pi dhcpd: than a configuration issue please read the section on submitting
 Jan 29 19:08:44 pi dhcpd: bugs on either our web page at www.isc.org or in the README file
 Jan 29 19:08:44 pi dhcpd: before submitting a bug.  These pages explain the proper
 Jan 29 19:08:44 pi dhcpd: process and the information we find helpful for debugging..
 Jan 29 19:08:44 pi dhcpd:
 Jan 29 19:08:44 pi dhcpd: exiting.
 Jan 29 19:08:46 pi isc-dhcp-server[3332]: Starting ISC DHCP server: dhcpdcheck syslog for diagnostics. ... failed!
 Jan 29 19:08:46 pi isc-dhcp-server[3332]: failed!
 Jan 29 19:08:46 pi systemd[1]: isc-dhcp-server.service: control process exited, code=exited status=1
 Jan 29 19:08:46 pi systemd[1]: Unit isc-dhcp-server.service entered failed state.

地狱怪异的所有此错误消息的是,/etc/dhcp/dhcpd.conf居然用于为wlan0的子网中的全功能子网条款。为eth0子网添加一个子句可以解决所有问题。

如此处建议的那样,将接口名称放在INTERFACES中会破坏DHCPD。在Raspbian Jessie和其他操作系统上进行了验证。


2
我不确定用“ 这是错误的答案”开始回答是最好的主意
。–

@Ghanima谢谢!我已将我的评论复制到错误的答案中=)错过了它=)已修复!
Alexey Vesnin

1

ISC DHCP服务器正常。

将/ etc / default / isc-dhcp-server INTERFACES =“ wlan0”更改为eth0

服务isc-dhcp-server启动好吗?

将/ etc / default / isc-dhcp-server INTERFACES =“ eth0”更改为wlan0

......接口wlan0做IP地址

ifconfig,wlan0 IP?

.. nano / etc / network / interfaces

iface wlan0 inet静态地址192.168.42.2网络掩码255.255.255.0 ..

ifdown wlan0 ifup wlan0 ifconfig wlan0

wlan0链接encap:以太网HWaddr 00:00:xx:xx:xx:xx inet地址:192.168.42.2 Bcast:192.168.42.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packet:1153 errors:0掉落:0超限:0帧:0 TX数据包:1178错误:0掉落:0超限:0载波:0冲突:0 txqueuelen:1000 RX字节:219204(214.0 KiB)TX字节:245615(239.8 KiB)

服务isc-dhcp-server启动


3
您的回答有点含糊,请下次再添加更多说明?
lenik


-1

配置/编辑无头服务器时的常见错误是使用Windows IDE编辑文件。如果这样做,请使用Notepad ++,然后不要忘记检查Format is => UNIX格式 && Encode in UTF-8 without BOM

解决大多数这种奇怪的行为。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.