linux下配置DHCP服務

DHCP服務器配置:

 

   找到dhcp-3.0.5-7.el5.i386.rpm 這個包,然後安裝。

   安裝   rpm -ivh foo-1.0-l.i386.rpm    i表示includedocs  安裝文檔,V表示顯示附加信息,h表示hash 安裝時輸出hash 記號。

    [root@test Server]# rpm -ivh dhcp-3.0.5-21.el5.i386.rpm

warning: dhcp-3.0.5-21.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186

Preparing...                ########################################### [100%]

   1:dhcp                   ########################################### [100%]

表示安裝成功。

安裝成功後會生成以下兩個文件

配置文件是/etc/dhcpd.conf ,       租約數據庫文件時 /var/lib/dhcpd/dhcpd.leases     ,

然後,編輯 /etc/dhcpd.conf ,
 [root@test dhcpd]# vi /etc/dhcpd.conf    
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample   其中會顯示這兩行
接下來,我們要將/usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample 覆蓋到/etc/dhcp.conf

 

[root@test dhcp-3.0.5]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample  /etc/dhcpd.conf
cp:是否覆蓋“/etc/dhcpd.conf? y

 

然後編輯/etc/dhcpd.conf 文件:
[root@test etc]# vi dhcpd.conf

 

ddns-update-style interim;        #定義所支持的DNS動態更新類型
ignore client-updates;            #忽略客戶端更新

 

subnet 192.168.0.0 netmask 255.255.255.0 {

 

# --- default gateway
        option routers                  192.168.0.1;          #網關地址
        option subnet-mask             255.255.255.0;      #子網掩碼:默認子網掩碼

 

        option nis-domain               "domain.org";
        option domain-name              "domain.org";     #DNS後綴
        option domain-name-servers      192.168.1.1;       #DNS服務器地址

 

        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;

 

        range dynamic-bootp 192.168.0.128 192.168.0.254;     #動態IP地址範圍
        default-lease-time 21600;                      #默認IP租約時間,單位秒
        max-lease-time 43200;               #客戶端IP租約時間最大值,單位爲妙

 

        # we want the nameserver to appear at a fixed address
        host ns {
                next-server marvin.redhat.com;
                hardware ethernet 12:34:56:78:AB:CD;
                fixed-address 207.175.42.254;
        }
}

 

可以修改爲:

 

 ddns-update-style interim;        #定義所支持的DNS動態更新類型
ignore client-updates;            #忽略客戶端更新

 

subnet 192.168.100.0  netmask 255.255.255.0 {

 

# --- default gateway
        option routers                  192.168.100.1;          #網關地址
        option subnet-mask             255.255.255.0;      #子網掩碼:默認子網掩碼

 

        option nis-domain               "yanglei.com";
        option domain-name              "yanglei.com";     #DNS後綴
        option domain-name-servers      192.168.100.1;       #DNS服務器地址

 

        option time-offset              -18000; # Eastern Standard Time  
#       option ntp-servers              192.168.100.1;
#       option netbios-name-servers     192.168.100.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- you understand Netbios very well
#       option netbios-node-type 2;

 

        range dynamic-bootp 192.168.100.10   192.168.100.254;     #動態IP地址範圍
        default-lease-time 21600;                      #默認IP租約時間,單位秒
        max-lease-time 43200;               #客戶端IP租約時間最大值,單位爲妙

 

        # we want the nameserver to appear at a fixed address
        host ns {
                next-server marvin.redhat.com;
                hardware ethernet 12:34:56:78:AB:CD;
                fixed-address 207.175.42.254;
        }
}
修改完後保存。
啓動服務:
[root@test etc]# /etc/init.d/dhcpd  start
啓動 dhcpd[確定]
啓動完成後,查看日誌:
[root@test etc]# tail -f /var/log/messages
Oct 27 15:07:17 test dhcpd: Copyright 2004-2006 Internet Systems Consortium.
Oct 27 15:07:17 test dhcpd: All rights reserved.
Oct 27 15:07:17 test dhcpd: For info, please visit http://www.isc.org/sw/dhcp/
Oct 27 15:07:17 test dhcpd: WARNING: Host declarations are global.  They are not limited to the scope you declared them in.
Oct 27 15:07:17 test dhcpd: Wrote 0 deleted host decls to leases file.
Oct 27 15:07:17 test dhcpd: Wrote 0 new dynamic host decls to leases file.
Oct 27 15:07:17 test dhcpd: Wrote 0 leases to leases file.
Oct 27 15:07:17 test dhcpd: Listening on LPF/eth0/00:0c:29:fa:b0:cd/192.168.100/24
Oct 27 15:07:17 test dhcpd: Sending on   LPF/eth0/00:0c:29:fa:b0:cd/192.168.100/24
Oct 27 15:07:17 test dhcpd: Sending on   Socket/fallback/fallback-net     
日誌顯示如上  說明配置完成。    
網絡設置爲自動獲取,檢查網路中地址如果在192.168.100.10   192.168.100.254;  這個段內,說明配置成功。

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章