「Dhcpd」の版間の差分
(ページの作成:「{{Lowercase title}} Category:ネットワーク de:Dhcpd en:Dhcpd ru:Dhcpd {{Related articles start}} {{Related|dhcpcd}} {{Related articles end}} dhcpd...」) |
(同期) |
||
(4人の利用者による、間の15版が非表示) | |||
1行目: | 1行目: | ||
{{Lowercase title}} |
{{Lowercase title}} |
||
− | [[Category: |
+ | [[Category:DHCP]] |
[[de:Dhcpd]] |
[[de:Dhcpd]] |
||
[[en:Dhcpd]] |
[[en:Dhcpd]] |
||
+ | [[pt:Dhcpd]] |
||
[[ru:Dhcpd]] |
[[ru:Dhcpd]] |
||
+ | [[zh-hans:Dhcpd]] |
||
{{Related articles start}} |
{{Related articles start}} |
||
− | {{Related| |
+ | {{Related|ネットワーク設定}} |
+ | {{Related|ネットワークツール}} |
||
{{Related articles end}} |
{{Related articles end}} |
||
+ | [https://www.isc.org/dhcp/ dhcpd] は、旧式の ISC DHCP サーバーです。 |
||
+ | {{Note| |
||
− | dhcpd は [http://www.isc.org/downloads/dhcp/ Internet Systems Consortium] による DHCP サーバーです。LAN 上でルーターとして動作するマシンなどで有用です。 |
||
+ | * ''dhcpd'' は既に保守されていません。 [https://www.isc.org/ Internet Systems Consortium] (ISC) は、[[Kea]] を [https://www.isc.org/kea/ 公式な代替] として推奨しています。 |
||
+ | * ''dhcpd'' (DHCP '''サーバー'''デーモン)は、[[dhcpcd]] (DHCP '''クライアント'''デーモン) とは異なります。 |
||
+ | }} |
||
== インストール == |
== インストール == |
||
+ | |||
[[公式リポジトリ]]の {{pkg|dhcp}} パッケージを[[インストール]]してください。 |
[[公式リポジトリ]]の {{pkg|dhcp}} パッケージを[[インストール]]してください。 |
||
== 設定 == |
== 設定 == |
||
− | + | ''dhcpd'' がリスニングするインターフェース (ここでは {{ic|eth0}}) に静的な IPv4 アドレスを設定します。他のインターフェースのサブネットと重ならないように注意してください。 |
|
# ip link set up dev eth0 |
# ip link set up dev eth0 |
||
− | # ip addr add 139.96.30.100/24 dev eth0 |
+ | # ip addr add 139.96.30.100/24 dev eth0 # 任意のアドレス |
+ | {{Tip| |
||
− | {{Tip|Usually, the one of next three subnets is used for private networks, which are specially reserved and won't conflict with any host in the Internet: |
||
+ | * 起動時に静的IPアドレスを割り当てるには、[[ネットワーク設定#固定 IP アドレス]]を参照してください。 |
||
− | * {{ic|192.168/16}} (subnet {{ic|192.168.0.0}}, netmask {{ic|255.255.0.0}}) |
||
+ | * [[RFC:1918|RFC 1918]] サブネットはプライベートネットワーク用に予約されており、インターネット上のホストとは競合しません。 |
||
− | * {{ic|172.16/12}} (subnet {{ic|172.16.0.0}}, netmask {{ic|255.240.0.0}}) |
||
+ | }} |
||
− | * {{ic|10/8}} (for large networks; subnet {{ic|10.0.0.0}}, netmask {{ic|255.0.0.0}}) |
||
− | See also [http://www.ietf.org/rfc/rfc1918.txt RFC 1918].}} |
||
+ | デフォルトの設定ファイル {{ic|dhcpd.conf}} には多くのサンプルが含まれているため、元のファイルを移動しておきます。 |
||
− | 起動時に固定 ip を割り当てるには、[[ネットワーク設定#固定 IP アドレス]]を参照。 |
||
+ | # cp /etc/dhcpd.conf /etc/dhcpd.conf.example |
||
− | デフォルトの {{ic|dhcpd.conf}} にはアンコメントされている例がたくさん含まれているので、ファイルを移動してください: |
||
+ | 特定のサブネット ({{ic|139.96.30.0/24}}) のみをリスニングするように、以下のような最小構成の設定ファイルを作成します。 |
||
− | # mv /etc/dhcpd.conf /etc/dhcpd.conf.example |
||
− | |||
− | 最小限の設定ファイルは以下のようになります: |
||
{{hc|/etc/dhcpd.conf| |
{{hc|/etc/dhcpd.conf| |
||
43行目: | 48行目: | ||
}} |
}} |
||
+ | この設定ファイルで使用されているオプションは次のとおりです。 |
||
− | {{ic|domain-name-servers}} option contains addresses of DNS servers which are supplied to clients. In our example we are using Google's public DNS servers. If you know a local DNS servers (for example, provided by your ISP), you should use it. If you've configured your own DNS on a local machine, then use its address in your subnet (e. g. {{ic|139.96.30.100}} in our example). |
||
+ | {{ic|domain-name-servers}} クライアントに提供される DNS サーバーのアドレスを指定します。ここでは Google のパブリックDNSサーバーを使用しています。ローカルマシンに独自の DNS サーバーを設定している場合は、そのアドレスを指定してください (ここでは {{ic|139.96.30.0/24}}) |
||
− | {{ic|subnet-mask}} and {{ic|routers}} defines a subnet mask and a list of available routers on the subnet. In most cases for small networks you can use {{ic|255.255.255.0}} as a mask and specify an IP address of the machine on which you're configuring DHCP server as a router. |
||
+ | {{ic|subnet-mask}} および {{ic|routers}} これらは、サブネットマスクとサブネット内で利用可能なルーターのリストを定義します。 |
||
− | {{ic|subnet}} blocks defines options for separate subnets, which are mapped to the network interfaces on which ''dhcpd'' is running. In our example this is one subnet {{ic|139.96.30.0/24}} for single interface {{ic|eth0}}, for which we defined the range of available IP addresses. Addresses from this range will be assigned to the connecting clients. |
||
+ | また、{{ic|routers}} はクライアントに提供されるデフォルトゲートウェイも指定します。 |
||
+ | 小規模なネットワークでは、通常 {{ic|255.255.255.0}} をマスクとして使用し、''dhcpd'' を実行しているマシンのIPアドレス(ここでは {{ic|139.96.30.100}}) を指定できます。 |
||
+ | {{ic|subnet}} ''dhcpd'' がリッスンしているネットワークインターフェースに適用される、個別のサブネットのオプションを定義します。 |
||
− | 設定後、[[Systemd#ユニット使う|systemctl]] を使って {{ic|dhcpd4.service}} を起動することで ''dhcpd'' デーモンを起動できます。任意で、ブート時に自動的に起動するように有効化してください。 |
||
+ | ここでは、単一のサブネット {{ic|139.96.30.0/24}} (インターフェース {{ic|eth0}}) の利用可能な IP アドレスの範囲を定義しています。 |
||
+ | 詳細なオプションについては、{{man|5|dhcpd.conf}} を参照してください。 |
||
− | Now, to any computer you connect to the {{ic|eth0}} will be assigned an IPv4 address (from {{ic|139.96.30.150}} to {{ic|139.96.30.250}} in this example). |
||
+ | {{Note|''dhcpd'' は、設定ファイルで定義されたサブネットを持つインターフェースのみをリスニングします。{{man|8|dhcpd}} の説明とは異なる動作をする点に注意してください。}} |
||
− | == Tips and Tricks == |
||
− | === Listening on only one interface === |
||
− | If your computer is already part of one or several networks, it could be a problem if your computer starts giving ip addresses to machines from the other networks. It can be done by either configuring dhcpd or starting it as a daemon with [[Systemd#Using units|systemctl]]. |
||
− | + | === PXE === |
|
− | In order to exclude an interface, you must create an empty declartion for the subnet that will be configured on that interface. |
||
+ | [[Preboot Execution Environment]] (PXE) 設定は、次の2つのオプションで実行されます: |
||
− | This is done by editing the configuration file (for example): |
||
+ | |||
− | {{hc|/etc/dhcpd.conf|<nowiki> |
||
+ | {{hc|/etc/dhcpd.conf| |
||
− | # No DHCP service in DMZ network (192.168.2.0/24) |
||
− | + | next-server 192.168.0.2; |
|
+ | filename "/pxelinux.0"; |
||
− | } |
||
+ | }} |
||
− | </nowiki>}} |
||
+ | |||
+ | {{ic|next-server}} は [[TFTP]] サーバーのIPアドレスであり、{{ic|filename}} はブートするイメージを指定します。 |
||
+ | このセクションは、{{ic|subnet}} 全体に含めることも、特定の {{ic|host}} 定義内に含めることもできます。 |
||
− | ==== サービスファイル ==== |
||
− | There is no service files provided by default to use ''dhcpd'' only on one interface so you need to create one: |
||
+ | == 使用方法 == |
||
− | {{hc| /etc/systemd/system/dhcpd4@.service|<nowiki> |
||
− | [Unit] |
||
− | Description=IPv4 DHCP server on %I |
||
− | Wants=network.target |
||
− | After=network.target |
||
+ | ''dhcpd'' には {{ic|dhcpd4.service}} と {{ic|dhcpd6.service}} の2つのユニットファイルが含まれており、これらを使用してデーモンを[[有効化|制御]]できます。 |
||
− | [Service] |
||
+ | これらのサービスは、それぞれ IPv4 および IPv6 用に すべての [[ネットワークインターフェース]] 上でデーモンを起動します。 |
||
− | Type=forking |
||
− | PIDFile=/run/dhcpd4.pid |
||
− | ExecStart=/usr/bin/dhcpd -4 -q -pf /run/dhcpd4.pid %I |
||
− | KillSignal=SIGINT |
||
+ | == 参照 == |
||
− | [Install] |
||
− | WantedBy=multi-user.target |
||
− | </nowiki>}} |
||
+ | * [https://kb.isc.org/docs/aa-00333 ISC DHCP ドキュメント] |
||
− | Now you can start ''dhcpd'' as a daemon which only listen to a specific interface, for example {{ic|eth0}}. |
||
− | # systemctl start dhcpd4@eth0.service |
2025年2月26日 (水) 06:52時点における最新版
dhcpd は、旧式の ISC DHCP サーバーです。
インストール
公式リポジトリの dhcp パッケージをインストールしてください。
設定
dhcpd がリスニングするインターフェース (ここでは eth0
) に静的な IPv4 アドレスを設定します。他のインターフェースのサブネットと重ならないように注意してください。
# ip link set up dev eth0 # ip addr add 139.96.30.100/24 dev eth0 # 任意のアドレス
デフォルトの設定ファイル dhcpd.conf
には多くのサンプルが含まれているため、元のファイルを移動しておきます。
# cp /etc/dhcpd.conf /etc/dhcpd.conf.example
特定のサブネット (139.96.30.0/24
) のみをリスニングするように、以下のような最小構成の設定ファイルを作成します。
/etc/dhcpd.conf
option domain-name-servers 8.8.8.8, 8.8.4.4; option subnet-mask 255.255.255.0; option routers 139.96.30.100; subnet 139.96.30.0 netmask 255.255.255.0 { range 139.96.30.150 139.96.30.250; }
この設定ファイルで使用されているオプションは次のとおりです。
domain-name-servers
クライアントに提供される DNS サーバーのアドレスを指定します。ここでは Google のパブリックDNSサーバーを使用しています。ローカルマシンに独自の DNS サーバーを設定している場合は、そのアドレスを指定してください (ここでは 139.96.30.0/24
)
subnet-mask
および routers
これらは、サブネットマスクとサブネット内で利用可能なルーターのリストを定義します。
また、routers
はクライアントに提供されるデフォルトゲートウェイも指定します。
小規模なネットワークでは、通常 255.255.255.0
をマスクとして使用し、dhcpd を実行しているマシンのIPアドレス(ここでは 139.96.30.100
) を指定できます。
subnet
dhcpd がリッスンしているネットワークインターフェースに適用される、個別のサブネットのオプションを定義します。
ここでは、単一のサブネット 139.96.30.0/24
(インターフェース eth0
) の利用可能な IP アドレスの範囲を定義しています。
詳細なオプションについては、dhcpd.conf(5) を参照してください。
PXE
Preboot Execution Environment (PXE) 設定は、次の2つのオプションで実行されます:
/etc/dhcpd.conf
next-server 192.168.0.2; filename "/pxelinux.0";
next-server
は TFTP サーバーのIPアドレスであり、filename
はブートするイメージを指定します。
このセクションは、subnet
全体に含めることも、特定の host
定義内に含めることもできます。
使用方法
dhcpd には dhcpd4.service
と dhcpd6.service
の2つのユニットファイルが含まれており、これらを使用してデーモンを制御できます。
これらのサービスは、それぞれ IPv4 および IPv6 用に すべての ネットワークインターフェース 上でデーモンを起動します。