- 追加された行はこの色です。
- 削除された行はこの色です。
#topicpath
- wi-fi AP を Linux で構築する
- Wifi AP を Linux で構築する
/////////////////////////////////////////////////////////////////////////////////
* 目次 [#contents]
#contents();
/////////////////////////////////////////////////////////////////////////////////
* wi-fi AP にする [#wi-fi-ap]
* Wifi AP にする [#wi-fi-ap]
- ノート PC に付いている Wifi を、APに繋ぎに行くものではなく、それ自身を AP にし、他の Wifi client(スマホや他のノートPCなど)から接続を受け付けるようにする。
//===============================================================================
** hostapd の設定 [#hostapd]
- hostapd をインストールする
# aptitude install hostapd
** Wifi interface の設定 [#g28e16c9]
- interface: wlan0
- IP: 192.168.126.1
# ifconfig wlan0 down
# ifconfig wlan0 192.168.126.1 netmask 255.255.255.0
# ifconfig wlan0 up
- ThinkPad X230 では、こんな感じ
[kazu@foerster:4 ~]$ lsmod | grep wifi
iwlwifi 166761 0
mac80211 192806 1 iwlwifi
cfg80211 137243 2 mac80211,iwlwifi
- mac80211 は、hostapd のサポート対象になっているようだ。
- 取り敢えず、[[hostapd 本家>http://hostap.epitest.fi/hostapd/]] から DL した hostapd.conf を使ってみる。
-- 置き場所は
/etc/hostapd/hostapd.conf
-- /etc/init.d/hostapd から参照するために
/etc/default/hostapd
に、下記を記述する
DAEMON_CONF="/etc/hostapd/hostapd.conf"
- 実行
root@foerster:/etc/hostapd# /usr/sbin/hostapd /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
Using interface wlan0 with hwaddr 64:80:99:7a:1e:7c and ssid 'test'
取り敢えず、動いているらしい...
- SSID の書き換え
$ vi /etc/hostapd/hostapd.conf [RETURN]
# SSID to be used in IEEE 802.11 management frames
ssid=hogehoge ←適切な SSID に書き換える
//===============================================================================
** dhcpd の設定 [#k734f1be]
- dhcpd がなければインストールする。debian の場合は isc-dhcp-server を利用出来る。
# aptitude install isc-dhcp-server
- 設定 /etc/dhcp/dhcpd.conf
設定内容:
INTERFACES="wlan0";
subnet 192.168.126.0 netmask 255.255.255.0 {
range 192.168.126.10 192.168.126.254;
option domain-name-servers 8.8.8.8;
option routers 192.168.126.1;
default-lease-time 600;
max-lease-time 7200;
}
- 設定 /etc/default/isc-dhcp-server
-- /etc/init.d/isc-dhcp-server のデフォルトの挙動から変更しない場合には、ここには特に設定は必要ない
- 起動
# /etc/init.d/isc-dhcp-server start
//===============================================================================
** bridge の設定 [#bridge]
- /etc/network/interfaces を編集する
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp
# Wired network interface
ahto rht0
iface eth0 inet static
address 0.0.0.0
# Wireless network interface
auto wlan0
iface wlan0 inet static
address 0.0.0.0
# Bridge network interface
auto br0
iface br0 inet static
address 192.168.1.253
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-nameservers 192.168.1.1
bridge_ports eth0 wlan0
bridge_stp off
//===============================================================================
** dhcpd の設定 [#dhcpd]
- dhcp server をインストールする
# aptitude install isc-dhcp-server
** hostapd の設定 [#hostapd]
- hostapd をインストールする
# aptitude install hostapd
- 設定 /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
-- ssid, wpa_passphrase は、適切に設定する
-- driver は、AP に対応するドライバのことらしい。
--- [[ソフトウェアアクセスポイント>https://wiki.archlinuxjp.org/index.php/%E3%82%BD%E3%83%95%E3%83%88%E3%82%A6%E3%82%A7%E3%82%A2%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E3%83%9D%E3%82%A4%E3%83%B3%E3%83%88]]~
--- [[About nl80211>https://wireless.wiki.kernel.org/en/developers/Documentation/nl80211]]
- 起動
# /etc/init.d/hostapd start
- /etc/dhcp/dhcpd.conf の編集
//===============================================================================
** bridge の設定 [#bridge]
- ルータとして機能させるため、kernel の IP foward 機能を有効にする
# sysctl -w net.ipv4.ip_forward=1
-- sysctl は、 /proc/sys 配下のファイルへアクセスすることにより、カーネルパラメータの読み書きを行うツール。
- iptables で設定する
# iptables -t nat -A POSTROUTING -s 192.168.126.0/24 -o eth0 -j MASQUERADE
-- 上記では、 wlan0 にぶら下がるクライアントのネットワーク (192.168.126.0/24) の転送先を eth0 に設定している
/////////////////////////////////////////////////////////////////////////////////
* 参考リンク [#links]
- [[Ubuntuで無線LANルーターを構築する>http://netbuffalo.doorblog.jp/archives/3895783.html]]
- [[Debianで無線APを作る(2)Add Star>http://d.hatena.ne.jp/hoge-maru/20110326/1301155960]]
- [[hostapd 本家>http://hostap.epitest.fi/hostapd/]]
- [[hostapd を用いた無線 LAN アクセスポイントの構築>http://masap.sakura.ne.jp/wireless/hostapd.html]]
- [[Ubuntuで無線LANアクセスポイントを構築 [Hostapd で無線LAN AP構築]>http://bibo-log.blog.so-net.ne.jp/2012-05-15]]
- [[Ubuntuで無線LANルーターを構築する>http://netbuffalo.doorblog.jp/archives/3895783.html]]
- [[How To: Create an 802.11n AP (Access Point) w/ Debian on a Dockstar/Pogoplug/kirkwood device>http://forum.doozan.com/read.php?2,6300]]
- [[HostAPD, Linux and the iPhone>http://www.redshiftwireless.com/hostapd-linux-and-the-iphone/]]