LoginSignup
64
68

More than 5 years have passed since last update.

Raspberry Pi 2 (Raspbian: jessie) でIPアドレスを固定する

Last updated at Posted at 2015-12-07

概要

Raspbian WheezyでIP固定化する方法は簡単に見つかったが、Jessieでは方法が異なっていたため、設定方法を記録しておくことにします。

設定内容

Wheezyでは /etc/network/interfaces を編集することで固定IP化できましたが、Jessieでは有効になりませんでした。

interfacesファイルをよく見ると、以下のようなコメントが記述されています

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

そこで、dhcpcd.confのmanを見てみる。以下のような記述が

     static value
             Configures a static value.  If you set ip_address then dhcpcd
             will not attempt to obtain a lease and just use the value for the
             address with an infinite lease time.

             Here is an example which configures a static address, routes and
             dns.
                   interface eth0
                   static ip_address=192.168.0.10/24
                   static routers=192.168.0.1
                   static domain_name_servers=192.168.0.1

             Here is an example for PPP which gives the destination a default
             route.  It uses the special destination keyword to insert the
             destination address into the value.
                   interface ppp0
                   static ip_address=
                   destination routers

そっくりそのまま使えそうなので、/etc/dhcpcd.confに以下のように追記して再起動。

etc/dhcpcd.conf
interface eth0
static ip_address=192.168.0.15/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

設定したIPアドレスに固定されました。
この例は有線LAN(eth0)を使った例なので、無線の場合は調べてみてください。

64
68
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
64
68