我有一台安装了 raspbian 的 raspberry pi 2。它通过局域网 (eth0) 连接到路由器,并具有静态地址 192.168.254.106。
我还有一个 USB wifi 适配器,连接到我的树莓派。它运行良好 - 我可以通过 Web 界面连接到任何 wifi 网络。现在我想将我的树莓派用作热点(接入点),并且我的 wifi 客户端的 IP 范围应为 192.168.254.201 - 192.168.254.250(并且 wifi AP 地址应为 192.168.254.200)。因此,我安装了两个软件包:
- isc-dhcp 服务器
- hostapd
这是我的设置:
猫/etc/dhcp/dhcpd.conf:
subnet 192.168.254.0 netmask 255.255.255.0 {
range 192.168.254.201 192.168.254.250;
option broadcast-address 192.168.254.255;
option routers 192.168.254.106;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local";
option domain-name-servers 8.8.8.8, 8.8.4.4, 64.6.64.6, 64.6.65.6;
}
猫/etc/hostapd/hostapd.conf:
interface=wlan0
driver=nl80211
#driver=mt7601u
ssid=somename
hw_mode=g
channel=7
wmm_enabled=0
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=somepassword
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
logger_syslog=-1
猫/etc/dhcpcd.conf:
interface eth0
static ip_address=192.168.254.106
static routers=192.168.254.1
static domain_name_servers=192.168.254.1
static domain_search=
interface wlan0
static ip_address=192.168.254.200/24
nohook wpa_supplicant
static routers=
static domain_name_servers=
static domain_search=
猫/etc/dnsmasq.conf:
interface=wlan0
dhcp-range=192.168.254.201,192.168.254.250,255.255.255.0,24h
当我跑步时sudo systemctl 启动 isc-dhcp-server我懂了:
Job for isc-dhcp-server.service failed because the control process exited with error code.
See "systemctl status isc-dhcp-server.service" and "journalctl -xe" for details.
系统日志中包含以下消息:
Dec 19 01:22:58 raspberrypi isc-dhcp-server[6049]: Launching IPv4 server only.
Dec 19 01:23:00 raspberrypi isc-dhcp-server[6049]: Starting ISC DHCPv4 server: dhcpdcheck syslog for diagnostics. ... failed!
Dec 19 01:23:00 raspberrypi isc-dhcp-server[6049]: failed!
Dec 19 01:23:00 raspberrypi systemd[1]: isc-dhcp-server.service: Control process exited, code=exited, status=1/FAILURE
Dec 19 01:23:00 raspberrypi systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.
Dec 19 01:44:26 raspberrypi isc-dhcp-server[9461]: Launching IPv4 server only.
Dec 19 01:44:28 raspberrypi isc-dhcp-server[9461]: Starting ISC DHCPv4 server: dhcpdcheck syslog for diagnostics. ... failed!
Dec 19 01:44:28 raspberrypi isc-dhcp-server[9461]: failed!
Dec 19 01:44:28 raspberrypi systemd[1]: isc-dhcp-server.service: Control process exited, code=exited, status=1/FAILURE
Dec 19 01:44:28 raspberrypi systemd[1]: isc-dhcp-server.service: Failed with result 'exit-code'.
当我跑步时sudo systemctl 启动 hostapd我懂了:
Job for hostapd.service failed because the control process exited with error code.
See "systemctl status hostapd.service" and "journalctl -xe" for details.
系统日志中包含以下消息:
Dec 19 01:48:58 raspberrypi hostapd[10258]: Configuration file: /etc/hostapd/hostapd.conf
Dec 19 01:48:58 raspberrypi hostapd[10258]: nl80211: Could not configure driver mode
Dec 19 01:48:58 raspberrypi hostapd[10258]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
Dec 19 01:48:58 raspberrypi hostapd[10258]: nl80211 driver initialization failed.
Dec 19 01:48:58 raspberrypi hostapd[10258]: wlan0: interface state UNINITIALIZED->DISABLED
Dec 19 01:48:58 raspberrypi hostapd[10258]: wlan0: AP-DISABLED
Dec 19 01:48:58 raspberrypi hostapd[10258]: wlan0: CTRL-EVENT-TERMINATING
Dec 19 01:48:58 raspberrypi hostapd[10258]: hostapd_free_hapd_data: Interface wlan0 wasn't started
Dec 19 01:48:58 raspberrypi systemd[1]: hostapd.service: Control process exited, code=exited, status=1/FAILURE
Dec 19 01:48:58 raspberrypi systemd[1]: hostapd.service: Failed with result 'exit-code'.
以下是我的配置文件:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.254.105 netmask 255.255.255.0 broadcast 192.168.254.255
inet6 fd00:adc3:bfbf:0:5b84:2f54:149d:bf8 prefixlen 64 scopeid 0x0<global>
inet6 fd00:adc3:bfbf::f6f prefixlen 128 scopeid 0x0<global>
inet6 fe80::e8be:f86a:f528:af4b prefixlen 64 scopeid 0x20<link>
inet6 fd00:adc3:bfbf:0:e1c9:c71d:4c6c:d63f prefixlen 64 scopeid 0x0<global>
ether b8:27:eb:fc:50:d1 txqueuelen 1000 (Ethernet)
RX packets 34309 bytes 2530306 (2.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 43326 bytes 6908782 (6.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 60317 bytes 17389663 (16.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 60317 bytes 17389663 (16.5 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 7a:7b:39:0f:66:42 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
和我的系统盘:
Bus 001 Device 004: ID 148f:7601 Ralink Technology, Corp. MT7601U Wireless Adapter
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp. SMC9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
那么,我的配置文件有什么问题?