为第二个 hostapd 接入点创建虚拟 wifi 网络接口

为第二个 hostapd 接入点创建虚拟 wifi 网络接口

我正在尝试设置hostapd两个 SSID。一件我能做的事;事实证明,第二次是不可能的。

我最新的假设是,首先必须创建其中出现的另一个内容ip a,然后将其添加到intefaes文件中,然后在 中使用它hostapd.conf。这是我想出的命令以及我现在遇到的问题:

# iw dev wlx00e032800384 interface add ap2 type managed addr 02:e0:32:80:03:81
command failed: No such device (-19)

该适配器是 eBay 便宜的,并且正在使用rtl8821CU驱动程序。

更新:配置hostapd

看起来它hostapd试图为自己做同样的事情,但由于同样的原因失败了。

hostapd.conf

interface=wlx00e032800384
bridge=br0
#driver=rtl8821cu
country_code=UK
ieee80211d=1
ieee80211n=1
hw_mode=g
channel=9

wmm_enabled=1

# NORMAL ACCESS POINT

ssid=mini31
wpa=2
wpa_passphrase=password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
auth_algs=1
macaddr_acl=0
wmm_enabled=1

# OPEN ACCESS POINT
bss=ap_open

ssid=mini31_open
wpa=0 # open
macaddr_acl=1 # 1 = deny unless in accept list
accept_mac_file=/etc/hostapd/hostapd.accept

使用调试消息运行hostapd会显示正在发生的情况:

# hostapd -dd /etc/hostapd/hostapd.conf
random: getrandom() support available
Configuration file: /etc/hostapd/hostapd.conf
nl80211: Supported cipher 00-0f-ac:1
nl80211: Supported cipher 00-0f-ac:5
nl80211: Supported cipher 00-0f-ac:2
nl80211: Supported cipher 00-0f-ac:4
nl80211: Supported vendor command: vendor_id=0x1a11 subcmd=4106
nl80211: Supported vendor command: vendor_id=0x1a11 subcmd=4107
nl80211: interface wlx00e032800384 in phy phy1
nl80211: Set mode ifindex 4 iftype 3 (AP)
nl80211: Setup AP(wlx00e032800384) - device_ap_sme=1 use_monitor=0
nl80211: Subscribe to mgmt frames with AP handle 0x560d50976330 (device SME)
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x560d50976330 match=04
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x560d50976330 match=0501
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x560d50976330 match=0503
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x560d50976330 match=0504
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x560d50976330 match=06
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x560d50976330 match=08
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x560d50976330 match=09
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x560d50976330 match=0a
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x560d50976330 match=11
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x560d50976330 match=12
nl80211: Register frame type=0xd0 (WLAN_FC_STYPE_ACTION) nl_handle=0x560d50976330 match=7f
nl80211: Enable Probe Request reporting nl_preq=0x560d50975b20
nl80211: Register frame type=0x40 (WLAN_FC_STYPE_PROBE_REQ) nl_handle=0x560d50975b20 match=
rfkill: initial event: idx=2 type=1 op=0 soft=0 hard=0
nl80211: Add own interface ifindex 12 (ifidx_reason 4)
nl80211: if_indices[16]: 12(4)
nl80211: Add own interface ifindex 4 (ifidx_reason -1)
nl80211: if_indices[16]: 12(4) 4(-1)
nl80211: Adding interface wlx00e032800384 into bridge br0
phy: phy1
BSS count 2, BSSID mask ff:ff:ff:ff:ff:fe (1 bits)
wlx00e032800384: interface state UNINITIALIZED->COUNTRY_UPDATE
Previous country code 00, new country code UK
Continue interface setup after channel list update
ctrl_iface not configured!
RTM_NEWLINK: ifi_index=4 ifname=wlx00e032800384 operstate=6 linkmode=0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
RTM_NEWLINK: ifi_index=4 ifname=wlx00e032800384 operstate=6 linkmode=0 master=12 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
RTM_NEWLINK: ifi_index=4 ifname=wlx00e032800384 operstate=6 linkmode=0 master=12 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
RTM_NEWLINK: ifi_index=4 ifname=wlx00e032800384 master=12 operstate=6 ifi_family=7 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
nl80211: Add ifindex 12 for bridge br0
nl80211: Add own interface ifindex 12 (ifidx_reason 4)
nl80211: ifindex 12 already in the list
RTM_NEWLINK: ifi_index=4 ifname=wlx00e032800384 master=12 operstate=6 ifi_family=7 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
nl80211: Add ifindex 12 for bridge br0
nl80211: Add own interface ifindex 12 (ifidx_reason 4)
nl80211: ifindex 12 already in the list
RTM_NEWLINK: ifi_index=4 ifname=wlx00e032800384 master=12 operstate=6 ifi_family=7 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
nl80211: Add ifindex 12 for bridge br0
nl80211: Add own interface ifindex 12 (ifidx_reason 4)
nl80211: ifindex 12 already in the list
RTM_NEWLINK: ifi_index=12 ifname=br0 operstate=6 linkmode=0 ifi_family=0 ifi_flags=0x11043 ([UP][RUNNING][LOWER_UP])
wlx00e032800384: Event INTERFACE_STATUS (5) received
Unknown event 5
nl80211: Event message available
nl80211: Drv Event 36 (NL80211_CMD_REG_CHANGE) received for wlx00e032800384
nl80211: Regulatory domain change
 * initiator=0
 * type=1
