wiki:TipAndDoc/network/dhcpd

Version 15 (modified by mitty, 13 years ago) (diff)

--

DHCPd

  • 標準はISC DHCPd
  • Ubuntuでは「udhcpd」という組み込み機器向け由来のDHCPdも選択できる。

logging

  • log-facility でsyslogへのログ出力を変更できる
  • Ubuntu:/etc/dhcp3/dhcpd.conf
    # 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;
    
  • syslog.conf
    local7.* -/var/log/dhcpd.log
    
  • CentOSでは、local7はデフォルトでbootログ用に使われているようなので、変えた方が良いかもしれない。
    • /etc/syslog.conf
      # Save boot messages also to boot.log
      local7.*                                                /var/log/boot.log
      
    • /var/log/boot.log
      Jul  1 16:43:03 VM-centos5 NET[3471]: /sbin/dhclient-script : updated /etc/resolv.conf
      Jul  1 16:43:08 VM-centos5 NET[3562]: /sbin/dhclient-script : updated /etc/resolv.conf
      Jul  1 16:47:13 VM-centos5 NET[3692]: /sbin/dhclient-script : updated /etc/resolv.conf
      (snip)
      

Ubuntu

  • aptitude install dhcp3-server
    • clientは標準ではdhcp3-client

configure

  • /etc/default/dhcp3-server
    # On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
    #       Separate multiple interfaces with spaces, e.g. "eth0 eth1".
    INTERFACES=""
    
    • ListenするIFを指定
  • /etc/dhcp3/dhcpd.conf についてはman dhcpd.conf

warning with dhcp3

CentOS

  • yum install dhcp
    • clientは標準ではdhclient

configure

  • /etc/sysconfig/dhcpd
    # Command line options here
    DHCPDARGS=
    
  • /etc/dhcpd.conf についてはman dhcpd.conf

searching multiple domains

  • setting the DNS search string

    option domain-search domain-list;

    This was added in 3.1.0.
    (snip)
    You can configure 'option domain-name "example.com sales.example.com";', and on many Unixish systems, this will become a 'search' string in /etc/resolv.conf. But it doesn't work as expected on many non-unixish systems (they parse the spaces as part of the domain name).

multiple domain-name on same subnet

  • Debian GNU/Linux 6.0.4 (squeeze)
  • ドメインはlocal.mitty.jpとdhcp.mitty.jp
    • local -> static assign
    • dhcp -> dynamic assign
  • host {...} で定義されたものがlocalに、それ以外はdhcpへ
  • /23のサブネットを用いて、localとdhcpで192.168.0.0と192.168.0.1に分ける
    • 普通に/24 x 2個のサブネットにしてしまうと、local<->dhcp間のデータがdefault routeで中継されてしまいうまくない
  • /etc/dhcp/dhcpd.conf
    ddns-update-style interim;
    
    option domain-name "dhcp.mitty.jp";
    option domain-name-servers 192.168.0.254;
    
    default-lease-time 172800;
    max-lease-time 2678400;
    
    authoritative;
    
    log-facility local7;
    
    subnet 192.168.0.0 netmask 255.255.254.0 {
    	option routers 192.168.0.254;
    	option ntp-servers 192.168.0.254;
    	option broadcast-address 192.168.0.255;
    	option domain-search "local.mitty.jp", "dhcp.mitty.jp";
    	
    	pool {
    		allow unknown-clients;
    		option domain-name "dhcp.mitty.jp";
    		range 192.168.1.100 192.168.1.199;
    		default-lease-time 7200;
    		max-lease-time 86400;
    		ddns-updates on;
    	}
    	
    	pool {
    		deny unknown-clients;
    		option domain-name "local.mitty.jp";
    		range 192.168.0.100 192.168.0.199;
    		ddns-updates off;
    	}
    	
    	include "/etc/dhcp/dhcpd.conf.d/local.mitty.jp";
    }
    
    • poolを使って、allow/deny unknown-clientsで選別する

      The unknown-clients flag is used to tell dhcpd whether or not to dynamically assign addresses to unknown clients. Dynamic address assignment to unknown clients is allowed by default. An unknown client is simply a client that has no host declaration.

  • /etc/dhcp/dhcpd.conf.d/local.mitty.jp
    (snip)
    
    host dhclient {
    	hardware ethernet 00:0C:29:73:3D:94;
    	fixed-address 192.168.0.250;
    }
    
  • /etc/bind/named.conf.local
    (snip)
    
    zone "local.mitty.jp" {
    	type master;
    	file "db.local.mitty.jp";
    };
    
    zone "0.168.192.in-addr.arpa" {
    	type master;
    	file "db.192.168.0";
    };
    
    zone "dhcp.mitty.jp" {
    	type master;
    	file "db.dhcp.mitty.jp";
    	allow-update {
    		127.0.0.1;
    		192.168.0.254;
    	};
    };
    
    zone "1.168.192.in-addr.arpa" {
    	type master;
    	file "db.192.168.1";
    	allow-update {
    		127.0.0.1;
    		192.168.0.254;
    	};
    };
    
    • 以下のファイルを適宜作っておく
      • /var/cache/bind/db.192.168.0
      • /var/cache/bind/db.192.168.1
      • /var/cache/bind/db.dhcp.mitty.jp
      • /var/cache/bind/db.local.mitty.jp

Attachments (5)

Download all attachments as: .zip