0
0

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 1 year has passed since last update.

Photon OS と ISC DHCP で DHCP サーバーを構築

Posted at

以前の記事で、Photon OS に dnsmasq をインストールして、DNS サーバー兼 DHCP サーバーを構築しました。

今回は、DHCP サーバー機能に絞って、構築していく手順を紹介します。

なぜわざわざ?とも思いますが、dnsmasq で DNS サーバーも同時に構築しようとする場合、Photon OS 4.0 以降では、systemd-resolved とポート競合を起こしてしまったり、手順に若干の落とし穴があります。そのため、サクッと DHCP サーバーだけ構築したい場合には、ISC DHCP (isc-dhcp-server) を使った方が簡単なので、その紹介になります。

前提

Photon OS がデプロイ済みであり、最低限の設定として、こちら↓のあたりが行われている想定で、手順を記載しています。
ただし、全ての手順を実施する必要は無いので、詰まった時に参照いただければ良いです。

また、執筆時点で、Photon OS は ver 4.0 を利用しています。

# cat /etc/photon-release
VMware Photon OS 4.0
PHOTON_BUILD_NUMBER=2f5aad892

パッケージのインストール

今回利用する ISC DHCP のサーバー機能のパッケージをインストールします。

tdnf install -y dhcp-server

ちなみに... パッケージ名は dhcp-server ですが、下記の SPEC ファイルを見てもらうと、中身が ISC DHCP を使っていることが分かります。

設定ファイルの修正

DHCP サーバーとしての設定を記載していきます。

vi /etc/dhcp/dhcpd.conf

設定例:

/etc/dhcp/dhcpd.conf
subnet 192.168.122.0 netmask 255.255.255.0 {
  range 192.168.122.100 192.168.122.200;
  option routers 192.168.122.254;
  option domain-name-servers 192.168.1.1;
  option ntp-servers 192.168.1.1;
}

もし、特定のホスト (MAC アドレス) に対して、固定 IP アドレスを振りたい場合には、下記のような設定を追記します。

/etc/dhcp/dhcpd.conf
host dhcp-tester {
  hardware ethernet xx:xx:xx:xx:xx:xx;
  fixed-address 192.168.122.101;
}

また、DHCP サーバーにする VM が、複数の NIC を持っている場合、どの NIC を使うのか指定する必要があります。
その場合は、下記のように設定します。

vi /etc/default/dhcpd

設定例:

/etc/default/dhcpd
DHCPD_OPTS=
INTERFACES="eth1"

サービスの起動

まずは、サービスを有効化します。

systemctl enable dhcp.service

次に、サービスを起動します。

systemctl start dhcp.service

サービスの起動を確認して、正しく起動しているか見ておきましょう。

systemctl status dhcp.service
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?