为何我的 DHCP 服务器不工作?

为何我的 DHCP 服务器不工作?

我正在尝试用我的树莓派设置一个 DHCP 服务器,但是服务isc-dhcp 服务器無法啟動。

为什么不重新启动服务?

是否配置

eth0      Link encap:Ethernet  HWaddr X  
          inet6 addr: fe80::3d41:3edd:7319:617e/64 Scope:Link
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

eth1      Link encap:Ethernet  HWaddr X  
          inet addr:169.254.6.116  Bcast:169.254.255.255  Mask:255.255.0.0
          inet6 addr: fe80::f16d:b76f:795e:d4ff/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:299 errors:0 dropped:0 overruns:0 frame:0
          TX packets:72 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:40462 (39.5 KiB)  TX bytes:20406 (19.9 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:200 errors:0 dropped:0 overruns:0 frame:0
          TX packets:200 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:16656 (16.2 KiB)  TX bytes:16656 (16.2 KiB)

wlan0     Link encap:Ethernet  HWaddr X  
          inet addr:192.168.0.102  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::704a:b2ae:8ac9:48e/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1022 errors:0 dropped:11 overruns:0 frame:0
          TX packets:726 errors:0 dropped:1 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:125229 (122.2 KiB)  TX bytes:114072 (111.3 KiB)

/etc/网络/接口

auto lo
iface lo inet loopback

iface eth0 inet manual

iface eth1 inet dhcp
    address 192.168.2.1
    netmask 255.0.0.0

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

/etc/dhcp/dhcpd.conf

ddns-update-style none;
log-facility local7;

subnet 192.168.2.0 netmask 255.255.255.0 {

        option routers                  192.168.2.1;
        option subnet-mask              255.255.255.0;
        option broadcast-address        192.168.2.255;
        option domain-name-servers      194.168.2.1;
        option ntp-servers              192.168.2.1;
        option netbios-name-servers     192.168.2.1;
        option netbios-node-type 2;
        default-lease-time 86400;
        max-lease-time 86400;

        pool {
                range 192.168.2.2 192.168.2.254;
        }

        host gateway {
                hardware ethernet x;
                fixed-address 192.168.2.1;

        }

}

服务 isc-dhcp-服务器重新启动

Job for isc-dhcp-server.service failed. See 'systemctl status isc-dhcp-server.service' and 'journalctl -xn' for details.

systemctl status isc-dhcp-server.service

Mar 25 20:33:55 raspberrypi dhcpd[1146]: 
Mar 25 20:33:55 raspberrypi dhcpd[1146]: No subnet declaration for wlan0 (192.168.0.102).
Mar 25 20:33:55 raspberrypi dhcpd[1146]: ** Ignoring requests on wlan0.  If this is not what
Mar 25 20:33:55 raspberrypi dhcpd[1146]: you want, please write a subnet declaration
Mar 25 20:33:55 raspberrypi dhcpd[1146]: in your dhcpd.conf file for the network segment
Mar 25 20:33:57 raspberrypi isc-dhcp-server[1138]: Starting ISC DHCP server: dhcpdcheck syslog for diagnostics. ... failed!
Mar 25 20:33:57 raspberrypi isc-dhcp-server[1138]: failed!
Mar 25 20:33:57 raspberrypi systemd[1]: isc-dhcp-server.service: control process exited, code=exited status=1
Mar 25 20:33:57 raspberrypi systemd[1]: Failed to start LSB: DHCP server.
Mar 25 20:33:57 raspberrypi systemd[1]: Unit isc-dhcp-server.service entered failed state

已编辑

/etc/default/isc-dhcp 服务器

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

#
# This is a POSIX shell fragment
#

# Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
#DHCPD_CONF=/etc/dhcp/dhcpd.conf

# Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
#DHCPD_PID=/var/run/dhcpd.pid

# Additional options to start dhcpd with.
#       Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
#OPTIONS=""

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

答案1

在中/etc/network/interfaces,您需要将 eth1 的节更改为如下形式

auto eth1
iface eth1 inet static
    address 192.168.2.1
    netmask 255.255.255.0

你似乎已经/etc/default/isc-dhcp-server掌握了

相关内容