• ホーム
  • サーバ
  • ISC DHCPサーバ
  • 設定ファイル
  • ISC DHCP設定ファイル

    /etc/dhcpd.conf
    
    ※インストール時にはこのファイルは無いので、ソースファイルの中のサンプルファイルをコピーする
    cd /opt/src/dhcp-3.0.3/server/		(ソースファイルの中のserverの中)
    cp dhcpd.conf /etc/dhcpd.conf
    
    ■中身
    (server-identifier eri0.dhcp.example.com;	DHCP サーバの正式インターフェース名称)無くてもよさそう
    server-name "dhcp.example.jp";		このサーバのFQDN(完全修飾ドメイン名) 必須ではない
    					クライアントにも通知される名前(IP又はドメイン名)
    next-server サーバ名;			初期ブートファイル (filename 文で指定したもの) をロードする
    					サーバのホストアドレスを指定(IP又はドメイン名)
    					端末よっては、このパラメータが無い場合server-nameを参照するかもしれない
    ddns-update-style none;			DHCPサーバでDDNSを使用する(interim)か使用しない(none)か
    log-facility local0;			syslogのファシリティを指定。指定しない場合はdaemon
    					(syslog.confにlocal0.info /logfile を記載すること)
    option time-offset 32400;			日本なら世界標準時間+9時間
    
    ########## 以下サブネットごとの設定 ##########
    ########## subnetステートメントは複数記述することで、複数のサブネットに対応できる##########
    subnet 192.168.0.0 netmask 255.255.255.0 {	ネットワーク部とネットマスクを書く
        range 192.168.0.100 192.168.0.132;		クライアントに提供するIPアドレスの範囲を書く
        range 192.168.0.150 192.168.0.200;		複数アドレスプールの指定も可能
        range 192.168.1.10 192.168.5.254;		こんな風にIPを続けた書き方も可能
        option broadcast-address 192.168.0.255;	クライアントに与えるブロードキャストアドレス指定
        option routers 192.168.0.1;		デフォルトルータのアドレスを指定する
        option subnet-mask 255.255.255.0;		クライアントに与えるサブネットマスクを指定
        option domain-name "example.com";		所属するドメイン名
        option domain-name-servers 192.168.1.1,192.168.1.2;		DNSサーバ
        default-lease-time 3600;			標準(クライアントが指定しない場合)のIP貸し出し時間(秒)
        max-lease-time 7200;			最大のIP貸し出し時間
    
    }
        host koteiPC1 {			その他 指定したMACアドレスにのみIPを割り当てる
            hardware ethernet 00:A0:B0:0A:8C:C3;	(固定IPアドレスをリースする)
            fixed-address 192.168.0.99;		カンマで複数IPの指定も可能
        }
    
    ※重要※ 自分(DHCPサーバ)が属するネットワークの設定を持っている必要がある為、以下を指定する
    subnet 192.168.1.0 netmask 255.255.255.0 {	自分の属するネットワークインタフェース用の設定
    	not authoritative;			DHCPを提供しない(提供する場合は普通に記入する)
    }
    
    □その他
        filename "file1";	ブート時適応させるファイル(ネットワークブートPXEサーバ(DHCPとTFTP))
    
      substring		substring (評価対象, どこから, どこまでか(何バイトまでか)) 
      deny booting		クライアントからのクエリに答えない
      hardware		ハードウェアタイプ及びリンク層アドレスを返す
    	イーサネットは01です。よってMACアドレスの場合は、01:FF:FF:FF:FF:FF:FFのようになる
    	つまり下記例の場合substring(hardware,1,2)とする理由は、0,1としてしまうと
    	ハードウェアタイプの01とMACの00という意味になるため、含めるなら次のようにします
    	if substring(hardware,0,2) = 01:00:12 {
      (例)
        if substring(hardware,1,2) = 00:FF {	00:FFから始まるMACアドレスからの要求を拒否
            deny booting;
        }
    
    
    
    ■スコープ(グループ、設定の有効範囲)について
    例
    全体のスコープ(グローバルスコープ)
    ...
    subnet ... {
    	サブネット1のスコープ
    	...
    	...
    	host ... {
    		ホスト1のスコープ
    		...
    	}
    }
    
    上記の場合、優先度は高い順に「ホスト1」←「サブネット1」←「全体」
    同じ設定がある場合は、最も内側のスコープの設定が適応される(パラメータのオーバーライドという)
    
    また設定範囲を任意に作成したい場合は、以下のgroupやshared-networkステートメントを使用します
    group{
    	ステートメント;
    	...
    }
    又は
    shared-network testname {
    	subnet ... {
    	}
    	subnet ... {
    	}
    }
    groupとの違いはshared-networkで指定した共有ネットワーク名が、ログ出力の際に使用される所
    
    
    
    ※複数のネットワークのDHCPサーバになる場合、DHCPリレーエージェントからDHCPDiscoverが中継されることになる。
     その場合はDHCPリレーエージェントと同一のネットワークのIPアドレスを返す。 
    
    ※DNSへの正引き、逆引き登録をしておくこと
    
    ※設定変更後は一度killを行ってから有効になる。 ※※※ISC DHCPはkill -HUPが使えない 
    
    
    
    ■ログのカスタマイズ
    参考(条件付評価)
    http://linuxjm.sourceforge.jp/html/dhcp/man5/dhcp-eval.5.html
    追加ログ設定する
    log(priority, data-expr)	ログに書き出したいデータをsyslogへ追加する
    	priority	fatal, error, info, debug で指定(省略可能)
    	data-expr		データ式。ここに書いた式の結果がログに出力される
    			複数のデータ値を出力したい場合は、concatで連結させる事
    
    suffix (hardware,6)	suffix(評価対象,後ろから指定バイト分) 
    cancat(内容1,内容2,・・・)	内容が式なら実行結果を、"文字列"ならそのままで、文字が連結される
    leased-address		そのクライアントにIPが割り当て済みの場合、そのIPアドレスが入る
    binary-to-ascii (numeric-expr1, numeric-expr2, data-expr1, data-expr2)  評価対象を指定した基数のテキストに変換
    	numeric-expr1	基数-何進数に変換するか。普通は10進数か16進数(2〜16で指定)
    	numeric-expr2	数値のビット幅。普通は8bit(8か16か32で指定)
    	data-expr1	区切り文字
    	data-expr2	評価対象
    
    
    
    
    設定例
    ddns-update-style none; option domain-name "dhcp.example.com"; option domain-name-servers 192.168.1.1; subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.2 192.168.1.99; option broadcast-address 192.168.1.255; option routers 192.168.1.1; option subnet-mask 255.255.255.0; option domain-name "example.com"; option domain-name-servers 192.168.1.1; default-lease-time 600; max-lease-time 7200; }
    デフォルトの中身
    -------------------------------------------------------------------------------------------------- # dhcpd.conf # # Sample configuration file for ISC dhcpd # # option definitions common to all supported networks... option domain-name "example.org"; option domain-name-servers ns1.example.org, ns2.example.org; default-lease-time 600; max-lease-time 7200; # If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. #authoritative; # Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7; # No service will be given on this subnet, but declaring it helps the # DHCP server to understand the network topology. subnet 10.152.187.0 netmask 255.255.255.0 { } # This is a very basic subnet declaration. subnet 10.254.239.0 netmask 255.255.255.224 { range 10.254.239.10 10.254.239.20; option routers rtr-239-0-1.example.org, rtr-239-0-2.example.org; } # This declaration allows BOOTP clients to get dynamic addresses, # which we don't really recommend. subnet 10.254.239.32 netmask 255.255.255.224 { range dynamic-bootp 10.254.239.40 10.254.239.60; option broadcast-address 10.254.239.31; option routers rtr-239-32-1.example.org; } # A slightly different configuration for an internal subnet. subnet 10.5.5.0 netmask 255.255.255.224 { range 10.5.5.26 10.5.5.30; option domain-name-servers ns1.internal.example.org; option domain-name "internal.example.org"; option routers 10.5.5.1; option broadcast-address 10.5.5.31; default-lease-time 600; max-lease-time 7200; } # Hosts which require special configuration options can be listed in # host statements. If no address is specified, the address will be # allocated dynamically (if possible), but the host-specific information # will still come from the host declaration. host passacaglia { hardware ethernet 0:0:c0:5d:bd:95; filename "vmunix.passacaglia"; server-name "toccata.fugue.com"; } # Fixed IP addresses can also be specified for hosts. These addresses # should not also be listed as being available for dynamic assignment. # Hosts for which fixed IP addresses have been specified can boot using # BOOTP or DHCP. Hosts for which no fixed address is specified can only # be booted with DHCP, unless there is an address range on the subnet # to which a BOOTP client is connected which has the dynamic-bootp flag # set. host fantasia { hardware ethernet 08:00:07:26:c0:a5; fixed-address fantasia.fugue.com; } # You can declare a class of clients and then do address allocation # based on that. The example below shows a case where all clients # in a certain class get addresses on the 10.17.224/24 subnet, and all # other clients get addresses on the 10.0.29/24 subnet. class "foo" { match if substring (option vendor-class-identifier, 0, 4) = "SUNW"; } shared-network 224-29 { subnet 10.17.224.0 netmask 255.255.255.0 { option routers rtr-224.example.org; } subnet 10.0.29.0 netmask 255.255.255.0 { option routers rtr-29.example.org; } pool { allow members of "foo"; range 10.17.224.10 10.17.224.250; } pool { deny members of "foo"; range 10.0.29.10 10.0.29.230; } } #

    前へ  トップへ inserted by FC2 system