概要
DHCPとは、コンピュータにIpアドレスを自動的に割り振る仕組みです。
クライアントがiPアドレスをリクエストした際に、DHCPサーバがあらかじめ設定されているから、未使用のIPアドレスを一定期間貸し出す。
インストール
DHCPサーバ構成のパッケージは、dhcp-server
になります。
# 事前確認
[admin@almalinux9 ~]$ yum list installed |grep dhcp
# インストール
[admin@almalinux9 ~]$ sudo yum install -y dhcp-server
メタデータの期限切れの最終確認: 0:04:35 前の 2024年02月10日 16時31分52秒 に実施しました。
依存関係が解決しました。
=============================================================================================================================================================
パッケージ アーキテクチャー バージョン リポジトリー サイズ
=============================================================================================================================================================
インストール:
dhcp-server x86_64 12:4.4.2-19.b1.el9 baseos 1.2 M
依存関係のインストール:
dhcp-common noarch 12:4.4.2-19.b1.el9 baseos 128 k
トランザクションの概要
=============================================================================================================================================================
インストール 2 パッケージ
ダウンロードサイズの合計: 1.3 M
インストール後のサイズ: 4.2 M
パッケージのダウンロード:
(1/2): dhcp-common-4.4.2-19.b1.el9.noarch.rpm 458 kB/s | 128 kB 00:00
(2/2): dhcp-server-4.4.2-19.b1.el9.x86_64.rpm 1.8 MB/s | 1.2 MB 00:00
-------------------------------------------------------------------------------------------------------------------------------------------------------------
合計 1.0 MB/s | 1.3 MB 00:01
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
準備 : 1/1
インストール中 : dhcp-common-12:4.4.2-19.b1.el9.noarch 1/2
scriptletの実行中: dhcp-server-12:4.4.2-19.b1.el9.x86_64 2/2
インストール中 : dhcp-server-12:4.4.2-19.b1.el9.x86_64 2/2
scriptletの実行中: dhcp-server-12:4.4.2-19.b1.el9.x86_64 2/2
検証 : dhcp-common-12:4.4.2-19.b1.el9.noarch 1/2
検証 : dhcp-server-12:4.4.2-19.b1.el9.x86_64 2/2
インストール済み:
dhcp-common-12:4.4.2-19.b1.el9.noarch dhcp-server-12:4.4.2-19.b1.el9.x86_64
完了しました!
パケットフィルタリング設定
# 現在の利用可能なサービスの確認
[admin@almalinux9 ~]$ sudo firewall-cmd --list-services
cockpit dhcpv6-client ssh
# 設定の追加
[admin@almalinux9 ~]$ sudo firewall-cmd --add-service=dhcp
success
# ルールの保存
[admin@almalinux9 ~]$ sudo firewall-cmd --runtime-to-permanent
success
DHCPサーバの基本設定
IPv4用の設定ファイルは、/etc/dhcp/dhcpd.conf
ですが、インストール後は何も設定がされていない。
そのため、サンプルの設定ファイルが/usr/share/doc/dhcp-server
配下にあるのでコピーして編集する。
ちなみに、ファイルの中身を確認すると・・・
/etc/dhcp/dhcpd.conf
[admin@almalinux9 ~]$ sudo cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp-server/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
# 設定ファイルの種類
[admin@almalinux9 dhcp-server]$ cd /usr/share/doc/dhcp-server/ && ll
合計 16
-rw-r--r--. 1 root root 5856 9月 27 11:44 dhcp-lease-list.pl
-rw-r--r--. 1 root root 3266 12月 18 2019 dhcpd.conf.example
-rw-r--r--. 1 root root 3367 9月 27 11:44 dhcpd6.conf.example
drwxr-xr-x. 2 root root 70 2月 10 16:36 ldap
設定ファイルのコピー
[admin@almalinux9 ~]$ sudo cp /usr/share/doc/dhcp-server/dhcpd.conf.example /etc/dhcp/dhcpd.conf