まず、インスールされているバージョンを確認してみます。
| # rpm -qa | grep dhcp dhcp-3.0.5-29.el5_7.1 |
設定ファイルは/etc/dhcpd.confなのですが、/etcにはファイルがありませんのでサンプルファイルをコピーします。
| # cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf |
次にファイルを編集します。想定しているネットワークは以下のとおりです。
| ネットワーク | 192.168.1.0 |
|---|---|
| サブネットマスク | 255.255.255.0 |
| デフォルトゲートウェイ | 192.168.1.1 |
| DNSサーバ | 192.168.1.1 |
| ドメイン名 | localdomain |
| DHCPレンジ | 192.168.1.200-192.168.1.220 |
上記の内容に沿ってファイルを編集します。
| # vi /etc/dhcpd.conf ddns-update-style interim; ignore client-updates; subnet 192.168.1.0 netmask 255.255.255.0 { ←環境に合わせて変更 # --- default gateway option routers 192.168.1.1; ←環境に合わせて変更 option subnet-mask 255.255.255.0; ←環境に合わせて変更 option nis-domain "localdomain"; ←環境に合わせて変更 option domain-name "localdomain"; ←環境に合わせて変更 option domain-name-servers 192.168.1.1; ←環境に合わせて変更 option time-offset -18000; # Eastern Standard Time option ntp-servers 192.168.1.1; # option netbios-name-servers 192.168.1.1; # --- Selects point-to-point node (default is hybrid). Don't change this unless # -- you understand Netbios very well # option netbios-node-type 2; range dynamic-bootp 192.168.1.201 192.168.1.220; ←環境に合わせて変更 default-lease-time 21600; max-lease-time 43200; # we want the nameserver to appear at a fixed address # host ns { ←MACアドレスで固定IPを振りたいときに設定(今回はコメントアウト) # next-server marvin.redhat.com; # hardware ethernet 12:34:56:78:AB:CD; # fixed-address 207.175.42.254; # } } |
| # service dhcpd start dhcpd を起動中: [ OK ] |
OS起動時に自動起動にします。
さて、この設定だとクライアントがIPアドレスを取得まで10数秒ほどかかってしまいました。ログ(/var/log/messages)を見ると「not authoritative」とか「not authorized」とか表示されていました。
| # chkconfig dhcpd on |
さて、この設定だとクライアントがIPアドレスを取得まで10数秒ほどかかってしまいました。ログ(/var/log/messages)を見ると「not authoritative」とか「not authorized」とか表示されていました。
| # cat/var/log/messages Nov 8 15:43:25 cent57 dhcpd: DHCPREQUEST for 172.16.111.157 from f0:4d:a2:aa:13:92 via eth0: ignored (not authoritative). Nov 8 15:44:04 cent57 dhcpd: DHCPREQUEST for 172.16.111.157 from f0:4d:a2:aa:13:92 via eth0: ignored (not authoritative). Nov 8 15:44:29 cent57 dhcpd: DHCPDISCOVER from f0:4d:a2:aa:13:92 (COMPUTER-01) via eth0 Nov 8 15:44:30 cent57 dhcpd: DHCPOFFER on 192.168.1.220 to f0:4d:a2:aa:13:92 (COMPUTER-01) via eth0 Nov 8 15:44:30 cent57 dhcpd: Unable to add forward map from COMPUTER-01.localdomain to 192.168.1.220: not authorized Nov 8 15:44:30 cent57 dhcpd: DHCPREQUEST for 192.168.1.220 (192.168.1.1) from f0:4d:a2:aa:13:92 (COMPUTER-01) via eth0 Nov 8 15:44:30 cent57 dhcpd: DHCPACK on 192.168.1.220 to f0:4d:a2:aa:13:92 (COMPUTER-01) via eth0 Nov 8 15:44:33 cent57 dhcpd: DHCPINFORM from 192.168.1.220 via eth0: not authoritative for subnet 192.168.1.0 Nov 8 15:44:36 cent57 dhcpd: DHCPINFORM from 192.168.1.220 via eth0: not authoritative for subnet 192.168.1.0 |
調べてみると、権威のないDHCPサーバになっているようです。そこで、192.168.1.0については権威がある宣言をします。具体的には、dhcpd.confのsubnetセクション内に「authoritative;」と追記します。
| # cat /etc/dhcpd.conf ddns-update-style interim; ignore client-updates; subnet 192.168.1.0 netmask 255.255.255.0 { authoritative; ←これを追記 # --- default gateway option routers 192.168.1.1; option subnet-mask 255.255.255.0; option nis-domain "localdomain"; option domain-name "localdomain"; option domain-name-servers 192.168.1.1; option time-offset -18000; # Eastern Standard Time option ntp-servers 192.168.1.1; # option netbios-name-servers 192.168.1.1; # --- Selects point-to-point node (default is hybrid). Don't change this unless # -- you understand Netbios very well # option netbios-node-type 2; range dynamic-bootp 192.168.1.201 192.168.1.220; default-lease-time 21600; max-lease-time 43200; # we want the nameserver to appear at a fixed address # host ns { # next-server marvin.redhat.com; # hardware ethernet 12:34:56:78:AB:CD; # fixed-address 207.175.42.254; # } } |
これで「not authoritative」のワーニングは表示されなくなり、IPアドレスの取得時間も早くなりました!