码迷,mamicode.com
首页 > 系统相关 > 详细

linux DHCP服务器的配置(redhat6.4)

时间:2015-07-09 00:59:26      阅读:219      评论:0      收藏:0      [点我收藏+]

标签:linux   dhcp 配置

步骤一:给DHCP服务器配置静态ip

[root@localhost ~]# ifconfig eth0         //查看eth0网卡的配置信息

eth0      Link encap:Ethernet  HWaddr 00:0C:29:0C:C3:1F  

          inet addr:192.168.1.33  Bcast:192.168.1.255  Mask:255.255.255.0

          inet6 addr: fe80::20c:29ff:fe0c:c31f/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:2519 errors:0 dropped:0 overruns:0 frame:0

          TX packets:2644 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:1806182 (1.7 MiB)  TX bytes:1671573 (1.5 MiB)

          Interrupt:18 Base address:0x2000 



[root@localhost ~]# route -n        //   查看路由表条目 

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0




步骤二:

根据要求安装DHCP服务器所需软件包

[root@localhost ~]# rpm -q dhcp       // 查看dhcp包是否安装,下面显示未安装

package dhcp is not installed

[root@localhost ~]# mkdir /ww         //建立一个文件夹

[root@localhost ~]# mount /dev/cdrom /ww    //将系统镜像挂载到/ww目录下

mount: block device /dev/sr0 is write-protected, mounting read-only

[root@localhost ~]# rpm -ivh /ww/Packages/dhcp-4.1.1-34.P1.el6.x86_64.rpm    //安装dhcp

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

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

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

[root@localhost ~]# 


步骤三:

产生DHCP服务器配置文件

[root@localhost ~]# cp /usr//share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcp/dhcpd.conf      cp:是否覆盖“/etc/dhcp/dhcpd.conf"?y             


步骤四:配置/etc/dhcp/dhcpd.conf配置文件

# dhcpd.conf

#

# Sample configuration file for ISC dhcpd

#


# option definitions common to all supported networks...

option domain-name "example.org";

option domain-name-servers 8.8.8.8, 4.4.4.4;      //指定dns服务器地址


default-lease-time 600;

max-lease-time 7200;


# Use this to enble / disable dynamic dns updates globally.

#ddns-update-style none;


# If this DHCP server is the official DHCP server for the local

# network, the authoritative directive should be uncommented.

#authoritative;


# Use this to send dhcp log messages to a different log file (you also

# have to hack syslog.conf to complete the redirection).

log-facility local7;


# No service will be given on this subnet, but declaring it helps the

# DHCP server to understand the network topology.


subnet 192.168.1.0 netmask 255.255.255.0 {           

}


# This is a very basic subnet declaration.


subnet 192.168.1.0 netmask 255.255.255.0 {        //声明网址地址

  range 192.168.1.10 192.168.1.100;              //设置地址池

  option routers 192.168.1.1;                     //设置默认网关

}


# This declaration allows BOOTP clients to get dynamic addresses,

# which we don‘t really recommend.


subnet 10.254.239.32 netmask 255.255.255.224 {

  range dynamic-bootp 10.254.239.40 10.254.239.60;

  option broadcast-address 10.254.239.31;

  option routers rtr-239-32-1.example.org;

}


# A slightly different configuration for an internal subnet.

subnet 10.5.5.0 netmask 255.255.255.224 {

  range 10.5.5.26 10.5.5.30;

  option domain-name-servers ns1.internal.example.org;

  option domain-name "internal.example.org";

  option routers 10.5.5.1;

  option broadcast-address 10.5.5.31;

  default-lease-time 600;

  max-lease-time 7200;

}


# Hosts which require special configuration options can be listed in

# host statements.   If no address is specified, the address will be

# allocated dynamically (if possible), but the host-specific information

# will still come from the host declaration.


host passacaglia {

  hardware ethernet 0:0:c0:5d:bd:95;

  filename "vmunix.passacaglia";

  server-name "toccata.fugue.com";

}


# Fixed IP addresses can also be specified for hosts.   These addresses

# should not also be listed as being available for dynamic assignment.

# Hosts for which fixed IP addresses have been specified can boot using

# BOOTP or DHCP.   Hosts for which no fixed address is specified can only

# be booted with DHCP, unless there is an address range on the subnet

# to which a BOOTP client is connected which has the dynamic-bootp flag

# set.

host fantasia {

  hardware ethernet 08:00:07:26:c0:a5;

  fixed-address fantasia.fugue.com;

}


# You can declare a class of clients and then do address allocation

# based on that.   The example below shows a case where all clients

# in a certain class get addresses on the 10.17.224/24 subnet, and all

# other clients get addresses on the 10.0.29/24 subnet.


class "foo" {

  match if substring (option vendor-class-identifier, 0, 4) = "SUNW";

}


shared-network 224-29 {

  subnet 10.17.224.0 netmask 255.255.255.0 {

    option routers rtr-224.example.org;

  }

  subnet 10.0.29.0 netmask 255.255.255.0 {

    option routers rtr-29.example.org;

  }

  pool {

    allow members of "foo";

    range 10.17.224.10 10.17.224.250;

  }

  pool {

    deny members of "foo";

    range 10.0.29.10 10.0.29.230;

  }

}


步骤五:启动DHCP服务器


[root@localhost ~]# service dhcpd start

启动 dhcpd:                                               [确定]



步骤六:测试


开一台windows7和dhcp同一网络下,自动获取ip

技术分享


  打开/etc/dhcp/dhcpd.conf     修改第五行host后面的参数 绑定win7的mac 给win7指定的ip

技术分享

技术分享

技术分享重启dhcp服务 service dhcpd restart

技术分享技术分享


查看win7 的网络连接详细信息

技术分享


本文出自 “LIXIAOWEI” 博客,请务必保留此出处http://itlxw.blog.51cto.com/10197289/1672208

linux DHCP服务器的配置(redhat6.4)

标签:linux   dhcp 配置

原文地址:http://itlxw.blog.51cto.com/10197289/1672208

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!