当没有已知的接入点可用时,如何有条件地在 Dietpi 上托管热点

当没有已知的接入点可用时,如何有条件地在 Dietpi 上托管热点

我正在吃一个配有 Dietpi 的覆盆子。

背景: 这个 Pi 被用作魔镜,即将成为送给朋友的礼物。它仅使用无线网络。镜像将与已知的 wpa_supplicant.conf 文件一起交付,以使其从第一天起就可以工作。用例是,如果他更改了 WPA 密钥或具有不同的 SSID,他应该能够通过 ssh 登录到 pi。

目标 总体目标是拥有一个定期检查可用网络的脚本(与接入点 (AP) 的网络连接就足够了)。

我当前的问题是我根本无法创建热点。

(工作中):因此,如果给出连接,则配置只是使用 dhcp 作为客户端。

(不工作):如果没有给出连接,则应更改 pi 上的配置以托管 AP,为其子网提供 dhcp 服务器。 (欢迎替代想法)

当我深入研究文档时,我发现 Dietpi 不能与dnsmasqbut一起使用isc-dchp-server

我使用的所有服务都已启动,没有journalctl -xe任何条目值得担心。

$systemctl list-units --type=service看起来不错

启用 APdietpi-config看起来与我的配置方式不同,因为它使用了错误的子网。 (应该是 42.xx 而不是 1.xx)

[  OK  ] DietPi-Config | Desired setting in /etc/hostapd/hostapd.conf was already set: wpa_passphrase=SECRET_PHRASE
[  OK  ] DietPi-WiFiDB | mkdir -p /etc/wpa_supplicant
[  OK  ] DietPi-WiFiDB | eval > /var/lib/dietpi/dietpi-wifi.db
[ INFO ] DietPi-WiFiDB | Applied WiFi DB slot 0 with SSID "CLEARNET"
[ INFO ] DietPi-WiFiDB | Applied WiFi DB slot 1 with SSID ""
[ INFO ] DietPi-WiFiDB | Applied WiFi DB slot 2 with SSID ""
[ INFO ] DietPi-WiFiDB | Applied WiFi DB slot 3 with SSID ""
[ INFO ] DietPi-WiFiDB | Applied WiFi DB slot 4 with SSID ""
[  OK  ] DietPi-WiFiDB | chown root:root /var/lib/dietpi/dietpi-wifi.db /etc/wpa_supplicant/wpa_supplicant.conf
[  OK  ] DietPi-WiFiDB | chmod 600 /var/lib/dietpi/dietpi-wifi.db /etc/wpa_supplicant/wpa_supplicant.conf
[  OK  ] DietPi-Config | systemctl stop isc-dhcp-server
[ SUB1 ] DietPi-Set_hardware > wifimodules (enable)
[ INFO ] DietPi-Set_hardware | Please wait, enabling WiFi modules...
[ INFO ] DietPi-Set_hardware | Checking for required APT packages: iw wireless-tools wpasupplicant wireless-regdb
[  OK  ] wifimodules enable | Completed
[ INFO ] DietPi-Config | Dropping network connections, please wait...
[ INFO ] DietPi-Config | Restarting network connections, please wait...
[  OK  ] DietPi-Config | systemctl daemon-reload
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/b8:27:eb:23:f0:44
Sending on   LPF/eth0/b8:27:eb:23:f0:44
Sending on   Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 4
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
DHCPOFFER of 192.168.1.169 from 192.168.1.1
DHCPREQUEST for 192.168.1.169 on eth0 to 255.255.255.255 port 67
DHCPACK of 192.168.1.169 from 192.168.1.1
bound to 192.168.1.169 -- renewal in 18890 seconds.
[  OK  ] DietPi-Config | systemctl start isc-dhcp-server
[ INFO ] DietPi-Config | Reloading networking data, please wait...
[  OK  ] DietPi-Config | Network restarted
$ cat /etc/network/interfaces
# Location: /etc/network/interfaces
# Please modify network settings via: dietpi-config
# Or create your own drop-ins in: /etc/network/interfaces.d/

# Drop-in configs
source interfaces.d/*

# Ethernet
allow-hotplug eth0
iface eth0 inet dhcp
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
#dns-nameservers 192.168.1.1

# WiFi
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.0.1
netmask 255.255.255.0
#gateway 192.168.0.1
#dns-nameservers 9.9.9.9 149.112.112.112
pre-up iw dev wlan0 set power_save off
post-down iw dev "wlan0 set power_save on

# iptables NAT rules
up iptables-restore < /etc/iptables.ipv4.nat
up ip6tables-restore < /etc/iptables.ipv6.nat
$ cat /etc/network/interfaces.d/wlan0
iface wlan0 inet static
  address 192.168.42.99
  network 192.168.42.0
  netmask 255.255.255.0
  broadcast 192.168.42.255
  wpa-ssid "magic-mirror"
  wpa-psk "SECRET_PHRASE"
  wpa-group TKIP CCMP
  wpa-key-mgmt WPA-PSK
$cat /etc/dhcp/dhcpd.conf
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;

subnet 192.168.42.0 netmask 255.255.255.0 {
        range 192.168.42.10 192.168.42.50;
        option broadcast-address 192.168.42.255;
        option routers 192.168.42.1;
        option domain-name "local";
        option domain-name-servers 9.9.9.9, 149.112.112.112;
}

预先感谢您的任何建议

相关内容