让 WiFi AP 与 hostapd 和 isc-dhcp-server 一起工作 [Xubuntu 14.04]

Cyn*_*dre 5 xubuntu wireless networking dhcpd hostapd

我曾尝试使用来自 WebUpd8 的 ap-hotspot,但它在 13.10 或 14.04 中对我不起作用,所以我一直在努力手动设置 hostapd,isc-dhcp-server因为 dnsmasq 对我有冲突。我已经能够连接到 AP,并得到一个IP,但路由似乎不想工作。这是我的构建日志和我一直遵循的指南:

配置文件:

/etc/network/interfaces

auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet static
hostapd -dd /etc/hostapd/hostapd.conf
address 10.10.0.1
netmask 255.255.255.0
Run Code Online (Sandbox Code Playgroud)

/etc/default/hostapd

RUN_DAEMON="yes"
DAEMON_CONF="/etc/hostapd/hostapd.conf"
DAEMON_OPTS="-dd"
Run Code Online (Sandbox Code Playgroud)

/etc/hostapd/hostapd.conf

# WiFi Hotspot
interface=wlan0
driver=nl80211
#Access Point
ssid=workshop
hw_mode=g
# WiFi Channel:
channel=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=mypass
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
Run Code Online (Sandbox Code Playgroud)

/etc/dhcp/dhcpd.conf

ddns-update-style none;
#default-lease-time 600;
#max-lease-time 7200;
log-facility local7;
subnet 10.10.0.0 netmask 255.255.255.0 {
    range 10.10.0.2 10.10.0.32;
    option domain-name-servers 208.67.222.222, 208.67.220.220;
    option routers 10.10.0.1;
}
Run Code Online (Sandbox Code Playgroud)

/etc/rc.local

iptables -t nat -A POSTROUTING -s 10.10.0.0/32 -o eth1 -j MASQUERADE
exit 0
Run Code Online (Sandbox Code Playgroud)

运行了以下命令:

sudo ifconfig wlan0 10.10.0.1
sudo sysctl net.ipv4.ip_forward=1
sudo ip link set dev wlan0 up
sudo service hostapd start
Run Code Online (Sandbox Code Playgroud)

我已经安装bridge-utils,但我还没有添加br0,因为我不确定如何更改配置的其他部分以反映它...

编辑:通过另一个(较旧的)指南仔细检查我的配置后,再次尝试并决定在连接时添加日志中显示的内容。连接的设备是我的安卓手机,通过普通路由器连接正常。

(我了解日志中发生的大部分事情,并且启动看起来很好。然后滚动随机性......)

Add randomness: count=52 entropy=51
mgmt::auth
authentication: STA=a0:f4:50:18:a2:c3 auth_alg=0 auth_transaction=1 status_code=0 wep=0
  New STA
wlan0: STA a0:f4:50:18:a2:c3 IEEE 802.11: authentication OK (open system)
wlan0: STA a0:f4:50:18:a2:c3 MLME: MLME-AUTHENTICATE.indication(a0:f4:50:18:a2:c3, OPEN_SYSTEM)
wlan0: STA a0:f4:50:18:a2:c3 MLME: MLME-DELETEKEYS.request(a0:f4:50:18:a2:c3)
authentication reply: STA=a0:f4:50:18:a2:c3 auth_alg=0 auth_transaction=2 resp=0 (IE len=0)
Add randomness: count=53 entropy=52
mgmt::auth cb
wlan0: STA a0:f4:50:18:a2:c3 IEEE 802.11: authenticated
mgmt::assoc_req
association request: STA=a0:f4:50:18:a2:c3 capab_info=0x431 listen_interval=20
  new AID 1
wlan0: STA a0:f4:50:18:a2:c3 IEEE 802.11: association OK (aid 1)
Add randomness: count=54 entropy=53
mgmt::assoc_resp cb
wlan0: STA a0:f4:50:18:a2:c3 IEEE 802.11: associated (aid 1)
wlan0: STA a0:f4:50:18:a2:c3 MLME: MLME-ASSOCIATE.indication(a0:f4:50:18:a2:c3)
wlan0: STA a0:f4:50:18:a2:c3 MLME: MLME-DELETEKEYS.request(a0:f4:50:18:a2:c3)
wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=0x9f8ac90 key_idx=0 set_tx=1 seq_len=0 key_len=0
   addr=a0:f4:50:18:a2:c3
wlan0: STA a0:f4:50:18:a2:c3 WPA: event 1 notification
wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=0x9f8ac90 key_idx=0 set_tx=1 seq_len=0 key_len=0
   addr=a0:f4:50:18:a2:c3
IEEE 802.1X: Ignore STA - 802.1X not enabled or forced for WPS
wlan0: STA a0:f4:50:18:a2:c3 WPA: start authentication
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state INITIALIZE
wpa_driver_nl80211_set_key: ifindex=3 alg=0 addr=0x9f8ac90 key_idx=0 set_tx=1 seq_len=0 key_len=0
   addr=a0:f4:50:18:a2:c3
