見よう見まねのラズベリーパイ (6)~Wi-FiのIP固定~

DHCPでIPを割り振っているワイヤレスLANを固定IP化します。
予め、 ifconfig コマンドで現在使用しているワイヤレスLANのインターフェイスを確認しておきます。通常であれば「wlan0」にIPアドレスが割り振られて、現在使用中のワイヤレスLANインターフェイスは「wlan0」である事が確認できます。
ラズベリーパイのIPアドレスは /etc/network/interfaces で設定します。

pi@raspberrypi:~$ sudo nano /etc/network/interfaces

後で変更履歴が分かるように、
iface wlan0 inet manual
の前に”#”を付けてコメントアウトします。
改めて以下の設定を追加します。
iface wlan0 inet static
address 192.168.1.111
netmask 255.255.255.0
gateway 192.168.1.1

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and ‘man dhcpcd.conf’

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet manual

allow-hotplug wlan0
# iface wlan0 inet manual /コメントアウト

# 追記
iface wlan0 inet static
address 192.168.1.111
netmask 255.255.255.0
gateway 192.168.1.1
# ここまで
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

Ctrl+o で上書保存。Ctrl+x で終了します。
reload して設定を有効にします。

pi@raspberrypi:~$ sudo /etc/init.d/networking reload

ifconfigコマンドやSSHでログインして設定したIPアドレスが反映されていることを確認します。

カテゴリー: Raspberry Pi タグ: , , , , , , , , パーマリンク

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です