DHCP : サーバーの設定2025/11/03 |
|
DHCP ( Dynamic Host Configuration Protocol ) サーバーを構築し、ローカルネットワーク内のクライアントコンピューターに IP アドレスの自動割当ができるようにします。 |
|
| [1] | DHCP のインストールと設定です。当例では IPv4 についてのみ例示します。 |
|
[root@dlp ~]#
dnf -y install dhcp-server
[root@dlp ~]#
vi /etc/dhcp/dhcpd.conf # 以下の内容で新規作成 # ドメイン名指定 option domain-name "srv.world"; # ネームサーバーのホスト名, または IP アドレス指定 option domain-name-servers dlp.srv.world; # デフォルト貸出期間 default-lease-time 600; # 最大貸出期間 max-lease-time 7200; # 正当な DHCP サーバーであることの宣言 authoritative; # ネットワークアドレスとサブネットマスク指定 subnet 10.0.0.0 netmask 255.255.255.0 { # 貸し出す IP アドレスの範囲指定 range dynamic-bootp 10.0.0.200 10.0.0.254; # ブロードキャストアドレス指定 option broadcast-address 10.0.0.255; # ゲートウェイアドレス指定 option routers 10.0.0.1; } systemctl enable --now dhcpd |
| [2] | Firewalld を有効にしている場合は DHCP サービスの許可が必要です。DHCP サーバー は [67/UDP] を使用します。 |
|
[root@dlp ~]# firewall-cmd --add-service=dhcp success [root@dlp ~]# firewall-cmd --runtime-to-permanent success |
| [3] | DHCP サーバーからクライアントコンピューターにリースされた IP アドレスは以下のファイルで確認できます。 |
|
[root@dlp ~]# ll /var/lib/dhcpd total 4 -rw-r--r--. 1 dhcpd dhcpd 0 Jul 23 09:00 dhcpd6.leases -rw-r--r--. 1 dhcpd dhcpd 277 Nov 3 10:36 dhcpd.leases -rw-r--r--. 1 dhcpd dhcpd 0 Jul 23 09:00 dhcpd.leases~[root@dlp ~]# cat /var/lib/dhcpd/dhcpd.leases
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-4.4.3-P1
# authoring-byte-order entry is generated, DO NOT DELETE
authoring-byte-order little-endian;
server-duid "\000\001\000\0010\232\303\220RT\000%!9";
lease 10.0.0.250 {
starts 1 2025/11/03 01:37:34;
ends 1 2025/11/03 01:47:34;
cltt 1 2025/11/03 01:37:34;
binding state active;
next binding state free;
rewind binding state free;
hardware ethernet 00:0c:29:e5:f5:43;
uid "\001\000\014)\345\365C";
set vendor-class-identifier = "MSFT 5.0";
client-hostname "RX-0";
}
.....
.....
|
| Sponsored Link |
|
|