ISC DHCP
なんとなく、DHCPサーバをさわったのでメモ。
alaska: dhcpd ( ISC-DHCP 4.1.0 )
arizona: client ( dhcping )
arizona ( dhcping ) <--> alaska ( dhcpd )
- ISC-DHCP の設定
[root@alaska ~]# yum install -y dhcp.i586
ドキュメントは下記。サンプルコンフィグもある。
ldap用のスキーマもあるなー。
いつか、dhcp と ldap の連携テストしてみたいなー。いつか、、、いつかは、TBD..
[root@alaska ~]# ls /usr/share/doc/dhcp-4.1.0/*
/usr/share/doc/dhcp-4.1.0/3.0b1-lease-convert
/usr/share/doc/dhcp-4.1.0/IANA-arp-parameters
/usr/share/doc/dhcp-4.1.0/LICENSE
/usr/share/doc/dhcp-4.1.0/README
/usr/share/doc/dhcp-4.1.0/README.ldap
/usr/share/doc/dhcp-4.1.0/RELNOTES
/usr/share/doc/dhcp-4.1.0/References.txt
/usr/share/doc/dhcp-4.1.0/api+protocol
/usr/share/doc/dhcp-4.1.0/dhclient-tz-exithook.sh
/usr/share/doc/dhcp-4.1.0/dhcpd-conf-to-ldap
/usr/share/doc/dhcp-4.1.0/dhcpd.conf.sample
/usr/share/doc/dhcp-4.1.0/draft-ietf-dhc-ldap-schema-01.txt
/usr/share/doc/dhcp-4.1.0/sethostname.sh
/usr/share/doc/dhcp-4.1.0/solaris.init
/usr/share/doc/dhcp-4.1.0/ms2isc:
Registry.perlmodule ms2isc.pl readme.txt
サンプルコンフィグをもとに、dhcpd.conf を作成。
[root@alaska ~]# cp /usr/share/doc/dhcp-4.1.0/dhcpd.conf.sample /etc/dhcp/
[root@alaska ~]# cd /etc/dhcp/
[root@alaska dhcp]# mv dhcpd.conf org.dhcpd.conf
[root@alaska dhcp]# cp dhcpd.conf.sample dhcpd.conf
[root@alaska dhcp]# egrep -v "^#" /etc/dhcp/dhcpd.conf
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.1 10.0.0.100;
option domain-name-servers ns1.internal.example.org;
option domain-name "internal.example.org";
option routers 10.0.0.254;
option broadcast-address 10.0.0.255;
default-lease-time 600;
max-lease-time 7200;
}
起動
[root@alaska dhcp]# /etc/init.d/dhcpd start
dhcpd を起動中: [失敗]
エラーがでた。
No subnet declaration for eth0 (192.168.1.200).
eth0が 192.168.1.200 ( 192.168.1.0/24 ) なのに、subnet が 10.0.0.0 となっているから
いけないのかな。。
[root@alaska dhcp]# ifconfig eth0 | grep "1.200"
inet addr:192.168.1.200 Bcast:192.168.1.255 Mask:255.255.255.0
修正
- dhcpd.conf
#subnet 10.0.0.0 netmask 255.255.255.0 {
subnet 192.168.1.0 netmask 255.255.255.0 {
# range 10.0.0.1 10.0.0.100;
range 192.168.1.10 192.168.1.50;
# option domain-name-servers ns1.internal.example.org;
# option domain-name "internal.example.org";
# option routers 10.0.0.254;
option routers 192.168.1.254;
# option broadcast-address 10.0.0.255;
option broadcast-address 192.168.1.255;
default-lease-time 600;
max-lease-time 7200;
}
起動した。自分の属していないネットワークのレンジ書くのどうやるんだっけなー。。忘れた。。
ルータ越えで、dhcp relay とかやってるとき、自分の属していないネットワークレンジ書くだろうし。。
まぁ後でいいや。
- 動作確認
動作確認には、dhcping というのが便利!
[root@arizona ~]# yum install -y dhcping
dhcping - send a DHCP request to DHCP server to see if it’s up and running
SYNOPSIS
dhcping [-v] [-q] [-i] [-r] -t maxwait -c client-IP-address -s server-
IP-address -h client-hardware-address [-g gateway-IP-address]
gid ( gateway address ) も指定できる。
ではテスト。
あら、no answer
[root@arizona ~]# dhcping -v -s 192.168.1.200
no answer
dhcpd のログ。
んん?、not authoritative ...
alaska dhcpd: DHCPREQUEST for 0.0.0.0 from 00:00:00:00:00:00 via eth0: ignored (not authoritative)
dhcpingマシンのIP,H/W address を指定して、try again.
[root@arizona ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:1D:60:77:A1:38
inet addr:192.168.1.150 Bcast:192.168.1.255 Mask:255.255.255.0
unknown lease ってことは、range 外の IP ( i.e. 192.168.1.150 ) を要求しているってことかな。。
alaska dhcpd: DHCPREQUEST for 192.168.1.150 from 00:1d:60:77:a1:38 via eth0: unknown lease 192.168.1.150.
では、レンジ内のIPに変更。
[root@arizona ~]# dhcping -c 192.168.1.10 -h 00:1D:60:77:A1:38 -s 192.168.1.200
おっ、dhcpdが、DHCPACKかえした。
alaska dhcpd: DHCPREQUEST for 192.168.1.10 from 00:1d:60:77:a1:38 via eth0
alaska dhcpd: DHCPACK on 192.168.1.10 to 00:1d:60:77:a1:38 via eth0
-V を指定すると、詳細が表示される。
[root@arizona ~]# dhcping -V -c 192.168.1.10 -h 00:1D:60:77:A1:38 -s 192.168.1.200
setup
request
packet 250 bytes
01 01 06 00 06 61 78 4a 00 00 00 00 c0 a8 01 0a
00 00 00 00 00 00 00 00 00 00 00 00 00 1d 60 77
a1 38 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 63 82 53 63
35 01 03 32 04 c0 a8 01 0a ff
op: 1
htype: 1
hlen: 6
hops: 0
xid: 0661784a
secs: 0
flags: 0
ciaddr: 192.168.1.10
yiaddr: 0.0.0.0
siaddr: 0.0.0.0
giaddr: 0.0.0.0
chaddr: 00:1d:60:77:a1:38:00:00:00:00:00:00:00:00:00:00
sname : .
fname : .
option 53 DHCP message type
DHCP message type: 3 (DHCPREQUEST)
option 50 Request IP address
Requested IP address: 192.168.1.10
続きはまたいつか。。TBD...
Extremeの cynical かっこいいなー。リフがかっこいい。。
さすが、ぬ~の べってんこ~と。
とてもじゃないけど、弾けない。。。
cynical, all you need is love ...
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.