wlan0: STA a0:f4:50:18:a2:c3 IEEE 802.1X: unauthorizing port
WPA: a0:f4:50:18:a2:c3 WPA_PTK_GROUP entering state IDLE
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state AUTHENTICATION
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state AUTHENTICATION2
WPA: Re-initialize GMK/Counter on first station
Get randomness: len=32 entropy=54
GMK - hexdump(len=32): [REMOVED]
Get randomness: len=32 entropy=22
Key Counter - hexdump(len=32): [REMOVED]
Get randomness: len=16 entropy=0
GTK - hexdump(len=16): [REMOVED]
wpa_driver_nl80211_set_key: ifindex=3 alg=3 addr=0x80dd6be key_idx=1 set_tx=1 seq_len=0 key_len=16
   broadcast key
WPA: Assign ANonce - hexdump(len=32): 12 53 6f 26 8a a3 87 09 b4 31 e2 81 ef c3 ea 3e 6c 3d 0c a5 fb 85 07 f2 0a 2a 4a 5e a2 00 59 e9
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state INITPSK
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state PTKSTART
wlan0: STA a0:f4:50:18:a2:c3 WPA: sending 1/4 msg of 4-Way Handshake
WPA: Send EAPOL(version=2 secure=0 mic=0 ack=1 install=0 pairwise=8 kde_len=0 keyidx=0 encr=0)
WPA: Use EAPOL-Key timeout of 100 ms (retry counter 1)
nl80211: Event message available
nl80211: New station a0:f4:50:18:a2:c3
IEEE 802.1X: a0:f4:50:18:a2:c3 TX status - version=2 type=3 length=95 - ack=1
WPA: EAPOL-Key TX status for STA a0:f4:50:18:a2:c3 ack=1
WPA: Increase initial EAPOL-Key 1/4 timeout by 1000 ms because of acknowledged frame
IEEE 802.1X: 121 bytes from a0:f4:50:18:a2:c3
   IEEE 802.1X: version=1 type=3 length=117
WPA: Received EAPOL-Key from a0:f4:50:18:a2:c3 key_info=0x10a type=2 key_data_length=22
WPA: Received Key Nonce - hexdump(len=32): 7c 4d 99 9f 10 56 93 84 a9 8a f8 15 d8 8e 1e 6d 2f 39 95 8f bc 99 9a 4c 06 3d 37 65 e6 db 49 fa
WPA: Received Replay Counter - hexdump(len=8): 00 00 00 00 00 00 00 01
Add randomness: count=55 entropy=0
wlan0: STA a0:f4:50:18:a2:c3 WPA: received EAPOL-Key frame (2/4 Pairwise)
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state PTKCALCNEGOTIATING
WPA: PTK derivation - A1=90:4c:e5:55:94:4d A2=a0:f4:50:18:a2:c3
WPA: Nonce1 - hexdump(len=32): 12 53 6f 26 8a a3 87 09 b4 31 e2 81 ef c3 ea 3e 6c 3d 0c a5 fb 85 07 f2 0a 2a 4a 5e a2 00 59 e9
WPA: Nonce2 - hexdump(len=32): 7c 4d 99 9f 10 56 93 84 a9 8a f8 15 d8 8e 1e 6d 2f 39 95 8f bc 99 9a 4c 06 3d 37 65 e6 db 49 fa
WPA: PMK - hexdump(len=32): [REMOVED]
WPA: PTK - hexdump(len=48): [REMOVED]
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state PTKCALCNEGOTIATING2
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state PTKINITNEGOTIATING
wlan0: STA a0:f4:50:18:a2:c3 WPA: sending 3/4 msg of 4-Way Handshake
WPA: Send EAPOL(version=2 secure=1 mic=1 ack=1 install=1 pairwise=8 kde_len=46 keyidx=1 encr=1)
Plaintext EAPOL-Key Key Data - hexdump(len=56): [REMOVED]
WPA: Use EAPOL-Key timeout of 100 ms (retry counter 1)
IEEE 802.1X: a0:f4:50:18:a2:c3 TX status - version=2 type=3 length=151 - ack=1
WPA: EAPOL-Key TX status for STA a0:f4:50:18:a2:c3 ack=1
IEEE 802.1X: 99 bytes from a0:f4:50:18:a2:c3
   IEEE 802.1X: version=1 type=3 length=95
