搭建一個簡單的DHCP伺服器

來源:互聯網
上載者:User

標籤:搭建簡單的dhcp伺服器

實驗環境:

系統:RHEL6.4

一.給DHCP伺服器配置固定IP

[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0


DEVICE=eth0                                                             

HWADDR=.......                                   

TYPE=Ethernet            

UUID=......                                                               

ONBOOT=yes                                                         

NM_CONTROLLED=yes

BOOTPROTO=static                                              

IPADDR=192.168.50.253

NETMASK=255.255.255.0                                     

[[email protected] ~]#service network restart       

[[email protected] ~]#chkconfig network on         

[[email protected] ~]inconfig eth0



二.安裝dhcp軟體包

[[email protected] ~]rpm -q dhcp

package dhcp is not installed

放入RHEL6.4.iso

[[email protected] ~]cd /misc/cd/Packages/

[[email protected] Packages]ls dhcp*

dhcp-4.1.1-34.P1.el6.x86_64.rpm  

dhcp-common-4.1.1-34.P1.el6.x86_64.rpm

[[email protected] Packages]rpm -ivh dhcp-4.1.1-34.P1.el6.x86_64.rpm

warning: dhcp-4.1.1-34.P1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY

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

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




三.配置DHCP伺服器

[[email protected] ~]vim /etc/dhcpd/dhcpd.conf


ddns-update-style none;       //動態更新類型

subnet 192.168.50.0 netmask 255.255.255.0 {                    //網段聲明                 

  range 192.168.50.10 192.168.50.20;                           //IP分配範圍

  range 192.168.50.50 192.168.50.60;

  option domain-name-servers 192.168.50.252,114.114.114.114;   //DNS伺服器位址

  option domain-name "tarena.com";                             //預設搜尋域

  option routers 192.168.50.254;       //預設閘道

  default-lease-time 21600;                                    //預設租期

  max-lease-time 43200;       //最大租期

}

host hostname {                                                //識別名稱

  hardware ethernet 00:00:00:00:00:00;       //客戶機MAC地址

  fixed-address 192.168.50.33;       //分配給改客戶機的固定IP

}

四.啟動服務

[[email protected] ~]service dhcpd status

dhcpd已停

[[email protected] ~]service dhcpd start

啟動dhcpd :                                [確定]

[[email protected] ~]chkconfig --list dhcpd

dhcpd           0:關閉  1:關閉  2:關閉   3:關閉   4:關閉   5:關閉 6:關閉

[[email protected] ~]chkconfig dhcpd on

五.用戶端驗證

Windows平台

        網路設定選擇自動選取,ipconfig /release

                              ipconfig /renew

Linux 平台

        臨時

                                         dhclient -d eth0     擷取

                                         dhclient -r  eth0     釋放

       永久

[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0


DEVICE=eth0

HWADDR=00:00:00:00:00:00

TYPE=Ethernet

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=dhcp


[[email protected] ~]#service network restart

[[email protected] ~]#ifconfig eth0



錯誤檢查:

service dhcpd configtest             //檢查dhcpd.conf語法錯誤

根據提示一步步排錯,如果文法OK,服務啟動不了,查看本機IP地址.


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.