设为首页 收藏本站
查看: 470|回复: 0

[经验分享] linux DHCP服务器的配置(redhat6.4)

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-7-9 08:23:47 | 显示全部楼层 |阅读模式
步骤一:给DHCP服务器配置静态ip
[iyunv@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


[iyunv@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服务器所需软件包
[iyunv@localhost ~]# rpm -q dhcp       // 查看dhcp包是否安装,下面显示未安装
package dhcp is not installed
[iyunv@localhost ~]# mkdir /ww         //建立一个文件夹
[iyunv@localhost ~]# mount /dev/cdrom /ww    //将系统镜像挂载到/ww目录下
mount: block device /dev/sr0 is write-protected, mounting read-only
[iyunv@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%]
[iyunv@localhost ~]#

步骤三:
产生DHCP服务器配置文件
[iyunv@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服务器

[iyunv@localhost ~]# service dhcpd start
启动 dhcpd:                                               [确定]


步骤六:测试

开一台windows7和dhcp同一网络下,自动获取ip
QQ截图20150709082324.png

  打开/etc/dhcp/dhcpd.conf     修改第五行host后面的参数 绑定win7的mac 给win7指定的ip
QQ截图20150709082341.png
spacer.jpg
spacer.jpg 重启dhcp服务 service dhcpd restart
spacer.jpg QQ截图20150709082350.png

查看win7 的网络连接详细信息
QQ截图20150709082356.png


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-84525-1-1.html 上篇帖子: centos 6.5 网桥配置 下篇帖子: Linux文件系统详解 服务器 linux
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表