# apt-get install iw # apt-get install wavemon
lspciを使ってデバイスの詳細を確認し、iw listでネットワークアダプタの機能詳細を確認。
# lspci | grep Atheros
00:0b.0 Network controller: Atheros Communications Inc. AR922X Wireless Network Adapter (rev 01)
# lspci -s 00:0b.0 -vv
00:0b.0 Network controller: Atheros Communications Inc. AR922X Wireless Network Adapter (rev 01)
        Subsystem: Atheros Communications Inc. Device 2093
        Control: I/O- Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr- Stepping- SERR- FastB2B- DisINTx-
        Status: Cap+ 66MHz+ UDF- FastB2B+ ParErr- DEVSEL=medium >TAbort- <TAbort- <MAbort- >SERR- <PERR- INTx-
        Latency: 168, Cache Line Size: 32 bytes
        Interrupt: pin A routed to IRQ 17
        Region 0: Memory at fd100000 (32-bit, non-prefetchable) [size=64K]
        Capabilities: [44] Power Management version 2
                Flags: PMEClk- DSI- D1- D2- AuxCurrent=100mA PME(D0+,D1-,D2-,D3hot+,D3cold-)
                Status: D0 NoSoftRst- PME-Enable- DSel=0 DScale=0 PME-
        Kernel driver in use: ath9k
# iw list
Wiphy phy0
        Band 1:
                Capabilities: 0x11ce
                        HT20/HT40
                        SM Power Save disabled
                        RX HT40 SGI
                        TX STBC
                        RX STBC 1-stream
                        Max AMSDU length: 3839 bytes
                        DSSS/CCK HT40
                Maximum RX AMPDU length 65535 bytes (exponent: 0x003)
                Minimum RX AMPDU time spacing: 8 usec (0x06)
                HT TX/RX MCS rate indexes supported: 0-15
                Frequencies:
                        * 2412 MHz [1] (17.0 dBm)
                        * 2417 MHz [2] (17.0 dBm)
                        * 2422 MHz [3] (17.0 dBm)
                        * 2427 MHz [4] (17.0 dBm)
                        * 2432 MHz [5] (17.0 dBm)
                        * 2437 MHz [6] (17.0 dBm)
                        * 2442 MHz [7] (17.0 dBm)
                        * 2447 MHz [8] (17.0 dBm)
                        * 2452 MHz [9] (17.0 dBm)
                        * 2457 MHz [10] (17.0 dBm)
                        * 2462 MHz [11] (17.0 dBm)
                        * 2467 MHz [12] (disabled)
                        * 2472 MHz [13] (disabled)
                        * 2484 MHz [14] (disabled)
                Bitrates (non-HT):
                        * 1.0 Mbps
                        * 2.0 Mbps (short preamble supported)
                        * 5.5 Mbps (short preamble supported)
                        * 11.0 Mbps (short preamble supported)
                        * 6.0 Mbps
                        * 9.0 Mbps
                        * 12.0 Mbps
                        * 18.0 Mbps
                        * 24.0 Mbps
                        * 36.0 Mbps
                        * 48.0 Mbps
                        * 54.0 Mbps
...
        Supported interface modes:
                 * IBSS
                 * managed
                 * AP
                 * AP/VLAN
                 * WDS
                 * monitor
                 * mesh point
                 * P2P-client
                 * P2P-GO
...
ネットワークインターフェイスにIPアドレスを割り当てる。
# cat << EOF >> /etc/network/interfaces
allow-hotplug wlan0
auto wlan0
iface wlan0 inet static
        address 192.168.100.1
        netmask 255.255.255.248
        network 192.168.100.0
        up route add -net 192.168.100.0 netmask 255.255.255.248 gw 192.168.100.1
        pre-down route del -net 192.168.100.0 netmask 255.255.255.248 gw 192.168.100.1
EOF
hostapdのインストールと、起動時に自動実行する設定の書き込み。設定ファイルの作成。
# apt-get install hostapd # cat << EOF >> /etc/default/hostapd DAEMON_CONF="/etc/hostapd/hostapd.conf" EOF # cat << EOF > /etc/hostapd/hostapd.conf interface=wlan0 driver=nl80211 ssid=SSID hw_mode=g channel=11 wpa=2 wpa_passphrase=PASSPHRASE wpa_key_mgmt=WPA-PSK rsn_pairwise=CCMP wmm_enabled=1 ieee80211n=1 EOF
クライアントのMACアドレスと鍵の対応表 /etc/hostapd-psk を作る。クライアントに入力してもらうパスフレーズがPASSPHRASEの場合の例
# apt-get install wpasupplicant
# wpa_passphrase SSID PASSPHRASE
network={
        ssid="SSID"
        #psk="PASSPHRASE"
        psk=38497220976092fc2707a838e4d4385019256149f99f935be22c90159d3b8373
}
# cat << EOF >> /etc/hostapd-psk
**:**:**:**:**:** 38497220976092fc2707a838e4d4385019256149f99f935be22c90159d3b8373
EOF
/etc/hostapd-psk を更新したら、デーモンを再起動させる。
# systemctl stop hostapd
# systemctl start hostapd
# systemctl --lines 100 --full status hostapd
● hostapd.service - LSB: Advanced IEEE 802.11 management daemon
   Loaded: loaded (/etc/init.d/hostapd)
   Active: active (running) since *** ****-**-** 11:33:38 ***; 13s ago
  Process: 10065 ExecStop=/etc/init.d/hostapd stop (code=exited, status=0/SUCCESS)
  Process: 10091 ExecStart=/etc/init.d/hostapd start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/hostapd.service
           └─10094 /usr/sbin/hostapd -B -P /run/hostapd.pid /etc/hostapd/hostapd.conf
*** ** 11:33:38 ************** hostapd[10091]: Starting advanced IEEE 802.11 management: hostapd.
*** ** 11:33:38 ************** systemd[1]: Started LSB: Advanced IEEE 802.11 management daemon.
dhcpdでipアドレスを割り当て、さらにMACアドレスで割り当てるIPアドレスを指定する例
# cat << EOF >> /etc/dhcp/dhcpd.conf
subnet 192.168.100.0 netmask 255.255.255.248 {
        option routers 192.168.100.1;
        range 192.168.100.2 192.168.100.5;
}
host foobar {
        hardware ethernet **:**:**:**:**:**
        fixed-address 192.168.100.2;
        option host-name "foobar";
}
EOF
# hostapd /etc/hostapd/hostapd.conf
最後にホストで動いているサービスにwlan0からつながるための設定
# /sbin/iptables -A INPUT -j ACCEPT -i wlan0
ブチブチ接続が切れるわけじゃないけど、RSSI値が大体-47から-45程度。リンクスピードが130Mbps。アンテナ同士が近づけばかなり改善するので、アンテナに延長ケーブルを付けたい。
実効的な速度は優先の10分の1程度になってしまった。有線(100Mbpsリンク)と無線(130Mbpsリンク)とでそれぞれsambaマウントしたディレクトリにddでファイル書き込みした場合の速度。有線はリンクスピードの8-9割出ているが、無線はリンクスピードの1割程度。結局有線のほうが早い結果になってる。
$ cd /mnt/wire $ dd if=/dev/zero of=./test count=10 bs=10M && rm ./test 10+0 records in 10+0 records out 104857600 bytes (105 MB) copied, 9.18348 s, 11.4 MB/s $ dd if=/dev/zero of=./test count=10 bs=100M && rm ./test 10+0 records in 10+0 records out 1048576000 bytes (1.0 GB) copied, 106.746 s, 9.8 MB/s $ cd /mnt/wireless $ dd if=/dev/zero of=./test count=10 bs=10M && rm ./test 10+0 records in 10+0 records out 104857600 bytes (105 MB) copied, 63.8521 s, 1.6 MB/s $ dd if=/dev/zero of=./test count=10 bs=100M && rm ./test 10+0 records in 10+0 records out 1048576000 bytes (1.0 GB) copied, 649.335 s, 1.6 MB/s
10 分間隔で "group key handshake completed" というメッセージが出る
ログを眺めていたら、以下のようなメッセージが10分間隔で出ている。これは正常。
# tail -f /var/log/daemon.log Jul 6 13:59:31 ****** hostapd: wlan0: STA **:**:**:**:**:** WPA: group key handshake completed (RSN) Jul 6 14:09:31 ****** hostapd: wlan0: STA **:**:**:**:**:** WPA: group key handshake completed (RSN) Jul 6 14:19:31 ****** hostapd: wlan0: STA **:**:**:**:**:** WPA: group key handshake completed (RSN) Jul 6 14:29:31 ****** hostapd: wlan0: STA **:**:**:**:**:** WPA: group key handshake completed (RSN)
以下を設定ファイルに追記すれば、間隔を5分にすることも可能。hostapdを再起動。
# echo "wpa_group_rekey=300" >> /etc/hostapd/hostapd.conf # /etc/init.d/hostapd restart Stopping advanced IEEE 802.11 management: hostapd. Starting advanced IEEE 802.11 management: hostapd. # tail -f /var/log/daemon.log Jul 6 14:59:34 ****** hostapd: wlan0: STA 00:1d:e0:31:7f:7f WPA: group key handshake completed (RSN) Jul 6 15:04:34 ****** hostapd: wlan0: STA 00:1d:e0:31:7f:7f WPA: group key handshake completed (RSN)
さらに、時々接続が切断される様子。接続状態をキープしたい。
# echo "wmm_enabled=0" >> /etc/hostapd/hostapd.conf # /etc/init.d/hostapd restart Stopping advanced IEEE 802.11 management: hostapd. Starting advanced IEEE 802.11 management: hostapd.