6
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Raspbian Stretch の固定IPアドレス化

Last updated at Posted at 2018-07-08

Raspbianの固定IP化

Raspbianを固定IP化するのにあたり、以下の順番でやっていく。

  1. DHCPで割り振られたIPアドレスを調べる
  2. 他のPC(母艦)から調べたIPアドレスにSSHでログインする
  3. /etc/dhcpcd.confを書き換える
  4. リブートする

ipアドレスを調べる

$ ifconfig -a
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.110.15  netmask 255.255.255.0  broadcast 192.168.110.255
        inet6 fe80::20f:d13f:7743:392  prefixlen 64  scopeid 0x20<link>
        ether b8:27:eb:be:63:00  txqueuelen 1000  (イーサネット)
        RX packets 102986  bytes 149294615 (142.3 MiB)
        RX errors 0  dropped 631  overruns 0  frame 0
        TX packets 55456  bytes 5171364 (4.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

もしくは

ip a s | grep global
    inet 192.168.110.15/24 brd 192.168.110.255 scope global wlan0

で、IPアドレスがわかる

sshでRaspbianにログインする

$ ssh -l pi 192.168.110.15

/etc/dhcpcd.confを書き換える

昔は、/etc/networks/interfacesを書き換えればよかたんだけど、Stretchは/etc/dhcpcd.confを書き換えるらしい。
以下の部分を追記した。

/etc/dhcpcd.conf
 interface wlan0
 static ip_address=192.168.110.50/24
 static routers=192.168.110.1
 static domain_name_servers=192.168.110.1

リブート

リブートすると、IPアドレスが先程設定した固定IPアドレスで立ち上がってくるので、再度sshでログインできることを確認する。

$ ssh -l pi 192.168.110.50

これでRapiroにRaspberryPiを載せても、遠隔で設定できるようになった。

6
12
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
6
12

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?