wlx00e032800384: Event CHANNEL_LIST_CHANGED (27) received
Channel list update timeout - try to continue anyway
nl80211: Regulatory information - country=00
nl80211: 2402-2472 @ 40 MHz 20 mBm
nl80211: 2457-2482 @ 20 MHz 20 mBm (no IR)
nl80211: 2474-2494 @ 20 MHz 20 mBm (no OFDM) (no IR)
nl80211: 5170-5250 @ 80 MHz 20 mBm (no IR)
nl80211: 5250-5330 @ 80 MHz 20 mBm (DFS) (no IR)
nl80211: 5490-5730 @ 160 MHz 20 mBm (DFS) (no IR)
nl80211: 5735-5835 @ 80 MHz 20 mBm (no IR)
nl80211: 57240-63720 @ 2160 MHz 0 mBm
nl80211: Added 802.11b mode based on 802.11g information
nl80211: Mode IEEE 802.11g: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467[NO_IR] 2472[NO_IR] 2484[DISABLED]
nl80211: Mode IEEE 802.11a: 5180 5200 5220 5240 5260[NO_IR][RADAR] 5280[NO_IR][RADAR] 5300[NO_IR][RADAR] 5320[NO_IR][RADAR] 5500[NO_IR][RADAR] 5520[NO_IR][RADAR] 5540[NO_IR][RADAR] 5560[NO_IR][RADAR] 5580[NO_IR][RADAR]
nl80211: Mode IEEE 802.11b: 2412 2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467[NO_IR] 2472[NO_IR] 2484[DISABLED]
Allowed channel: mode=1 chan=1 freq=2412 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=2 freq=2417 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=3 freq=2422 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=4 freq=2427 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=5 freq=2432 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=6 freq=2437 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=7 freq=2442 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=8 freq=2447 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=9 freq=2452 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=10 freq=2457 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=11 freq=2462 MHz max_tx_power=20 dBm
Allowed channel: mode=2 chan=36 freq=5180 MHz max_tx_power=20 dBm
Allowed channel: mode=2 chan=40 freq=5200 MHz max_tx_power=20 dBm
Allowed channel: mode=2 chan=44 freq=5220 MHz max_tx_power=20 dBm
Allowed channel: mode=2 chan=48 freq=5240 MHz max_tx_power=20 dBm
Allowed channel: mode=2 chan=149 freq=5745 MHz max_tx_power=20 dBm
Allowed channel: mode=2 chan=153 freq=5765 MHz max_tx_power=20 dBm
Allowed channel: mode=2 chan=157 freq=5785 MHz max_tx_power=20 dBm
Allowed channel: mode=2 chan=161 freq=5805 MHz max_tx_power=20 dBm
Allowed channel: mode=2 chan=165 freq=5825 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=1 freq=2412 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=2 freq=2417 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=3 freq=2422 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=4 freq=2427 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=5 freq=2432 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=6 freq=2437 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=7 freq=2442 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=8 freq=2447 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=9 freq=2452 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=10 freq=2457 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=11 freq=2462 MHz max_tx_power=20 dBm
Completing interface initialization
Mode: IEEE 802.11g  Channel: 9  Frequency: 2452 MHz
DFS 0 channels required radar detection
nl80211: Set freq 2452 (ht_enabled=1, vht_enabled=0, bandwidth=20 MHz, cf1=2452 MHz, cf2=0 MHz)
  * freq=2452
  * vht_enabled=0
  * ht_enabled=1
  * sec_channel_offset=0
  * channel_type=1
