Linux導入・サーバ構築備忘録
DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築DHCPサーバ構築

2−1.DHCPサーバ構築

前提:RedHatLinux8.0に含まれるdhcp-3.0pl1-26(Update済み)

とりあえずDHCPサーバを構築する人はここをクリックしましょう!

DHCPサーバ構築コマンドの説明だワン!

プログラム名 dhcp - Dynamic Host Configuration Protocol Server
コマンド概要 dhcp   [ -p port ][ -f ][ -d ][ -q ][ -t | -T ][ -cf config-file ]
[ -lf lease-file ][ -tf trace-output-file ][ -play trace-playback-
file ][ if0 [ ...ifN ] ]
オプション説明 -p ポートの指定(標準は67番ポートを使用)
-f dhcpdをフォアグランドで実行する(デバッグなどで使用)
-d デバッグ用フラグ,全てのアクティブログが収集できる
-q コピーライトメッセージを表示しないようにする
-t | -T -t:構成ファイルのテスト/-T:leaseデータベースファイルのテスト
-cf 構成ファイル指定
-lf leaseファイル指定
-tf サーバダンプファイル指定
-play ダンプファイルのプレーバック,leaseファイルは-lfで指定すること
if0..ifN dhcpdサーバを提供するインターフェースを指定 例)eth0など

dhcpdサーバ起動には/var/lib/dhcpにdhcpd.leasesファイルが必要です。
最近のRedHatはrpmで導入と同時にleasesファイルが作成されるようなので意識する必要は無いようですが、ソースファイルからコンパイルした場合はleasesファイルを忘れずに作成する必要があります。
作成例)
 $cd /var/lib/dhcp
 $touch dhcpd.leases

DHCPサーバ構築dhcpd.leasesの説明をするだワン!

ファイル名 dhcpd.leases - DHCP client lease database
ファイル概要 lease ip-address { statements.... }
ip-address: クライアントにリースしたIPアドレス
statement説明 starts date; リースの開始時間
ends date; リースの終了時間
tstp date; フェイルオーバーで使用 時間切れ日時
tsfp date; フェイルオーバーで使用 時間切れ認定日時
  date
weekday year/month/day hour:minutes:second
weekday 0-6   0:sunday - 6:saturday
hardware hardware-type
 mac-address;
ネットワークインターフェースとMACアドレス
hardware-type: ethernet
mac-address: XX:XX:XX:XX:XX:XX
uid client-identifier; クライアントのユーザID記録
client-hostname hostname; クライアントのホスト名
abandoned; サーバが捨てたリース 再割当可能状態
binding state state;
next binding state state;
リースBinding状況
state: active / free / backup
option agent.circuit-id
 string;
option agent.remote-id
 string;
circuitIDとremoteIDの記録
DHCPサーバ構築leaseファイルについては基本的な部分だけ説明しただワン!
 さらに詳細を知りたい人はman dhcpd.leasesで調べてみるだワン!

DHCPサーバ構築dhcpd.confの説明をするだワン!

宣言文 ステートメント
shared-network shared-network name {
  [ parameters ]
  [ declarations ]
}
共有ネットワーク定義
nameは任意の名前を設定
例)
shared-network TESTNET {
  [ parameters ]
  [ declarations ]
}
subnet subnet subnet-number netmask netmask {
  [ parameters ]
  [ declarations ]
}
サブネットを定義
subnet-numberはサブネットアドレスを設定
netmaskはネットワークマスクを設定
例)
subnet 192.168.0.0 netmask 255.255.255.0 {
  [ parameters ]
  [ declarations ]
}
range range [ dynamic-bootp ] low-address [ high-address ];
動的に割当てるアドレスレンジを定義
low-addressは割当開始アドレス
high-addressは割当終了アドレス
例)
range 192.168.0.1 192.168.0.99;
host host hostname {
  [ parameters ]
  [ declarations ]
}
ホスト名を定義
hostnameはクライアントのホスト名
例)
host client01 {
  [ parameters ]
  [ declarations ]
}
group group {
  [ parameters ]
  [ declarations ]
}
定義のグルーピングをする
キーワード
unknown-clients allow unknown-clients;
deny unknown-clients;
ignore unknown-clients;
Unknown-clientについての振る舞いを定義する
bootp allow bootp;
deny bootp;
ignore bootp;
bootpについての振る舞いを定義する
booting allow booting;
dent booting;
ignore booting;
bootingについての振る舞いを定義する
duplicates allow duplicates;
deny duplicates;
duplicateについての振る舞いを定義する
declines allow declines;
deny declines;
ignore declines;
declineについての振る舞いを定義する
client-updates allow client-updates;
deny client-updates;
client-updateについての振る舞いを定義する
ただし、interim DNS updateの時だけ有効になります
パラメータ ステートメント
always-broadcast always-broadcast flag;
DHCPとBOOTPの両プロトコルの要求に対するブロードキャストフラグを定義
flag: on
always-reply-frc1048 always-reply-rfc1048 flag;
RFC1048の要求に対する定義
flag: on
authoritative authoritative; / not authoritative;
信頼性の定義
authoritativeに設定すると間違った構成のclientに対してDHCPNAKを返す
boot-unknown-clients boot-unknown-clients flag;
 