WPA: Received EAPOL-Key from a0:f4:50:18:a2:c3 key_info=0x30a type=2 key_data_length=0
WPA: Received Key Nonce - hexdump(len=32): 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
WPA: Received Replay Counter - hexdump(len=8): 00 00 00 00 00 00 00 02
wlan0: STA a0:f4:50:18:a2:c3 WPA: received EAPOL-Key frame (4/4 Pairwise)
WPA: a0:f4:50:18:a2:c3 WPA_PTK entering state PTKINITDONE
wpa_driver_nl80211_set_key: ifindex=3 alg=3 addr=0x9f8ac90 key_idx=0 set_tx=1 seq_len=0 key_len=16
   addr=a0:f4:50:18:a2:c3
wlan0: AP-STA-CONNECTED a0:f4:50:18:a2:c3
wlan0: STA a0:f4:50:18:a2:c3 IEEE 802.1X: authorizing port
wlan0: STA a0:f4:50:18:a2:c3 RADIUS: starting accounting session 536C1843-00000000
wlan0: STA a0:f4:50:18:a2:c3 WPA: pairwise key handshake completed (RSN)
Add randomness: count=56 entropy=1
Run Code Online (Sandbox Code Playgroud)

(更多随机性,直到我 ctrl+c)

小智 0

尝试以下操作

\n\n
sudo apt-get install hostapd dnsmasq dhcp3-server isc-dhcp-server haveged\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n\n

设置hostapd

\n\n

hostapd 用于无线路由器功能:

\n\n
leafpad /etc/hostapd.conf\n
Run Code Online (Sandbox Code Playgroud)\n\n

通用热点配置:

\n\n

定义接口

\n\n
interface=wlan#\nbridge=br0\n
Run Code Online (Sandbox Code Playgroud)\n\n

选择驱动程序:

\n\n
driver=nl80211\n
Run Code Online (Sandbox Code Playgroud)\n\n

将接入点硬件模式设置为 802.11a/b/g/n(硬件支持吗?):

\n\n
hw_mode=g\nlogger_stdout=-1\nlogger_stdout_level=2\nrequire_ht=0\nht_capab= [HT40+] [HT40-] [SHORT-GI-40] [RX-STBC1]\nieee80211d=1\nieee80211n=1\nmacaddr_acl=0\nwmm_enabled=1\n
Run Code Online (Sandbox Code Playgroud)\n\n

配置无线特性:

\n\n
beacon_int=50\ncountry_code=US\ndisassoc_low_ack=1\n
Run Code Online (Sandbox Code Playgroud)\n\n

设置Wi-Fi信道:

\n\n
channel=6\n
Run Code Online (Sandbox Code Playgroud)\n\n

设置接入点名称:

\n\n
ssid=nametobroacdcast\nignore_broadcast_ssid=0\n
Run Code Online (Sandbox Code Playgroud)\n\n

设置加密标准(1为WPA,2为WPA2,3为WPA + WPA2):

\n\n
auth_algs=1\nwpa=3\nwpa_passphrase=yourpassword\nwpa_key_mgmt=WPA-PSK\nwpa_pairwise=TKIP CCMP\nrsn_pairwise=CCMP\n
Run Code Online (Sandbox Code Playgroud)\n\n

wpa_key_mgmt=WPA-EAP WPA-PSK-SHA256 WPA-EAP-SHA256 的其他选项

\n\n
\n\n

创建并保存./######.sh脚本

\n\n
sudo apt-get install hostapd dnsmasq dhcp3-server isc-dhcp-server haveged\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n\n

开始设置 DNS/DHCP

\n\n

dnsmasq dhcp3-server isc-dhcp-server 用于 DNS/DHCP 功能(选择一项):

\n\n

例子:

\n\n
leafpad /etc/dhcp/dhcpd.conf\n
Run Code Online (Sandbox Code Playgroud)\n\n

常规 DHCP 配置:

\n\n
ddns-update-style none\xcd\xbe\nignore clients-updates;\nauthoritative;\noption local-wpad code 252 = test;\nlog-facility local7\xcd\xbe\ndefault-lease-time 3600;\nmax-lease-time 7200;\nsubnet\n192.168.3.0 netmask 255.255.255.0 {\n    # Broadcast address\n    option broadcast-address 192.168.3.2\xcd\xbe\n    # Netmask\n    option subnet-mask 255.255.255.0;\n    # Default gateway\n    option routers 192.168.3.1;\n\n    # Domain Name Servers for directing client traffic \n    option domain-name-servers 8.8.8.8, 8.8.4.4\xcd\xbe\n    option time-offset 0;\n\n    # Set IP address range available to clients\n    range 192.168.3.2, 192.168.3.100\xcd\xbe\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n
\n\n

允许./#####.sh创建的脚本运行

\n\n

使hostapdfilecreated.sh可执行:

\n\n
sudo chmod +x nameoffilecreated.sh\n
Run Code Online (Sandbox Code Playgroud)\n\n

您必须进入######.sh文件所在的目录,cd然后运行命令。

\n\n

执行脚本以启动基于计算机的接入点广播:

\n\n
sudo ./nameoffilecreated.sh\n
Run Code Online (Sandbox Code Playgroud)\n