Linuxで無線LAN

 ノートパソコンはどこでも持ち運びができ便利で、その恩恵は自宅やオフィスでも受けることができます。

自宅やオフィスで使っている場合に、インターネットやファイルサーバと接続する際、LANケーブルを接続しようとすると、物理的に届かなかったり、ケーブルがぐちゃぐちゃになってしまい、踏んづけてしまったり、後片付けが大変だったりする場合があります。

そのような場合、無線LANを使えば上記のような問題は解決することができ、快適に使うことができます。もちろんLinuxをクライアントとして使った場合にも無線LANの恩恵を受けたいものです。

以下に、Thinkpad X30にBUFFALOのPCMCIAカードWLI2-CB-G54Lを使って無線LAN接続する設定について記載しています。

環境

機種
Thinkpad X30 (2672-41J)

無線LANカード
Buffalo WLI2-CB-G54L

ディストリビュージョン
Fedora Core 1

Kernel
2.4.32 (2.4.22からアップグレード)

Ndiswrapper
ndiswrapper-1.1

Windowsドライバ (infファイル)
NET2G54L.inf (Ver.6.3) Buffaloのドライバ

暗号化
128bit WEP

Ndiswrapperを導入するにはKernelのバージョンが2.6.6または2.4.26以降でなければならず、またkernelのソースも必要になります。Fedora Core 1ですとKernelのアップグレードが必要になり、今回は2.4.32にアップグレードして使用しています。今回はアップグレードが完了しているものとして話しを進めます。(2.4.32へのアップグレード作業についてはこちらを確認してください。)

インストール

NdiswrapperはWindowsのドライバを使用して無線LANカードを認識させ、無線LANを使用できるようにします。
まずはNdiswrapperのソースをsourceforgeのページにいきDownloadから入手してください。(今回記載しているバージョンは1.1です。

ソースを取得できたらインストール作業に取りかかります。

[root@localhost tmp]# tar zxvf ndiswrapper-1.1.tar.gz
[root@localhost tmp]# cd ndiswrapper-1.1
[root@localhost ndiswrapper-1.1]# make
[root@localhost ndiswrapper-1.1]# make install

上記を実行しエラーがなければインストールは完了です。
次にWindowsのドライバをNdiswrapperに読み込ませます。ドライバファイルはBuffaloのホームページからDownloadしておき、lhaにて解凍しておきます。(解凍する際のコマンドは”lha -x xxxx.exe <自己解凍形式のドライバファイル>”)

[root@localhost ndiswrapper-1.1]# ndiswrapper -i net2g54l.inf

以下のコマンドを実行し、読み込まれたかどうかを確認します。

[root@localhost ndiswrapper-1.1]# ndiswrapper  -l
  -> net2g54l        driver present, hardware present

上記のように表示されていれば読み込まれています。

モジュールの読み込みとWEPの設定

insmodまたはmodprobeコマンドでndiswrapperのモジュールを読みこみます。

[root@localhost ndiswrapper-1.1]# insmod ndiswrapper

モジュールの読み込みに成功すれば、dmesgで下記のように表示されます。

[root@localhost ndiswrapper-1.1]# dmesg

  (途中省略)

ndiswrapper version 1.1 loaded (preempt=no,smp=no)
ndiswrapper: driver net2g54l (BUFFALO INC.,09/08/2004,2.27.09.2004) loaded
PCI: Setting latency timer of device 02:00.0 to 64
ndiswrapper: using irq 11
divert: allocating divert_blk for wlan0
wlan0: ndiswrapper ethernet device 00:0d:0b:63:67:91 using driver net2g54l, configuration file 17FE:2220:1154:0334.5.conf
wlan0: encryption modes supported: WEP, WPA with TKIP, WPA with AES/CCMP

iwconfigコマンドでWireless Interfaceの状況を表示してみると、Loopbackとeth0も表示されますがWireless Interfaceではないためessidなどの情報は表示されません。

[root@localhost ndiswrapper-1.1]# iwconfig
lo        no wireless extensions.

eth0      no wireless extensions.

Warning: Driver for device wlan0 has been compiled with version 16
of Wireless Extension, while this program is using version 15.
Some things may be broken...

wlan0     IEEE 802.11g  ESSID:off/any
          Mode:Managed  Channel:0  Access Point: 00:00:00:00:00:00
          Bit Rate:1Mb/s   Tx-Power:0 dBm
          RTS thr:2347 B   Fragment thr:2346 B
          Encryption key:off
          Power Management:off
          Link Quality:100/0  Signal level:-200 dBm  Noise level:-256 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

今回は、暗号化にWEPを使用しているので、WEPの設定をおこないます。今回設定している環境ではWEP128bit文字列です。

[root@localhost ndiswrapper-1.1]# iwconfig wlan0 essid essid key restricted s:13字の文字列

再度iwconfigを実行するとESSIDとEncryption keyが設定されていることが確認できます。

[root@localhost ndiswrapper-1.1]# iwconfig
lo        no wireless extensions.

eth0      no wireless extensions.

Warning: Driver for device wlan0 has been compiled with version 16
of Wireless Extension, while this program is using version 15.
Some things may be broken...

wlan0     IEEE 802.11g  ESSID:"essid"
          Mode:Managed  Frequency:2.462GHz  Access Point: 00:0D:0B:53:91:0B
          Bit Rate:54Mb/s   Tx-Power:0 dBm
          RTS thr:2347 B   Fragment thr:2346 B
          Encryption key:6869-726F-6861-7275-6869-746F-65   Security mode:restricted
          Power Management:off
          Link Quality:100/0  Signal level:-54 dBm  Noise level:-256 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

ネットワークの設定

ESSIDとEncryptionの設定が終わったので、IPアドレスとRouteの設定をおこないます。
まずはIPアドレスですが、今回は192.168.2.0/24のネットワークアドレスから手動でアドレスを割り当てています。

[root@localhost ndiswrapper-1.1]# ifconfig wlan0 up 192.168.2.101
[root@localhost ndiswrapper-1.1]# ifconfig
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:3109 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3109 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:304176 (297.0 Kb)  TX bytes:304176 (297.0 Kb)

wlan0     Link encap:Ethernet  HWaddr 00:0D:0B:63:67:91
          inet addr:192.168.2.101  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:485 errors:0 dropped:0 overruns:0 frame:0
          TX packets:108 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:177412 (173.2 Kb)  TX bytes:8198 (8.0 Kb)
          Memory:10800800-10800fff

Default Gatewayの設定をおこないます。
下記では、無線LANルータのアドレスをDefault Gatewayに設定しています。

[root@localhost ndiswrapper-1.1]# route add default gw 192.168.2.1 wlan0
[root@localhost ndiswrapper-1.1]# route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.2.0     *               255.255.255.0   U     0      0        0 wlan0
169.254.0.0     *               255.255.0.0     U     0      0        0 lo
127.0.0.0       *               255.0.0.0       U     0      0        0 lo
default         .               0.0.0.0         UG    0      0        0 wlan0

以上で設定は完了です。
全ての作業が問題なく完了していれば、無線LANを使用してインターネットの閲覧などができる状態になっているはずです。

また、これらの作業を毎回手動で実施するのは面倒ですので、無線LANを使用する際に下記のようなスクリプトをrootで実行すると便利です。(rc.dに起動スクリプトを書くとさらに便利です。)

#!/bin/bash
insmod ndiswrapper
sleep 2
ipconfig wlan0 up 192.168.2.101
sleep 2
route add default gw 192.168.2.1 wlan0
タイトルとURLをコピーしました