我正在尝试编写一个在 raspbian 上调用时启动 hostapd 的脚本,但我无法摆脱 dhcp 客户端进程:
启动hostapd.sh
echo 'stopping wpa supplicant'
systemctl stop wpa_supplicant.service
sudo dhcpcd -k wlan0
echo 'bringing interface down'
ifdown wlan0
ifconfig wlan0 192.168.1.1
ifconfig wlan0 netmask 255.255.255.0
echo 'tarting hostapd'
systemctl start hostapd.service
ifup wlan0
systemctl start isc-dhcp-server.service
然而,当我运行它时,dhcp 客户端会激活并阻止所有内容:
sudo sh start-hostapd.sh
stopping wpa supplicant
dhcpcd[1181]: sending commands to master dhcpcd process
bringing interface down
Killed old client process
Internet Systems Consortium DHCP Client 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/wlan0/b8:27:eb:b8:86:33
Sending on LPF/wlan0/b8:27:eb:b8:86:33
Sending on Socket/fallback
DHCPRELEASE on wlan0 to 10.0.1.1 port 67
tarting hostapd
Internet Systems Consortium DHCP Client 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/wlan0/b8:27:eb:b8:86:33
Sending on LPF/wlan0/b8:27:eb:b8:86:33
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 5
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPOFFER from 10.0.1.1
DHCPACK from 10.0.1.1
bound to 10.0.1.15 -- renewal in 33866 seconds.
如何防止 dhcpd 这样做?
答案1
不管是什么原因造成的,肯定不是 dhcp服务器这样做,只是监听请求并响应。顺便说一句,我已经在我的 wlan0 上运行hostapd
多年isc-dhcp-server
了 - dhcp 服务器对于 AP 来说几乎是必不可少的。
看起来您有一个 dhclient 在 wlan0 上运行。也许你有iface wlan0 inet dhcp
在/etc/network/interfaces
.如果是这样,请将其更改为:
iface wlan0 inet static
address 192.168.1.1
netmask 255.255.255.0
broadcast 192.168.1.255
或者也许您正在运行网络管理器。从轨道上用核武器攻击它。
另外,你应该运行ifup wlan0
前开始hostapd
.