LoginSignup
8
11

More than 3 years have passed since last update.

RaspberryPi4 を5GHz対応のWiFiアクセスポイントにする

Posted at

はじめに

RaspberryPi4のWiFiアクセスポイント化でかなりハマったので、いつもお世話になっているQiitaへ忘備録として残します。

基本的には公式サイトを参照すれば問題ありません。
Setting up a Raspberry Pi as a routed wireless access point

ローカルでラズパイとPCを直接通信できるようにしたかっただけなので、ルーティングとIPマスカレード設定は行いませんでした。

手順

インストール

sudo apt install hostapd
sudo systemctl unmask hostapd
sudo systemctl enable hostapd

sudo apt install dnsmasq

sudo DEBIAN_FRONTEND=noninteractive apt install -y netfilter-persistent iptables-persistent

ラズパイ自身のIPアドレス設定

sudo nano /etc/dhcpcd.conf
dhcpcd.conf
interface wlan0
    static ip_address=192.168.4.1/24
    nohook wpa_supplicant

クライアント IPアドレス設定

sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
sudo nano /etc/dnsmasq.conf
dnsmasq.conf
interface=wlan0 # Listening interface
dhcp-range=192.168.4.2,192.168.4.20,255.255.255.0,24h
                # Pool of IP addresses served via DHCP
domain=wlan     # Local wireless DNS domain
address=/gw.wlan/192.168.4.1
                # Alias for this router

ロケーション設定
raspi-config -> 4 Localisation Options -> I4 Change Wi-fi Country -> JP Japanを選択。

sudo raspi-config

Wi-Fi設定
country_codeは日本。
ssidwpa_passphraseは自由に変更する。
(ただし、8文字以上かつハイフンとアンダーバー以外の記号は使わないこと。)

キーポイントはhw_modechannel
5GHz対応にしたいので a=IEEE 802.11a (5 GHz)を設定し、チャンネルを36とする。
通信規格とチャンネルがアンマッチだと起動しないので注意。

sudo nano /etc/hostapd/hostapd.conf
hostapd.conf
country_code=JP
interface=wlan0
ssid=NameOfNetwork
hw_mode=a
channel=36
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=AardvarkBadgerHedgehog
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

再起動

sudo systemctl reboot

再起動後に5GHz対応のWiFiアクセスポイントになる

8
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
11