RATE[0] rate=10 flags=0x1
RATE[1] rate=20 flags=0x1
RATE[2] rate=55 flags=0x1
RATE[3] rate=110 flags=0x1
RATE[4] rate=60 flags=0x0
RATE[5] rate=90 flags=0x0
RATE[6] rate=120 flags=0x0
RATE[7] rate=180 flags=0x0
RATE[8] rate=240 flags=0x0
RATE[9] rate=360 flags=0x0
RATE[10] rate=480 flags=0x0
RATE[11] rate=540 flags=0x0
hostapd_setup_bss(hapd=0x560d50972e80 (wlx00e032800384), first=1)
wlx00e032800384: Flushing old station entries
nl80211: flush -> DEL_STATION wlx00e032800384 (all)
wlx00e032800384: Deauthenticate all stations
nl80211: sta_remove -> DEL_STATION wlx00e032800384 ff:ff:ff:ff:ff:ff --> -22 (Invalid argument)
nl80211: bridge FDB entry delete for ff:ff:ff:ff:ff:ff ifindex=4 failed: Object not found
wpa_driver_nl80211_set_key: ifindex=4 (wlx00e032800384) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=4 (wlx00e032800384) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=4 (wlx00e032800384) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=4 (wlx00e032800384) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0
Using interface wlx00e032800384 with hwaddr 02:e0:32:80:03:80 and ssid "mini31"
Deriving WPA PSK based on passphrase
SSID - hexdump_ascii(len=6):
     6d 69 6e 69 33 31                                 mini31
PSK (ASCII passphrase) - hexdump_ascii(len=10): [REMOVED]
PSK (from passphrase) - hexdump(len=32): [REMOVED]
random: Got 20/20 random bytes
Get randomness: len=32 entropy=0
GMK - hexdump(len=32): [REMOVED]
Get randomness: len=32 entropy=0
Key Counter - hexdump(len=32): [REMOVED]
WPA: Delay group state machine start until Beacon frames have been configured
nl80211: Set beacon (beacon_set=0)
nl80211: Beacon head - hexdump(len=57): 80 00 00 00 ff ff ff ff ff ff 02 e0 32 80 03 80 02 e0 32 80 03 80 00 00 00 00 00 00 00 00 00 00 64 00 11 04 00 06 6d 69 6e 69 33 31 01 08 82 84 8b 96 0c 12 18 24 03 01 09
nl80211: Beacon tail - hexdump(len=123): 07 06 55 4b 20 01 0b 14 2a 01 04 32 04 30 48 60 6c 30 14 01 00 00 0f ac 04 01 00 00 0f ac 04 01 00 00 0f ac 02 0c 00 2d 1a 0c 00 1f ff 00 00 00 00 00 00 00 00 00 96 00 01 00 00 00 00 00 00 00 00 00 00 3d 16 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7f 04 00 00 00 02 dd 18 00 50 f2 02 01 01 00 00 03 a4 00 00 27 a4 00 00 42 43 5e 00 62 32 2f 00
nl80211: ifindex=4
nl80211: beacon_int=100
nl80211: beacon_rate=0
nl80211: rate_type=0
nl80211: dtim_period=2
nl80211: ssid - hexdump_ascii(len=6):
     6d 69 6e 69 33 31                                 mini31
  * beacon_int=100
  * dtim_period=2
