====== 07 DHCPD ====== ISC-DHCPを使いDHCPサーバを立ててみる ====== portsから ====== # cd /usr/ports/net/isc-dhcp3-server # make install clean # cp /usr/local/etc/dhcpd.conf.sample /usr/local/etc/dhcpd.conf # chmod 644 /usr/local/etc/dhcpd.conf ====== ソースを持ってくる ====== ISC http://www.isc.org より最新のtarballをダウンロードする。 最新はdhcp-3.0.2.tar.gz(2005年6月25日現在) > wget ftp://ftp.isc.org/isc/dhcp/dhcp-3.0.2.tar.gz ====== ソースの展開 ====== > tar zxvf dhcp-3.0.2.tar.gz ====== インストール ====== > cd ./dhcp-3.0.2.tar.gz > make > su # make install ====== 設定ファイルを編集 ====== ▼設定例 # dhcpd.conf # Dominio. option domain-name "mydomain.co.jp"; # Servidores DNS. option domain-name-servers 192.168.1.1, 210.147.240.193; # Servidores WINS. # Descomentar caso utilizado. #option netbios-name-servers 10.10.0.9; # Tempo padrao de alocacao em segundos. # Se o cliente nao especificar nenhum periodo de tempo # sera atribuido este. default-lease-time 600; # Tempo maximo de alocacao em segundos. # Tempo maximo que o cliente podera alocar o IP. # Apos isso deve renovar a alocacao. max-lease-time 7200; # Nao tentar atualizar o DNS. ddns-update-style none; # Caso este servidor nao seja o oficial para esta rede o # parametro abaixo devera ser comentado. authoritative; # O log eh feito pelo syslog. log-facility local6; # Declaracao de Subrede. subnet 192.168.1.0 netmask 255.255.255.0 { # Faixa de IPs disponiveis para alocar. range 192.168.1.11 192.168.1.20; # Gateway. option routers 192.168.1.1; } host ThinkPad { hardware ethernet 00:05:4E:45:58:04; fixed-address 192.168.1.20; } host ValueStar{ hardware ethernet 00:90:96:1B:83:FA; fixed-address 192.168.1.15; } host Dynabook{ hardware ethernet 00:90:CC:6C:97:0D; fixed-address 192.168.1.11; } ====== シェルを用意する/usr/local/etc/rc.d/dhcpd.sh ====== #!/bin/sh case "$1" in start) touch /var/db/dhcpd.leases /usr/sbin/dhcpd rl0 /sbin/route add -host 255.255.255.255 -iface rl0 ;; stop) /sbin/route delete -host 255.255.255.255 -iface rl0 pid=`ps -acx | grep " dhcpd" | awk '{print $1}'` kill ${pid} ;; *) echo "Usage: `basename $0` {start|stop}" >&2 ;; esac exit 0 ====== リース情報ログファイルを作成 ====== # touch /var/db/dhcpd.leases ====== 起動する ====== ▼設定が完了したら起動する # /usr/local/etc/rc.d/dhcp.sh start {{tag>dhcp}}