我的任务:使用 Linux mint 在平板电脑 (x86) 上配置和运行接入点 (AP),并从连接到创建的 AP 的设备进行访问。
所有脚本均针对物理 WiFi 接口提供
wlp1s0
我创建了名为
wlp1s0_ap
的虚拟接口
/lib/systemd/system/[email protected]
[Unit]
Description=Create virtual wireless interface
Requires=sys-subsystem-net-devices-wlp1s0.device
#After=network.target
After=sys-subsystem-net-devices-wlp1s0.device
[Service]
Type=oneshot
#ExecStart=/usr/sbin/iw dev wlp1s0 interface add %I type __ap addr "00:0c:e3:6f:78:ee"
ExecStart=/usr/sbin/iw dev wlp1s0 interface add %I type managed addr "00:0c:e3:6f:78:ee"
#ExecStart=/usr/bin/iw dev wlan0 interface add wlp1s0_ap type __ap addr "00:0c:e3:6f:78:ee"
[Install]
WantedBy=multi-user.target
然后运行
systemctl enable wireless-device@wlp1s0_ap.service
重新启动电脑
编辑:
sudo nano /etc/NetworkManager/NetworkManager.conf
通过将 wlp1s0_ap 创建的接口添加到 unmanaged-devices 部分(注意! 附加到现有接口)
[keyfile]
unmanaged-devices=interface-name:wlp1s0_ap
奔跑
sudo nmcli general reload
hostapd
我将 AP 称为
EVT
,密码为 ******
。更多详情如下。
hostapd
sudo apt install hostapd
sudo nano /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
sudo nano /etc/hostapd/hostapd.conf
interface=wlp1s0_ap
driver=nl80211
country_code=EE
ssid=EVT
wpa_passphrase=****
hw_mode=g
channel=10
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
auth_algs=1
macaddr_acl=0
ieee80211n=1
sudo systemctl start hostapd
选择来自 DHCP 服务器
isc-dhcp-server
。
sudo apt install isc-dhcp-server
sudo nano /etc/dhcp/dhcpd.conf
,(以下是当前版本):# dhcpd.conf
#INTERFACES="wlp1s0_ap"
option domain-name "etv.org";
option domain-name-servers 192.168.1.2, 192.168.1.3;
default-lease-time 86400;
max-lease-time 604800;
ddns-update-style none;
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
interface wlp1s0_ap;
## dhcp start and end IP range ##
range 192.168.1.100 192.168.1.200;
option subnet-mask 255.255.255.0; ## subnet
option broadcast-address 192.168.1.255; ## broadcast
option routers 192.168.1.254; ## router IP
}
守护进程启动为
service isc-dhcp-server start
我修改了文件以将IP
192.168.1.111
分配给接口wlp1s0_ap
:
sudo nano /etc/network/interfaces
/etc/network/interfaces
文件的内容是
auto lo
iface lo inet loopback
auto wlp1s0_ap
iface wlp1s0_ap inet static
address 192.168.1.111
netmask 255.255.255.0
gateway 192.168.1.0
broadcast 192.168.1.255
dns-nameservers 192.168.1.2,192.168.1.3
ifconfig
上市: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 1386 bytes 149889 (149.8 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1386 bytes 149889 (149.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp1s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.20.92.22 netmask 255.255.255.0 broadcast 172.20.92.255
inet6 fe80::9ea9:58d3:aa31:b7e9 prefixlen 64 scopeid 0x20<link>
ether 00:0c:e3:6f:78:ed txqueuelen 1000 (Ethernet)
RX packets 1111808 bytes 125498550 (125.4 MB)
RX errors 0 dropped 7507 overruns 0 frame 0
TX packets 23673 bytes 3070974 (3.0 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp1s0_ap: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.111 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::20c:e3ff:fe6f:78ee prefixlen 64 scopeid 0x20<link>
ether 00:0c:e3:6f:78:ee txqueuelen 1000 (Ethernet)
RX packets 808 bytes 124999 (124.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 893 bytes 155057 (155.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
但是我无法与此平板电脑通信
例如,
ping
到分配的IP ping 192.168.1.111
给出下一个响应:
PING 192.168.1.111 (192.168.1.111) 56(84) bytes of data.
From 192.168.1.101 icmp_seq=1 Destination Host Unreachable
From 192.168.1.101 icmp_seq=2 Destination Host Unreachable
From 192.168.1.101 icmp_seq=3 Destination Host Unreachable
From 192.168.1.101 icmp_seq=4 Destination Host Unreachable
^C
--- 192.168.1.111 ping statistics ---
5 packets transmitted, 0 received, +4 errors, 100% packet loss, time 4065ms
telnet输出:
~$ telnet 192.168.1.111
Trying 192.168.1.111...
telnet: Unable to connect to remote host: No route to host
问题:
hostapd + DHCP
的平板电脑的访问?您的静态 IP (.111) 在“DHCP 范围”(.100-.200) 内,因此我假设您可能存在 IP 冲突。
尝试使用 .93 IP 作为静态 IP,并确保没有其他带有 .93 的静态条目