2017年8月2日水曜日

raspberry pi 3 で hostapd + dnsmasq で wifi アクセスポイントをつくる

wifi access point をつくる





なイメージです。

英語の
https://frillip.com/using-your-raspberry-pi-3-as-a-wifi-access-point-with-hostapd/
のとおり

最終のスクリプトは
 ./wifi-accessPoint.bat
sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"


iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE  
iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT  
iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT 

service hostapd start  
service dnsmasq start 


必要な道具を用意します
aptitude install hostapd dnsmasq



/etc/dhcpcd.conf
hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option ntp_servers
require dhcp_server_identifier
slaac private
nohook lookup-hostname
denyinterfaces wlan0 



ヘリポートにアドレスをふります
 /etc/network/interfaces


source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet manual
allow-hotplug wlan0  
iface wlan0 inet static  
    address 172.24.1.1
    netmask 255.255.255.0
    network 172.24.1.0
    broadcast 172.24.1.255



ヘリコプターがつける準備です
/etc/hostapd/hostapd.conf

interface=wlan0
driver=nl80211
ssid=Pi3-AP
hw_mode=g
channel=6
ieee80211n=1
wmm_enabled=1
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_passphrase=1122334455


rsn_pairwise=CCMP



切符がないと 新幹線にはのれませんので
 /etc/dnsmasq.conf 
interface=wlan0      # Use interface wlan0  
listen-address=172.24.1.1 # Explicitly specify the address to listen on  
bind-interfaces      # Bind to the interface to make sure we aren't sending things elsewhere  
server=8.8.8.8       # Forward DNS requests to Google DNS  
domain-needed        # Don't forward short names  
bogus-priv           
dhcp-range=172.24.1.50,172.24.1.55,12h 


これにて 
wifi いう電波に乗って ヘリポートにおりたち(hostapdの役割)

dnsmasqから 切符をもらい

iptables によって新幹線にいけます


感謝です
日本語のサイトはいろいろ試しましたが駄目でした。
isc-dhcp サーバーは危なすぎます

0 件のコメント:

コメントを投稿