はじめての自宅サーバ構築 - Fedora/CentOS -
Last Update 2010/03/09
[ 更新履歴 ] [ サイト マップ ] [ 質問掲示板 ] [ 雑談掲示板 ] [ 接続機器評価掲示板 ] [ リンク(3) (1) ]
トップ >> DNSサーバ & DHCPサーバ >> DHCPサーバの構築(DHCP)
動作確認 [ FC1 / FC2 / FC3 / FC4 / FC5 / FC6 / Fedora7 / Fedora8 / Fedora9 / Fedora10 / Fedora11 / Fedora12 / CentOS4 / CentOS5 ]
  1. dhcpとは・・・
  2. dhcpのインストール
  3. dhcpの設定
    構築の前に・・・
    サービス設定ファイルの編集
  4. dhcpの起動
  5. OSの再起動を行なった時にdhcpを自動的に起動するように設定する
  6. クライアントの設定
    固定IP付与した『client1』の確認
    動的IP付与した『client2』の確認

■ コンテンツ関連情報 (Google)

■ dhcpとは・・・

dhcpとは、Dynamic Host Configuration Protocolの略で、クライアントPCでIPアドレスを自動取得するという設定を行なうと、クライアントがIPアドレスを必要とした時点でIPアドレス割り当て要求の為のブロードキャストを行ないます。
DHCPサーバがこのブロードキャストを認識すると、発信したPCにIPアドレスを貸し出します。

dhcp機能は、最近のルータにほとんど存在していますが、あえてLinuxで構築する場合を紹介します。

■ dhcpのインストール

# yum -y install dhcp

■ 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


設定ファイルの編集
※:dhcp ver4 辺りから上記でコピーしたサンプルと内容が若干異なりますが、
  下記の設定でも動作は可能です。(参考程度としてご理解下さい。)
# 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の起動

dhcpを起動する
# /etc/rc.d/init.d/dhcpd start
dhcpd を起動中:                                            [  OK  ]

■ OSの再起動を行なった時にdhcpを自動的に起動するように設定する

起動時にdhcpを起動する
# chkconfig dhcpd on
設定内容を確認
# chkconfig --list dhcpd
dhcpd           0:オフ  1:オフ  2:オン  3:オン  4:オン  5:オン  6:オフ

■ クライアントの設定

クライアントのネットワークの設定を以下の様にします。

  1. 「IPアドレスを自動的に取得する」のラジオボタンを選択しOKボタンをクリックします。
  2. クライアントを再起動します。
  3. 再起動後、設定されているか確認してみます。

■ 固定IP付与した『client1』の確認

『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>

■ 動的IP付与した『client2』の確認

『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>

リーズナブルで抜群のスペック。パソコン工房 価格.comブロードバンドプロバイダ比較

ページ先頭へ

Copyright(©)2004-2010 First home server construction. All Right Reserved.