ddns-hostname ddns-hostname name;
 
ddns-domainname ddns-domainname name;
 
ddns-rev-domainname ddns-rev-domainname name;
 
ddns-update-style ddns-update-style style;
 
ddns-updates ddns-updates flag;
 
default-lease-time default-lease-time time;
 
dynamic-bootp-lease-cutoff dynamic-bootp-lease-cutoff date;
 
dynamic-bootp-lease-length dynamic-bootp-lease-length length;
 
filename filename "filename";
 
fixed-address fixed-address address [, address ... ];
 
get-lease-hostnames get-lease-hostnames flag;
 
hardware hardware hardware-type hardware-address;
 
lease-file-name lease-file-name name;
 
local-port local-port port;
 
log-facility log-facility facility;
 
max-lease-time max-lease-time time;
 
min-lease-time min-lease-time time;
 
min-secs min-secs seconds;
 
next-server next-server server-name;
 
omapi-port omapi-port port;
 
one-lease-per-client one-lease-per-client flag;
 
pid-file-name pid-file-name name;
 
ping-check ping-check flag;
 
server-identifier server-identifier hostname;
 
server-name server-name name;
 
site-option-space site-option-space name;
 
stash-agent-options atash-agent-options flag;
 
update-optimization update-optimization flag;
 
update-static-leases update-static-leases flag;
 
use-host-decl-names use-host-decl-names flag;
 
use-lease-addr-for-default
-route
use-lease-addr-for-default-route flag;
 
vendor-option-space vendor-option-space string;
 
オプション ステートメント
all-subnets-local option all-subnets-local flag;
 
arp-cache-timeout option arp-cache-timeout uint32;
 
bootfile-name option bootfile-name text;
 
boot-size option boot-size uint16;
 
broadcast-address option broadcast-address ip-address;
 
cookie-servers option cookie-servers ip-address [, ip-address... ];
 
default-ip-ttl option default-ip-ttl uint8;
 
default-tcp-ttl option default-tcp-ttl uint8;
 
dhcp-client-identifier option dhcp-client-identifier string;
 
dhcp-max-messafe-size option dhcp-max-mesage-size uint16;
 
dhcp-parameter-request-list option dhcp-parameter-request-list uint16;
 
domain-name option domain-name text;
 
domain-name-servers option domain-name-servers ip-address [, ip-address...];
 
extensions-path-name option extensions-path-name text;
 
finger-server option finger-server ip-address [, ip-address... ];
 
font-servers option font-servers ip-address [, ip-address... ];
 
host-name option host-name string;
 
ieee802-3-encapsulation option ieee802-3-encapsulation flag;
 
ien116-name-servers option ien116-name-servers ip-address [, ip-address... ];
 
impress-servers option impress-servers ip-address [, ip-address... ];
 
interface-mtu option interface-mtu uint16;
 
ip-forwarding option ip-forwarding flag;
 
irc-server option irc-server ip-address [, ip-address... ];
 
log-servers option log-servers ip-address [, ip-address... ];
 
lpr-servers option lpr-servers ip-address [, ip-address... ];
 
mask-supplier option mask-supplier flag;
 
