AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 783155
Accepted
Revolucion for Monica
Revolucion for Monica
Asked: 2016-06-06 06:37:41 +0800 CST2016-06-06 06:37:41 +0800 CST 2016-06-06 06:37:41 +0800 CST

服务 isc-dhcp-server 无法启动

  • 772

我目前正在做一个项目,用我的 RaspberryPi 制作一个高度安全的路由器,以便在网络上匿名导航。然而,我无法正确配置守护进程以完成 wifi 与新服务器的 Internet 连接:

确实,当我这样做时:

:~ $ sudo service isc-dhcp-server start

我得到:

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

这是我的/etc/dhcp/dhcpd.conf设置

authoritative;

#added

subnet 192.168.42.0 netmask 255.255.255.0{
        range 192.168.42.10 192.168.42.50;
        option broadcast-adress 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;
}

这是我的/etc/network/interfaces设置:

source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback
iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet static
adress 192.168.42.1
netmask 255.255.255.0

iface wlan0 inet dhcp

iface eth0 inet manual

allow-hotplug wlan0
iface wlan0 inet static
adress 192.168.42.1
netmask 255.255.255.0

iface wlan0 inet dhcp
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

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

up iptables-restore < /etc/iptables.ipv4.nat

我的 RaspberryPi 是有线连接的,但有一个 wifi 加密狗

这里是systemctl status isc-dhcp-server.service

:~ $ systemctl status isc-dhcp-server.service
● isc-dhcp-server.service - LSB: DHCP server
   Loaded: loaded (/etc/init.d/isc-dhcp-server)
   Active: failed (Result: exit-code) since Tue 2016-06-07 00:13:45 CEST; 53s ago
  Process: 18098 ExecStart=/etc/init.d/isc-dhcp-server start (code=exited, status=1/FAILURE)

有些部分是用可怕的红色写的......

这是journalctl

-- Logs begin at Mon 2016-06-06 21:17:01 CEST, end at Tue 2016-06-07 00:18:32 CEST. --
Jun 07 00:13:45 raspberrypi isc-dhcp-server[18098]: than a configuration issue please read the section on submitting
Jun 07 00:13:45 raspberrypi isc-dhcp-server[18098]: bugs on either our web page at www.isc.org or in the README file
Jun 07 00:13:45 raspberrypi isc-dhcp-server[18098]: before submitting a bug.  These pages explain the proper
Jun 07 00:13:45 raspberrypi isc-dhcp-server[18098]: process and the information we find helpful for debugging..
Jun 07 00:13:45 raspberrypi isc-dhcp-server[18098]: exiting.
Jun 07 00:17:01 raspberrypi CRON[18118]: pam_unix(cron:session): session opened for user root by (uid=0)
Jun 07 00:17:01 raspberrypi CRON[18122]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Jun 07 00:17:01 raspberrypi CRON[18118]: pam_unix(cron:session): session closed for user root
Jun 07 00:18:32 raspberrypi sudo[18139]: pi : TTY=pts/0 ; PWD=/home/pi ; USER=root ; COMMAND=/bin/journalctl -xn
Jun 07 00:18:32 raspberrypi sudo[18139]: pam_unix(sudo:session): session opened for user root by pi(uid=0)
networking
  • 2 2 个回答
  • 111939 Views

