编辑

编辑

我正在尝试使用我飞来飞去的 raspberrypi (OS=raspbian 4.0.7),所以我研究了一点,一切似乎或多或少都工作得很好。我将 hostapd 与 wifi dongle 结合使用来提供 AccessPoint 和 dhcpd 作为 DHCP 服务器。

浏览日志我发现了一些奇怪的事情:

Jul  1 21:34:37 raspberrypi dhcpd: DHCPDISCOVER from 00:e0:4c:18:fd:0c (raspberrypi) via wlan0
Jul  1 21:34:38 raspberrypi dhcpd: DHCPOFFER on 10.0.0.12 to 00:e0:4c:18:fd:0c (raspberrypi) via wlan0
Jul  1 21:35:41 raspberrypi dhcpd: DHCPDISCOVER from 00:e0:4c:18:fd:0c (raspberrypi) via wlan0
Jul  1 21:35:42 raspberrypi dhcpd: DHCPOFFER on 10.0.0.12 to 00:e0:4c:18:fd:0c (raspberrypi) via wlan0
Jul  1 21:36:45 raspberrypi dhcpd: DHCPDISCOVER from 00:e0:4c:18:fd:0c (raspberrypi) via wlan0
Jul  1 21:36:46 raspberrypi dhcpd: DHCPOFFER on 10.0.0.12 to 00:e0:4c:18:fd:0c (raspberrypi) via wlan0

为什么会发生这种情况?我怎样才能阻止它?

如果配置:

eth0  Link encap:Ethernet  HWaddr b8:27:eb:cd:a0:b7
      inet addr:195.169.228.44  Bcast:195.169.229.255  Mask:255.255.254.0
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:7447 errors:0 dropped:21 overruns:0 frame:0
      TX packets:2033 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:1829496 (1.7 MiB)  TX bytes:347081 (338.9 KiB)

lo    Link encap:Local Loopback
      inet addr:127.0.0.1  Mask:255.0.0.0
      UP LOOPBACK RUNNING  MTU:65536  Metric:1
      RX packets:51 errors:0 dropped:0 overruns:0 frame:0
      TX packets:51 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:3876 (3.7 KiB)  TX bytes:3876 (3.7 KiB)

wlan0 Link encap:Ethernet  HWaddr 00:e0:4c:18:fd:0c
      inet addr:10.0.0.1  Bcast:10.0.0.255  Mask:255.255.255.0
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:2703 errors:0 dropped:15 overruns:0 frame:0
      TX packets:2713 errors:0 dropped:7 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:467746 (456.7 KiB)  TX bytes:1434643 (1.3 MiB)

dhcpd 配置:

ddns-update-style none;

default-lease-time 600;
max-lease-time 7200;

authoritative;

subnet 10.0.0.0 netmask 255.255.255.0 {
    range 10.0.0.10 10.0.0.50;
    option broadcast-address 10.0.0.255;
    option routers  10.0.0.1;
    option domain-name "marienbosch-network";
    option domain-name-servers 8.8.8.8, 8.8.4.4;
}

编辑:

/etc/网络/接口:

auto lo
    iface lo inet loopback

auto eth0
    allow-hotplug eth0
    iface eth0 inet static
    address 195.169.228.44
    netmask 255.255.254.0
    gateway 195.169.229.254

auto wlan0
iface wlan0 inet static
    address 10.0.0.1
    netmask 255.255.255.0

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

ip表:

*filter
:INPUT ACCEPT [525:53548]
:FORWARD ACCEPT [6:302]
:OUTPUT ACCEPT [105:11782]
-A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD -i wlan0 -o eth0 -j ACCEPT
COMMIT

*nat
:PREROUTING ACCEPT [373:47175]
:INPUT ACCEPT [99:10520]
:OUTPUT ACCEPT [34:2555]
:POSTROUTING ACCEPT [7:645]
-A POSTROUTING -o eth0 -j MASQUERADE
COMMIT

编辑
为了尝试解决此问题,在 /etc/network/interfaces 中将 wlan0 从静态更改为 dhcp,
这导致重新启动后出现以下情况:

Listening on LPF/wlan0/"mac address of wlan device"
Sending on LPF/wlan0/"mac address of wlan device"
Sending on Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 11
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 20
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 14
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 6
No DHCP OFFERS received
...  

,恢复为静态,如 /etc/network/interfaces 下所示

答案1

是的,它在 dhcp 守护程序或您可以下载的其他动态主机配置协议实用程序的帮助下提供 IP。您只需将 dhcpd 的配置文件设置为默认即可停止回显。

编辑

(在我看来)问题出在评论中所述的“/etc/network/interfaces”。

查询者具有静态设置 wlan0 的设置,但应该这样做;

'iface wlan0 inet dhcp'

相关内容