nl80211: hidden SSID not in use
nl80211: privacy=1
nl80211: auth_algs=0x1
nl80211: wpa_version=0x2
nl80211: key_mgmt_suites=0x2
nl80211: pairwise_ciphers=0x10
nl80211: group_cipher=0x10
nl80211: SMPS mode - off
nl80211: beacon_ies - hexdump(len=6): 7f 04 00 00 00 02
nl80211: proberesp_ies - hexdump(len=6): 7f 04 00 00 00 02
nl80211: assocresp_ies - hexdump(len=6): 7f 04 00 00 00 02
WPA: Start group state machine to set initial keys
WPA: group state machine entering state GTK_INIT (VLAN-ID 0)
Get randomness: len=16 entropy=0
GTK - hexdump(len=16): [REMOVED]
WPA: group state machine entering state SETKEYSDONE (VLAN-ID 0)
wpa_driver_nl80211_set_key: ifindex=4 (wlx00e032800384) alg=3 addr=0x560d500ee0f0 key_idx=1 set_tx=1 seq_len=0 key_len=16
nl80211: KEY_DATA - hexdump(len=16): [REMOVED]
   broadcast key
nl80211: Set wlx00e032800384 operstate 0->1 (UP)
netlink: Operstate: ifindex=4 linkmode=-1 (no change), operstate=6 (IF_OPER_UP)
hostapd_setup_bss(hapd=0x560d50974a20 (ap_open), first=0)
nl80211: Create interface iftype 3 (AP)
Failed to create interface ap_open: -19 (No such device)
Failed to add BSS (BSSID=02:e0:32:80:03:81)
ap_open: Flushing old station entries
nl80211: flush -> DEL_STATION wlx00e032800384 (all)
ap_open: Deauthenticate all stations
nl80211: sta_remove -> DEL_STATION wlx00e032800384 ff:ff:ff:ff:ff:ff --> -22 (Invalid argument)
nl80211: bridge FDB entry delete for ff:ff:ff:ff:ff:ff ifindex=4 failed: Object not found
wpa_driver_nl80211_set_key: ifindex=0 (ap_open) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0
nl80211: set_key failed; err=-19 No such device)
Failed to clear default encryption keys (ifname=ap_open keyidx=0)
wpa_driver_nl80211_set_key: ifindex=0 (ap_open) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0
nl80211: set_key failed; err=-19 No such device)
Failed to clear default encryption keys (ifname=ap_open keyidx=1)
wpa_driver_nl80211_set_key: ifindex=0 (ap_open) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0
nl80211: set_key failed; err=-19 No such device)
Failed to clear default encryption keys (ifname=ap_open keyidx=2)
wpa_driver_nl80211_set_key: ifindex=0 (ap_open) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0
nl80211: set_key failed; err=-19 No such device)
Failed to clear default encryption keys (ifname=ap_open keyidx=3)
hostapd_free_hapd_data(ap_open)
wlx00e032800384: Flushing old station entries
nl80211: flush -> DEL_STATION wlx00e032800384 (all)
wlx00e032800384: Deauthenticate all stations
nl80211: sta_remove -> DEL_STATION wlx00e032800384 ff:ff:ff:ff:ff:ff --> -22 (Invalid argument)
nl80211: bridge FDB entry delete for ff:ff:ff:ff:ff:ff ifindex=4 failed: Object not found
wpa_driver_nl80211_set_key: ifindex=4 (wlx00e032800384) alg=0 addr=(nil) key_idx=0 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=4 (wlx00e032800384) alg=0 addr=(nil) key_idx=1 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=4 (wlx00e032800384) alg=0 addr=(nil) key_idx=2 set_tx=0 seq_len=0 key_len=0
wpa_driver_nl80211_set_key: ifindex=4 (wlx00e032800384) alg=0 addr=(nil) key_idx=3 set_tx=0 seq_len=0 key_len=0
hostapd_free_hapd_data(wlx00e032800384)
Interface initialization failed
wlx00e032800384: interface state COUNTRY_UPDATE->DISABLED
wlx00e032800384: AP-DISABLED
hostapd_interface_deinit_free(0x560d50971980)
hostapd_interface_deinit_free: num_bss=2 conf->num_bss=2
hostapd_interface_deinit(0x560d50971980)
wlx00e032800384: interface state DISABLED->DISABLED
hostapd_bss_deinit: deinit bss ap_open
ap_open: Deauthenticate all stations
nl80211: sta_remove -> DEL_STATION wlx00e032800384 ff:ff:ff:ff:ff:ff --> -22 (Invalid argument)
nl80211: bridge FDB entry delete for ff:ff:ff:ff:ff:ff ifindex=4 failed: Object not found
ap_open: AP-DISABLED
hostapd_cleanup(hapd=0x560d50974a20 (ap_open))
ap_open: CTRL-EVENT-TERMINATING
hostapd_free_hapd_data: Interface ap_open wasn't started
hostapd_bss_deinit: deinit bss wlx00e032800384
wlx00e032800384: Deauthenticate all stations
nl80211: sta_remove -> DEL_STATION wlx00e032800384 ff:ff:ff:ff:ff:ff --> -22 (Invalid argument)
nl80211: bridge FDB entry delete for ff:ff:ff:ff:ff:ff ifindex=4 failed: Object not found
wlx00e032800384: AP-DISABLED
hostapd_cleanup(hapd=0x560d50972e80 (wlx00e032800384))
wlx00e032800384: CTRL-EVENT-TERMINATING
hostapd_free_hapd_data: Interface wlx00e032800384 wasn't started
hostapd_interface_deinit_free: driver=0x560d50172840 drv_priv=0x560d50976750 -> hapd_deinit
nl80211: deinit ifname=wlx00e032800384 disabled_11b_rates=0
nl80211: Disable Probe Request reporting nl_preq=0x8888de85d81fd3a9
nl80211: Remove monitor interface: refcount=0
nl80211: Remove beacon (ifindex=4)
netlink: Operstate: ifindex=4 linkmode=0 (kernel-control), operstate=6 (IF_OPER_UP)
nl80211: Set mode ifindex 4 iftype 2 (STATION)
nl80211: Teardown AP(wlx00e032800384) - device_ap_sme=1 use_monitor=0
nl80211: Unsubscribe mgmt frames handle 0x8888de85d81febb9 (AP teardown (dev SME))
hostapd_interface_free(0x560d50971980)
hostapd_interface_free: free hapd 0x560d50972e80
hostapd_interface_free: free hapd 0x560d50974a20
hostapd_cleanup_iface(0x560d50971980)
hostapd_cleanup_iface_partial(0x560d50971980)
hostapd_cleanup_iface: free iface=0x560d50971980

请参阅

... 
hostapd_setup_bss(hapd=0x560d50974a20 (ap_open), first=0)
nl80211: Create interface iftype 3 (AP) 
Failed to create interface ap_open: -19 (No such device)
... 

答案1

如果 Wi-Fi 卡支持,则必须将第二个虚拟接口添加到物理接口。您使用的 iw 命令正在尝试将第二个托管接口添加到虚拟接口。最后,您需要第二个连接到 phy 的 AP 接口。您的卡可能还保留了 MAC,因此请尝试不分配 MAC。

iw phy0 interface add ap0 type __ap

请注意,“__ap”中有两个下划线,ap0 只是虚拟接口的任意名称。

相关内容