14
11

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.

Raspberry PiでDHCPサーバーを立てる

Last updated at Posted at 2017-08-15

isc-dhcp-serverを使って構築します

1. サーバーに固定ipアドレスを設定

こちらの手順で

2. isc-dhcp-serverのインストール

$ sudo apt-get install isc-dhcp-server

3. DHCPサーバーの設定

リースするアドレス体系の設定(dhcp.confを編集する)

$ sudo nano /etc/dhcp/dhcpd.conf
dhcp.conf
# コメントアウト
#option domain-name "example.org";
#option domain-name-servers ns1.example.org, ns2.example.org;

# コメントを外す	
authoritative;

# dhcp-relayを動作させるためには自ネットワークと、
# アドレス付与ネットワークの両方について設定を記述する必要がある
# セミコロンを忘れないように注意!
subnet 202.0.0.0 netmask 255.255.255.0 {}
subnet 8.0.0.0 netmask 255.255.255.0 {
  range 8.0.0.2 8.0.0.254;
  option routers 8.0.0.1;
  option subnet-mask 255.255.255.0;
  default-lease-time 600;
  max-lease-time 7200;  
  # dns setting
  #
  #
}

インタフェースの設定

$ sudo nano /etc/default/isc-dhcp-server
INTERFACES="eth0"

リース用ログファイルの作成

$ sudo touch /var/lib/dhcp/dhcpd.leases

リースアドレスのリセット

$ sudo rm /var/lib/dhcp/dhcpd.leases
$ sudo touch /var/lib/dhcp/dhcpd.leases

4. サービスの再起動・自動起動設定

$ sudo systemctl status isc-dhcp-server.service
$ sudo systemctl stop isc-dhcp-server.service
$ sudo systemctl start isc-dhcp-server.service
$ sudo systemctl enable isc-dhcp-server.service
14
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
14
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?