Version 21 (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)
- /etc/syslog.conf
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
- Bug #39249 in dhcp3 (Ubuntu): “(Dapper, Hardy) can't create /var/lib/dhcp3/dhclient.eth0.leases: Permission denied”
- sudo chown dhcp:dhcp /var/lib/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).
- DNS クライアントでのドメイン サフィックス検索一覧の設定方法
DHCP (Dynamic Host Configuration Protocol)。ドメイン サフィックス検索一覧を送信するように DHCP を構成することはできません。これは DHCP プロトコル自体の制限であり、特定のベンダの DHCP 実装の制限によるものではありません。
- How to request domain-search option from DHCP server ?
I don't believe it's supported, because the DHCP server will only give an option if the option was requested by the DHCP client. So it appears that would need additional configuration on the client side such as the option.
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が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.
- include (host設定)をpoolの中に記述すること。globalのoption domain-name "dhcp.mitty.jp";が適用されてしまう
- poolを使って、allow/deny unknown-clientsで選別する
- /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; } host winxp2 { hardware ethernet 00:50:56:26:9b:1c; fixed-address 192.168.0.2; }
- /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
- 以下のファイルを適宜作っておく
test
- dhclient -> 00:0c:29:73:3d:94
- dhclient2 -> 00:50:56:25:13:28
- winxp -> 00:0c:29:f0:16:80
- winxp2 -> 00:50:56:26:9b:1c
- 上記/etc/dhcp/dhcpd.conf.d/local.mitty.jpの通り、dhclient, winxp2が設定されている
dhcpd
- mitty@dhcpd:~$ tailf /var/log/syslog
May 5 14:08:43 dhcpd dhcpd: DHCPDISCOVER from 00:0c:29:73:3d:94 via eth0 May 5 14:08:43 dhcpd dhcpd: DHCPOFFER on 192.168.0.250 to 00:0c:29:73:3d:94 via eth0 May 5 14:08:43 dhcpd dhcpd: DHCPREQUEST for 192.168.0.250 (192.168.0.254) from 00:0c:29:73:3d:94 via eth0 May 5 14:08:43 dhcpd dhcpd: DHCPACK on 192.168.0.250 to 00:0c:29:73:3d:94 via eth0 May 5 14:09:59 dhcpd dhcpd: DHCPDISCOVER from 00:50:56:25:13:28 via eth0 May 5 14:10:00 dhcpd dhcpd: DHCPOFFER on 192.168.1.100 to 00:50:56:25:13:28 via eth0 May 5 14:10:00 dhcpd dhcpd: DHCPREQUEST for 192.168.1.100 (192.168.0.254) from 00:50:56:25:13:28 via eth0 May 5 14:10:00 dhcpd dhcpd: DHCPACK on 192.168.1.100 to 00:50:56:25:13:28 via eth0 May 5 14:10:33 dhcpd dhcpd: DHCPDISCOVER from 00:0c:29:f0:16:80 via eth0 May 5 14:10:34 dhcpd dhcpd: DHCPOFFER on 192.168.1.101 to 00:0c:29:f0:16:80 (winxp) via eth0 May 5 14:10:34 dhcpd named[1098]: client 192.168.0.254#60107: updating zone 'dhcp.mitty.jp/IN': adding an RR at 'winxp.dhcp.mitty.jp' A May 5 14:10:34 dhcpd named[1098]: client 192.168.0.254#60107: updating zone 'dhcp.mitty.jp/IN': adding an RR at 'winxp.dhcp.mitty.jp' TXT May 5 14:10:34 dhcpd dhcpd: Added new forward map from winxp.dhcp.mitty.jp to 192.168.1.101 May 5 14:10:34 dhcpd named[1098]: client 192.168.0.254#41458: updating zone '1.168.192.in-addr.arpa/IN': deleting rrset at '101.1.168.192.in-addr.arpa' PTR May 5 14:10:34 dhcpd named[1098]: client 192.168.0.254#41458: updating zone '1.168.192.in-addr.arpa/IN': adding an RR at '101.1.168.192.in-addr.arpa' PTR May 5 14:10:34 dhcpd dhcpd: added reverse map from 101.1.168.192.in-addr.arpa. to winxp.dhcp.mitty.jp May 5 14:10:34 dhcpd dhcpd: DHCPREQUEST for 192.168.1.101 (192.168.0.254) from 00:0c:29:f0:16:80 (winxp) via eth0 May 5 14:10:34 dhcpd dhcpd: DHCPACK on 192.168.1.101 to 00:0c:29:f0:16:80 (winxp) via eth0 May 5 14:13:23 dhcpd dhcpd: DHCPDISCOVER from 00:50:56:26:9b:1c via eth0 May 5 14:13:23 dhcpd dhcpd: DHCPOFFER on 192.168.0.2 to 00:50:56:26:9b:1c via eth0 May 5 14:13:23 dhcpd dhcpd: DHCPREQUEST for 192.168.0.2 (192.168.0.254) from 00:50:56:26:9b:1c via eth0 May 5 14:13:23 dhcpd dhcpd: DHCPACK on 192.168.0.2 to 00:50:56:26:9b:1c via eth0
dhclient
- -> local.mitty.jp
- @dhcpd:~$ ssh 192.168.0.250
- @dhclient:~$ cat /etc/resolv.conf
domain local.mitty.jp search local.mitty.jp local.mitty.jp. dhcp.mitty.jp. nameserver 192.168.0.254
- @dhclient:~$ /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:73:3d:94 inet addr:192.168.0.250 Bcast:192.168.0.255 Mask:255.255.254.0 (snip)
- @dhclient:~$ ip route
192.168.0.0/23 dev eth0 proto kernel scope link src 192.168.0.250 default via 192.168.0.254 dev eth0
- @dhclient:~$ ping winxp
PING winxp.dhcp.mitty.jp (192.168.1.101) 56(84) bytes of data. 64 bytes from winxp.dhcp.mitty.jp (192.168.1.101): icmp_req=1 ttl=128 time=3.98 ms 64 bytes from winxp.dhcp.mitty.jp (192.168.1.101): icmp_req=2 ttl=128 time=0.471 ms 64 bytes from winxp.dhcp.mitty.jp (192.168.1.101): icmp_req=3 ttl=128 time=0.353 ms ^C (snip)
dhclient2
- -> dhcp.mitty.jp
- @dhcpd:~$ ssh 192.168.1.100
- @dhclient2:~$ cat /etc/resolv.conf
domain dhcp.mitty.jp search dhcp.mitty.jp local.mitty.jp. dhcp.mitty.jp. nameserver 192.168.0.254
- @dhclient2:~$ /sbin/ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:25:13:28 inet addr:192.168.1.100 Bcast:192.168.0.255 Mask:255.255.254.0 (snip)
- @dhclient2:~$ ip route
192.168.0.0/23 dev eth0 proto kernel scope link src 192.168.1.100 default via 192.168.0.254 dev eth0
- @dhclient2:~$ ping dhclient
PING dhclient.local.mitty.jp (192.168.0.250) 56(84) bytes of data. 64 bytes from dhclient.local.mitty.jp (192.168.0.250): icmp_req=1 ttl=64 time=0.928 ms ^C (snip)
Windows
multiple subnet with multiple interfaces
- dhcp server on multiple interfaces.
- DHCPD and Assigning Subnets to Different Interfaces
- |ubuntu| Multiple interfaces, multi network DHCP server - Ubuntu Forums
- dhcpd: Interface eth0 matches multiple shared networks « そこはかと
IPエイリアスで別サブネットのIPアドレスを持たせているサーバーでdhcpdを動かしたい場合、下記のように単純にsubnetを1つ増やすだけではdhcpdからInterface eth0 matches multiple shared networksと怒られる。 そんな時はshared-network宣言で囲うといい。
Attachments (5)
- winxp.png (45.2 KB) - added by mitty 13 years ago.
- winxp2.png (45.3 KB) - added by mitty 13 years ago.
- winxp-ping-fail.png (46.1 KB) - added by mitty 13 years ago.
- winxp2-ping.png (48.1 KB) - added by mitty 13 years ago.
- tcp-ip_conf.png (62.1 KB) - added by mitty 13 years ago.
Download all attachments as: .zip