furuhashilab / 2021gsc_ShogoHirasawa

古橋研究室 4年 平澤彰悟の卒論リポジトリ
https://furuhashilab.github.io/2021gsc_ShogoHirasawa/
Creative Commons Attribution 4.0 International
0 stars 0 forks source link

Raspberry Pi スタンドアローン化 #23

Open ShogoHirasawa opened 2 years ago

ShogoHirasawa commented 2 years ago

ssh 接続

 ssh pi@raspberrypi.local

ラズパイ側のIPの固定

cat << _EOF_ | sudo tee -a /etc/dhcpcd.conf
interface eth0
static ip_address=192.168.10.1/24
_EOF_

sudo systemctl restart dhcpcd

パッケージインストール

sudo apt update -y
sudo apt install dnsmasq
sudo apt install -y apache2
sudo apt install -y hostapd
sudo apt upgrade -y
sudo apt autoremove -y
sudo apt-get install isc-dhcp-server
sudo apt-get install rng-tools

Wi-Fiクライアントとしての設定を無効化

sudo systemctl stop wpa_supplicant
sudo systemctl disable wpa_supplicant

dhcpcdの設定を固定IPに変える

sudo echo "interface wlan0" >> /etc/dhcpcd.conf
sudo echo "static ip_address=192.168.20.1/24" >> /etc/dhcpcd.conf
sudo systemctl restart dhcpcd

hostapdの設定

cat << _EOF_ | sudo tee /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
hw_mode=b
channel=1
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
ieee80211ac=0
wmm_enabled=1
ieee80211d=1
country_code=JP
ieee80211h=1
local_pwr_constraint=3
spectrum_mgmt_required=1
wpa=3
wpa_key_mgmt=WPA-PSK
ssid=dronebird
wpa_passphrase=dronebird
_EOF_

sudo sed -i -e "s@#DAEMON_CONF=\"\"@DAEMON_CONF=\"/etc/hostapd/hostapd.conf\"@g" /etc/default/hostapd

デーモンを有効化

sudo systemctl unmask hostapd 
sudo systemctl enable hostapd
sudo systemctl start hostapd

isc-dhcp-serverの設定

nano /etc/dhcp/dhcpd.conf
subnet 192.168.2.0 netmask 255.255.255.0 {
  range 192.168.2.100 192.168.2.200;
  option broadcast-address 192.168.2.255;
  default-lease-time 600;
  max-lease-time 7200;
}
sudo systemctl enable isc-dhcp-server
sudo systemctl restart isc-dhcp-server
ShogoHirasawa commented 2 years ago

Wi-Fiの一覧に表示されず...。