2 个回答

  • Voted
  1. Best Answer
    Revolucion for Monica
    2016-06-08T07:06:08+08:002016-06-08T07:06:08+08:00

    事情是这样的:

    最明显的一个是在这里用两个“d”写地址:

    subnet 192.168.42.0 netmask 255.255.255.0{
            range 192.168.42.10 192.168.42.50;
            option broadcast-adress 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 ifup wlan0
    

    service isc-dhcp-server多亏了这个 raspberrypihq 教程,我可以开始将 RPi 变成 routeur。

    然而,我现在有问题要运行sudo update-rc.d isc-dhcpd-server enable。任何帮助都将受到热烈欢迎!

    • 3
  2. MikeH London
    2021-09-23T03:25:51+08:002021-09-23T03:25:51+08:00

    以防它帮助任何人我刚刚在 Pi Zero W 上的 DietPi(Debian Buster)上解决了这个令人恼火的问题,并且已经解决了这个问题。

    isc-dhcp-server 非常好,但确实有这个怪癖,正如上面最初的询问者所指出的那样。我已经解决了这个问题——这不是一个错误——这就是原因的细节:

    isc-dhcp-server refuses (throws an error) if it cannot see an UP ethernet network subnet at launch time; it DOESN'T (contrary to some commentators) require an actual connection TO the ethernet port to which it is associated.
    
    When developing a WiFi Hotspot device, its normally a case of using hostapd as the AP server function (which re-configures the WiFi hardware to switch to AP mode) and alongside hostapd, you need a dhcp server like isc-dhcp-server to provide the IP address leasing service.
    
    SO: normally the start point, is a WiFi device which at boot, was configured as a CLIENT device, but needs to be switched to HOST mode to act as hotspot. So an early step is to set wlan0 (or whatever) DOWN, prior to launching hostapd.
    

    但是这种情况立即成为 isc-dhcp-server 不喜欢的情况之一:如果您尝试在 hostapd 之前启动它,它将失败,并抱怨没有子网可供它监听。

    So you may innocently then try, adding a new IP address (for the host) to your wlan0 (or equiv) and re-trying: THAT WON'T WORK EITHER, because although you now have a new IP attached to the Ethernet port, you will also find you cannot set it 'UP' (ip link set wlan0 up will FAIL). This is because the port is 'tainted' by the still-active stale address and the wpa-supplicant process which was using it.
    
    LONG STORY SHORT: you need to kill wpa-supplicant, to "free" the old address / FLUSH the ip settings for the port / THEN add the new IP address for host ; EVEN THEN, you'll find isc-dhcp-server STILL won't start, because you can't set the interface up - yet. Finally - run hostapd now, before isc, and IT will (in reconfiguring the chipset) also SET the wlan0 interface, to UP. So now - finally - you CAN run isc-dhcp-server, and it will start cleanly, and your hotspot will be up.
    

    我花了大约五个小时,我希望这可以节省一些时间。我的提炼笔记:

    将 ISC-DHCP-SERVER 与 HOSTAPD 一起排序:解决方案

    您必须遵循以下顺序:

    KILL the wpa-supplicant process (that's sustaining the client conn) this way:
    
    kill -2 $( cat /run/wpa_supplicant.wlan0.pid )
    
    sleep 1
    
    kill -9 $( cat /run/wpa_supplicant.wlan0.pid )
    
    FLUSH the WLAN IP setup, using:
    
    ip addr flush dev wlan0
    
    ADD the new host IP ADDRESS, using:
    
    ip addr add 10.1.1.1/24 dev wlan0
    
    START hostapd, which will also put wlan0 UP:
    
    /usr/sbin/hostapd /etc/hostapd/hostapd.conf &
    
    START isc-dhcp-server ( WLAN is up, as host now ):
    
    sudo service isc-dhcp-server restart
    

    那么接入点应该已启动并准备好接受客户端。

    这些当然是我的地址/编辑以满足您的需要。

    还有两个提示:配置文件 hostapd.conf 和 dhcp.conf 也会让你发疯:-这里是工作示例。重要提示:不要担心 hostapd.conf 中的“驱动程序名称”:它不是必需的。“注释掉”很好:

    hostapd.conf

    接口=wlan0

    #驱动程序=brcmfmac

    ssid =这是我的AP

    国家代码=美国

    hw_mode=g

    频道=6

    macaddr_acl=0

    auth_algs=1

    ignore_broadcast_ssid=0

    wpa=2

    wpa_passphrase=12345678

    wpa_key_mgmt=WPA-PSK

    wpa_pairwise=CCMP

    wpa_group_rekey=86400

    ieee80211n=1

    wme_enabled=1

    dhcpd.conf

    注释掉两个模板的“选项域..”行..然后在底部添加:

    子网 10.1.1.0 网络掩码 255.255.255.0 { 范围 10.1.1.100 10.1.1.109; 选项广播地址 10.1.1.255;选项路由器 10.1.1.1;默认租赁时间 600;最大租赁时间 7200;选项域名“mynetwork.org”;选项域名服务器 8.8.8.8、8.8.4.4;}

    虽然这项工作是在 Pi 上的,但它是在直接 Debian 的 DietPi 上进行的,所以同样的建议应该适合许多 Linux,包括多种风格的 Ububtus。

    祝大家好运

    • 0

相关问题

  • 如何设置 VLAN 转发?

  • 如何将主机 Ubuntu 上的 VPN (tun0) 网络适配器映射到 VirtualBox 来宾 Windows?

  • 如何限制下载/上传带宽?

  • 如何通过 Windows 网络共享文件?

  • 面板小程序以文本形式显示当前网络流量?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve