I/O Data WN-G150UM ドライバ
無線LANドングル I/O Data WN-G150UM を使用します。Raspbian Jessie でも刺すだけで認識されます。
$ dmesgドライバは 8192cu
:
usb 1-1.5: new high-speed USB device number 4 using dwc_otg
usb 1-1.5: New USB device found, idVendor=04bb, idProduct=094c
usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.5: Product: WN-G150UM
usb 1-1.5: Manufacturer: I-O DATA DEVICE, INC.
usb 1-1.5: SerialNumber: ************
usbcore: registered new interface driver rtl8192cu
AP化コマンドインストールと初期設定
Raspbian Jessie上でWN-G150UMをWifi AP化します。必要なコマンドをインストールします。$ sudo apt-get install hostapd
ドライバが8192cu の場合、apt-getでインストールしたhostapdが対応していないので、パッチ当てをしたバイナリを自力でビルドします。前バージョンRaspbian Wheezy では有志のバイナリを利用できましたが、Jessieではうまく動きません。
必要パッケージインストールします。
$ sudo apt-get install libssl-dev
$ sudo apt-get install libnl1 libnl-dev
hostapdのソースをダウンロードします。
http://w1.fi/hostapd/
$ cd
$ wget http://w1.fi/releases/hostapd-2.5.tar.gz
$ tar zxfv hostapd-2.5.tar.gz
パッチをダウンロードします。
https://github.com/pritambaral/hostapd-rtl871xdrv
https://github.com/pritambaral/hostapd-rtl871xdrv/raw/master/driver_rtw.c
https://github.com/pritambaral/hostapd-rtl871xdrv/raw/master/rtlxdrv.patch
$ wget https://github.com/pritambaral/hostapd-rtl871xdrv/raw/master/driver_rtw.c
$ wget https://github.com/pritambaral/hostapd-rtl871xdrv/raw/master/rtlxdrv.patch
パッチ当て
$ cp hostapd-2.5/src/drivers/driver_rtw.c hostapd-2.5/src/drivers/driver_rtw.c.orig
$ cp hostapd-2.5/src/drivers/driver_rtw.c hostapd-2.5/src/drivers/
$ cd hostapd-2.5/
$ patch -Np1 -i ../rtl871xdrv.patch
make & バイナリ入れ替え
$ cd hostapd
$ cp defconfig .config
$ echo CONFIG_DRIVER_RTW=y >> .config
$ make
$ sudo mv /usr/sbin/hostapd{,.orig}
$ sudo mv /usr/sbin/hostapd_cli{,.orig}
$ sudo cp hostapd /usr/sbin/
$ sudo cp hostapd_cli /usr/sbin/
hostapd.conf設定
hostapd.confファイルを作ります# cd
# sudo zcat /usr/share/doc/hostapd/examples/hostapd.conf.gz > hostapd.conf
# sudo cp hostapd.conf /etc/hostapd/hostapd.conf
hostapd.confの設定
/etc/hostapd/hostapd.conf
interface=wlan0driverはrtl871xdrvを使用します。
driver=rtl871xdrv
channel=5
ssid=raspi-starway001
hw_mode=g
macaddr_acl=0
auth_algs=1
wpa=2
wpa_passphrase=hogehoge
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
channel, ssid, wpa_passphrase は各環境で変更してください。
その他のパラメータはデフォルトのままです。
/etc/default/hostapd の設定
/etc/default/hostapdDAEMON_CONF="/etc/hostapd/hostapd.conf"
/etc/init.d/hostapd の改造
起動時、自動的にユニークなSSID名を割り当てる処理を組み込んでおきます。自分で設定した hostapd.conf の ssid 行を使用する場合は以下の修正は不要です。
修正すると、SSID名が starway-************ に変更されます。(**部分はMACアドレス)
/etc/init.d/hostapd 内の
. /lib/lsb/init-functions
行直後に下記追加。
MACADDR=`ifconfig | grep 'HWaddr' | tail -n 1 | awk '{print $5;}' |sed "s/://g"`
sed -i -e "s/^ssid=.*\$/ssid=starway-${MACADDR}/" $DAEMON_CONF
ブート時サービス起動
$ sudo update-rc.d hostapd enable
DHCPDコマンドインストールと初期設定
$ sudo apt-get install isc-dhcp-server
dhcpd.conf設定
/etc/dhcp/dhcpd.confにDHCPDで割り当てるネットワーク情報を記述します。#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;
#authoritative;
subnet 192.168.7.0 netmask 255.255.255.0 {
range 192.168.7.101 192.168.7.199;
option broadcast-address 192.168.7.255;
default-lease-time 600;
max-lease-time 7200;
option routers 192.168.7.1;
option domain-name "local";
option domain-name-servers 8.8.8.8, 8.8.4.4;
}
/etc/default/isc-dhcp-server の設定
/etc/default/isc-dhcp-serverDHCPD_CONF=/etc/dhcp/dhcpd.conf
INTERFACES="wlan0"
/etc/network/interfaces の設定
/etc/network/interfacesauto lo以上。
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet manual
auto wlan0
allow-hotplug wlan0
#iface wlan0 inet manual
#wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface wlan0 inet static
address 192.168.7.1
netmask 255.255.255.0
RasPi2のAPに無線LAN接続すれば、dhcpdによって IPアドレス 192.168.7.x が割り振られます。
RasPi2自身は、192.168.7.1 です。
wlan0-eth0フォワーディング
/etc/sysctl.conf 修正
/etc/sysctl.confnet.ipv4.ip_forward=1フォワーディングアクティベート
$ sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
iptables NAT設定
コマンドラインより下記入力※ファイアーウォール機能はなし。
※貫通状態なのでダイアルアップでは使用しないこと。
$ sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
$ sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
$ sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
iptables再設定用のツールをインストール
$ sudo apt-get install iptables-persistent
途中の質問、ipv4, ipv6それぞれの状態を保存するか?は「はい」
/etc/iptables/rules.v4 に現在のiptables 状態が保存されます。
リブート。
以上の設定でRapPi2が無線LANアクセスポイントとして動作します。
SSIDは starway-********** で、接続パスフレーズは hogehoge。
有線LAN側をインターネットに接続したネットワークに接続しておくとルーターとして動作し、RasPi2のAP経由でインターネットへアクセスできます。
0 件のコメント:
コメントを投稿