DHCP服務器配置

實驗01:DHCP服務器配置

  • 實驗目標

  • 公司要求將閒置的一臺Linux 主機配置爲DHCP服務器,以便爲局域網內員工的辦公用機提供自動分配IP地址的服務,以提高網絡管理和維護的效率。需要滿足的基本要求如下所述。

  • 1.爲192.168.10.0/24網段的客戶機自動配置網絡參數。

  • 用來給客戶機自動分配的IP地址範圍是:

                        192.168.10.50-192.168.10.100

                                        192.168.10.120-192.168.10.200

  • 客戶機的默認網關地址設爲192.168.10.254

  • 客戶機所使用的DNS服務器設爲192.168.10.253202.106.0.20

  • 默認搜索域後綴爲tarena.com

  • 將默認租約時間設爲8小時,最大租約時間24小時

  • 2.爲打印服務器分配保留地址(Win7

  •          這臺打印機每次開啓電源後獲得的IP地址都應該是192.168.10.8

  • 3.驗證DHCP服務器的IP分配情況、客戶機的租約信息

  • 實驗步驟

  • 實驗準備

Dhcp服務器一臺,客戶機一臺

使所有實驗機器在相同網絡

二.配置DHCP服務器

1.爲服務器配置ip地址以及子網掩碼

 

[root@localhost~]#vim/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

BOOTPROTO=none

ONBOOT=yes

HWADDR=00:0c:29:05:ef:c9

IPADDR=192.168.10.253

NETMASK=255.255.255.0

~     

 

  1. 2.爲服務器配置主機名以及網關

[root@localhost~]# vim /etc/sysconfig/network

NETWORKING=yes

NETWORKING_IPV6=yes

HOSTNAME=dhcpser.tarena.com

GATEWAY=192.168.10.254

 3.識別主機名

[root@localhost ~]# vim /etc/hosts

  1. 127.0.0.1              localhost.localdomain localhost

::1            localhost6.localdomain6 localhost6

  1. 192.168.10.253   dhcpser.tarena.com    dhcpser

 4.重新啓用網絡服務

[root@localhost ~]# service network restart

正在關閉接口 eth0                                        [確定]

關閉環回接口:                                             [確定]

彈出環回接口:                                             [確定]

彈出界面 eth0                                            [確定]

[root@localhost ~]# chkconfig network on

  1. 5.服務器端驗證配置

[root@localhost ~]# ifconfig eth0

eth0      Linkencap:Ethernet  HWaddr00:0C:29:05:EF:C9 

          inetaddr:192.168.10.253  Bcast:192.168.10.255  Mask:255.255.255.0

[root@localhost ~]# route -n

Kernel IP routing table

Destination    Gateway         Genmask         Flags Metric Ref    Use Iface

  1. 192.168.10.0   0.0.0.0         255.255.255.0   U    0      0        0 eth0

  2. 169.254.0.0     0.0.0.0         255.255.0.0     U    0      0        0 eth0

  3. 0.0.0.0        192.168.10.254  0.0.0.0         UG   0      0        0 eth0

[root@localhost ~]# hostname

dhcpser.tarena.com

[root@localhost~]# ping dhcpser.tarena.com

PINGdhcpser.tarena.com (192.168.10.253) 56(84) bytes of data.

64 bytes fromdhcpser.tarena.com (192.168.10.253): icmp_seq=1 ttl=64 time=0.096

三.安裝軟件包

[root@localhost~]# cd /media/Server/

[root@localhostServer]# rpm -ivh dhcp-3.0.5-31.el5_8.1.x86_64.rpm

warning:dhcp-3.0.5-31.el5_8.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID37017186

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

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

[root@localhostServer]# rpm -q dhcp

dhcp-3.0.5-31.el5_8.1

四.修改配置文件

[root@localhost~]#  vim /etc/dhcpd.conf

ddns-update-styleinterim;

subnet192.168.10.0 netmask 255.255.255.0 {

        option routers                  192.168.10.254;

        option subnet-mask              255.255.255.0;

        option domain-name              "tarena.com";

        option domain-name-servers      192.168.10.253,202.106.0.20;

        range dynamic-bootp 192.168.10.50192.168.0.100;

        range dynamic-bootp 192.168.10.120192.168.0.200;

        default-lease-time 28800;

        max-lease-time 86400;

        host client {

                hardware ethernet12:34:56:78:AB:CD;

                fixed-address 192.168.10.8;

        }

}

五.啓用服務

[root@localhost~]# service dhcpd restart

啓動 dhcpd                                               [確定]

[root@localhost~]# chkconfig dhcpd on

[root@localhost~]# netstat -ln | grep :67

udp        0     0 0.0.0.0:67                 0.0.0.0:* 

六.客戶端測試

  1. 1.修改固定配置

[root@localhost ~]# vim/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

BOOTPROTO=dhcp

ONBOOT=yes

HWADDR=00:0c:29:23:a5:76

  1. 2.重新啓用網絡服務

[root@localhost ~]# service network restart

正在關閉接口 eth0                                        [確定]

關閉環回接口:                                             [確定]

彈出環回接口:                                             [確定]

彈出界面 eth0

正在決定 eth0 IP 信息...完成。

                                                          [確定]

  1. 3.重新查看ip地址

[root@localhost~]# ifconfig eth0

eth0      Link encap:Ethernet  HWaddr 00:0C:29:23:A5:76 

          inet addr:192.168.10.200  Bcast:192.168.10.255  Mask:255.255.255.0

  1. 4.服務器端查看租約文件

  1. 5.客戶端查看租約文件

[root@localhost~]# vim /var/lib/dhclient/dhclient-eth0.leases

lease {

  interface "eth0";

  fixed-address 192.168.10.200;

  option subnet-mask 255.255.255.0;

  option routers 192.168.10.254;

  option dhcp-lease-time 28800;

  option dhcp-message-type 5;

  option domain-name-servers192.168.10.253,202.106.0.20;

  option dhcp-server-identifier 192.168.10.253;

  • 問題和經驗總結

故障現象:

[root@localhost~]# service dhcpd restart

啓動 dhcpd                                               [失敗]

解決辦法:

[root@localhost ~]# service dhcpdconfigtest

.....

Address range 192.168.10.50 to192.168.0.100, netmask 255.255.255.0 spans multiple subnets!

 

If you did not get this software fromftp.isc.org, please

get the latest from ftp.isc.org and installthat before

requesting help.

........

進入/etc/dhcpd.conf,將地址池的192.168.0.100192.168.0.200改爲192.168.10.

100192.168.10.200

 


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