| はじめての自宅サーバ構築 - Fedora/CentOS - | Last Update | 2008/07/25 | |
| It opened to 2004/09/19. 当サイトはFedora9で運用しています |
Visitors Pageviews Today(IP/PV) |
3,374,122 12,762,141 1,280/8,763 |
# yum -y install dhcp |
![]() |
dhcpサービスでIPアドレスを固定付与する場合、NICのMACアドレスが必要になります |
デフォルトで設定ファイルが存在しないのでサンプルをリネームコピーします
設定ファイル(サンプル)のコピー
インストールバージョンで場所が異なる場合があります。「/usr/share/doc/dhcp-x.x.x」
# cp /usr/share/doc/dhcp-3.0.1rc14/dhcpd.conf.sample /etc/dhcpd.conf
設定ファイルの編集
# vi /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
サービス起動時のメッセージ(以下)を出力しない様にする
not authoritative;
----------------------------------- メッセージ -----------------------------------
May 17 18:32:59 fedora dhcpd: If this DHCP server is authoritative for that subnet,
May 17 18:32:59 fedora dhcpd: please write an `authoritative;' directive either in the
May 17 18:32:59 fedora dhcpd: subnet declaration or in some scope that encloses the
May 17 18:32:59 fedora dhcpd: subnet declaration - for example, write it at the top
May 17 18:32:59 fedora dhcpd: of the dhcpd.conf file.
------------------------------------------------------------------------------------
自分のネットワーク及びネットマスクを設定
subnet 192.168.1.0 netmask 255.255.255.0 {
# --- default gateway
デフォルトゲートウェイを設定(ルータのアドレス)
option routers 192.168.1.1;
ネットマスクを設定
option subnet-mask 255.255.255.0;
コメントにする
# option nis-domain "domain.org";
ドメイン名を設定
option domain-name "kajuhome.com";
ネームサーバのIPアドレスを設定(複数指定したい場合は「,」で区切る)
option domain-name-servers 192.168.1.5;
コメントにする
# option time-offset -18000; # Eastern Standard Time
# option ntp-servers 192.168.1.1;
# option netbios-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
# option netbios-node-type 2;
クライアントに割り当てるIPアドレスの範囲を指定(10〜19の10個を割り当てる)
range dynamic-bootp 192.168.1.10 192.168.1.19;
デフォルトリース時間(秒)
default-lease-time 21600;
最大リース時間(秒)
max-lease-time 43200;
ここから下は、特定のPCに固定のIPアドレスを割り当てたい時に指定します。
下記の例はクライアントホスト名"client1"のMACアドレス12:34:56:78:AB:CD;
にIPアドレス"192.168.1.10"を割り当てます。
# we want the nameserver to appear at a fixed address
host client1 {
コメントにする
# next-server marvin.redhat.com;
MACアドレスを設定する
hardware ethernet 12:34:56:78:AB:CD;
割り当てたいIPアドレスを設定する
fixed-address 192.168.1.10;
}
}
|
dhcpを起動する # /etc/rc.d/init.d/dhcpd start dhcpd を起動中: [ OK ] |
起動時にdhcpを起動する # chkconfig dhcpd on 設定内容を確認 # chkconfig --list dhcpd dhcpd 0:オフ 1:オフ 2:オン 3:オン 4:オン 5:オン 6:オフ |
『client1』よりWindowsのコマンドプロンプトを起動します 下記の「Connection-specific DNS Suffix」は、 DNSサーバの構築(BIND)を行なっている為、サーバ名が「kajuhome.com」になっています Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. IPアドレスの確認をします C:\Documents and Settings\client1>ipconfig /all Windows IP Configuration Ethernet adapter ローカル エリア接続: Connection-specific DNS Suffix . : kajuhome.com Description . . . . . . . . . . . : Intel(R) PRO/1000 Network Connection Physical Address. . . . . . . . . : 12-34-56-78-AB-CD Dhcp Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes IP Address. . . . . . . . . . . . : 192.168.1.10 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 DHCP Server . . . . . . . . . . . : 192.168.1.5 DNS Servers . . . . . . . . . . . : 192.168.1.5 Lease Obtained. . . . . . . . . . : 2005年7月14日 16:31:28 Lease Expires . . . . . . . . . . : 2005年7月14日 22:31:28 C:\Documents and Settings\client1> |
『client2』よりWindowsのコマンドプロンプトを起動します 下記の「Connection-specific DNS Suffix」は、 DNSサーバの構築(BIND)を行なっている為、サーバ名が「kajuhome.com」になっています Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. IPアドレスの確認をします C:\Documents and Settings\client2>ipconfig /all Windows IP Configuration Ethernet adapter ローカル エリア接続: Connection-specific DNS Suffix . : kajuhome.com Description . . . . . . . . . . . : AMD PCNET Family PCI Ethernet Adapter Physical Address. . . . . . . . . : 00-0C-xx-xx-xx-xx Dhcp Enabled. . . . . . . . . . . : Yes Autoconfiguration Enabled . . . . : Yes IP Address. . . . . . . . . . . . : 192.168.1.12 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 DHCP Server . . . . . . . . . . . : 192.168.1.5 DNS Servers . . . . . . . . . . . : 192.168.1.5 Lease Obtained. . . . . . . . . . : 2006年6月14日 15:04:12 Lease Expires . . . . . . . . . . : 2006年6月14日 21:04:12 C:\Documents and Settings\client2> |