max-dgram-reassembly option max-dgram-reassembly uint16;
 
merit-dump option merit-dump text;
 
mobile-ip-home-agent option mobile-ip-home-agent ip-address [, ip-address.. ];
 
nds-servers option nds-servers ip-address [, ip-address... ];
 
nds-context option nds-context string;
 
nds-tree-name option nds-tree-name string;
 
netbios-dd-server option netbios-dd-server ip-address [, ip-address... ];
 
netbios-name-servers option netbios-name-servers ip-address [, ip-address.. ];
 
netbios-node-type option netbios-node-type uint8;
 
netbios-scope option netbios-scope string;
 
nwip-domain option nwip-domain string;
 
nwip-suboptions option nwip-suboptions string;
 
nis-domain option nis-domain text;
 
nis-servers option nis-servers ip-address [, ip-address... ];
 
nisplus-domain option nisplus-domain text;
 
nisplus-servers option nisplus-servers ip-address [, ip-address... ];
 
nntp-server option nntp-server ip-address [, ip-address... ];
 
non-local-source-routing option non-local-source-routing flag;
 
ntp-servers option ntp-servers ip-address [, ip-address... ];
 
path-mtu-plateau-table option path-mtu-plateau-table uint16 [, uint16... ];
 
perform-mask-discovery option perform-mask-discovery flag;
 
policy-filter option policy-filter ip-address ip-address
  [, ip-address ip-address... ];
 
pop-server option pop-server ip-address [, ip-address... ];
 
resource-location-servers option resource-location-servers ip-address
  [, ip-address... ];
 
root-path option root-path text;
 
router-discovery option router-discovery flag;
 
router-solicitation-address option router-solicitation-address ip-address;
 
routers option routers ip-address [, ip-address... ];
 
slp-directory-agent option slp-directory-agent boolean ip-address
  [, ip-address... ];
 
slp-service-scope option slp-service-scope boolean text;
 
smtp-server option smtp-server ip-address [, ip-address... ];
 
static-routes option static-routes ip-address ip-address
  [, ip-address ip-address... ];
 
streettalk-directory-
assistance-server
option streettalk-directory-assistance-server ip-address
  [, ip-address... ];
 
streettalk-server option streettalk-server ip-address [, ip-address... ];
 
subnet-mask option subnet-mask ip-address;
 
swap-server option swap-server ip-address;
 
tcp-keepalive-garbage option tcp-keepalive-garbage flag;
 
tcp-keepalive-interval option tcp-keepalive-interval uint32;
 
tftp-server-name option tftp-server-name text;
 
time-offset option time-offset int32;
 
time-servers option ip-address [, ip-address... ];
 
trailer-encapsulation option trailer-encapsulation flag;
 
uap-servers option uap-servers text;
 
user-class option user-class string;
 
vendor-class-identifier option vendor-class-identifier string;
 
vendor-encapsulated-options option vendor-encapsulated-options string;
 
x-display-manager option x-display-manager ip-address [, ip-address... ];
 
www-server option www-server ip-address [, ip-address... ];
 
DHCPサーバ構築dhcpd.confファイルについての標準的なものを列記してみただワン!
 さらに詳しく知りたい人はman dhcpd.confまたはman dhcp.optionsを参照するだワン!


これより先は実際にDHCPサーバの構成例を紹介します

/etc/dhcpd.confの内容:

subnet 192.168.0.0 netmask 255.255.255.0 {
option subnet-mask 255.255.255.0;
default-lease-time 21600;
max-lease-time 43200;
option time-offset 32400;
option domain-name-servers 192.168.1.1;
option routers 192.168.0.1;
range 192.168.0.50 192.168.0.59;
}

上記設定で基本的なDHCPサーバは稼動します

DHCPサーバの起動
 $/etc/rc.d/init.d/dhcpd start

DHCPには多くの設定があり一つ一つ紹介していくと気が遠くなりそうなほどあります。
一部LINUX備忘録にもDHCPサーバを立てて構成を公開しています。
アイデア次第でいろいろな使い道があると思いますのでTRYしてみてください。

DHCPサーバ構築健闘を祈るだワン!

上記Statementの説明は随時Updateしていく予定です。


戻る
DHCPサーバ構築