RHEL DHCP服务器配置

简介:

这一篇介绍了一下RHEL DHCP服务器配置,从DHCP服务器软件的安装开始。

[root@bys dhcp]# rpm -e dhcp          #卸载DHCP相关的软件   提示无法卸载。是与另一文件关联     
error: Failed dependencies:
      dhcp = 12:3.0.5-23.el5 is needed by (installed) dhcp-devel-3.0.5-23.el5.i386
[root@bys dhcp]# rpm -e dhcp-devel   #先卸载dhcp-devel
[root@bys dhcp]# rpm -e dhcp         #再卸载dhcp
[root@bys dhcp]# rpm -qa\grep dhcp  
rpmq: one type of query/verify may be performed at a time
[root@bys dhcp]# rpm -qa|grep dhcp  #查询下与dhcp关联的软件
dhcpv6-client-1.0.10-18.el5
[root@bys dhcp]# rpm -e dhcpv6-client      #继续卸载
[root@bys dhcp]# rpm -qa|grep dhcp         #再查询一下
[root@bys dhcp]# ls                    #安装文件是通过从系统安装盘CP过来的。
dhcp-3.0.5-23.el5.i386.rpm
dhcp-devel-3.0.5-23.el5.i386.rpm
dhcpv6-1.0.10-18.el5.i386.rpm
[root@bys dhcp]# rpm -ivh dhcp-3.0.5-23.el5.i386.rpm      #进行软件安装,这几个相关软件安装不分先后
warning: dhcp-3.0.5-23.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                                               ########################################### [100%]
   1:dhcp                                                  ########################################### [100%]
[root@bys dhcp]# rpm -ivh dhcp-devel-3.0.5-23.el5.i386.rpm
warning: dhcp-devel-3.0.5-23.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                                               ########################################### [100%]
   1:dhcp-devel                                            ########################################### [100%]
[root@bys dhcp]# ls
dhclient-3.0.5-23.el5.i386.rpm
dhcp-3.0.5-23.el5.i386.rpm
dhcp-devel-3.0.5-23.el5.i386.rpm
dhcpv6-1.0.10-18.el5.i386.rpm
dhcpv6-client-1.0.10-18.el5.i386.rpm
[root@bys dhcp]# rpm -ivh dhcpv6-client-1.0.10-18.el5.i386.rpm
warning: dhcpv6-client-1.0.10-18.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                                               ########################################### [100%]
   1:dhcpv6-client                                         ########################################### [100%]
[root@bys dhcp]# rpm -ivh dhclient-3.0.5-23.el5.i386.rpm
warning: dhclient-3.0.5-23.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                                               ########################################### [100%]
      package dhclient-3.0.5-23.el5.i386 is already installed
[root@bys dhcp]# rpm -ivh dhcpv6-1.0.10-18.el5.i386.rpm
warning: dhcpv6-1.0.10-18.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...                                               ########################################### [100%]
   1:dhcpv6                                                ########################################### [100%]
[root@bys dhcp]# rpm -qa|grep dhcp    
dhcp-3.0.5-23.el5
dhcpv6-1.0.10-18.el5
dhcpv6-client-1.0.10-18.el5
dhcp-devel-3.0.5-23.el5
[root@bys ~]# cd /usr/share/doc/dhcp-3.0.5
[root@bys dhcp-3.0.5]# ls
api+protocol                          RELNOTES
dhcpd.conf.sample                     rfc1542.txt
draft-ietf-dhc-authentication-14.txt  rfc2131.txt
draft-ietf-dhc-dhcp-dns-12.txt        rfc2132.txt
draft-ietf-dhc-failover-07.txt        rfc2485.txt
IANA-arp-parameters                   rfc2489.txt
ja_JP.eucJP                           rfc951.txt
README
[root@bys etc]# rm -f dhcpd.conf      #将/etc/dhcpd.conf删除
[root@bys etc]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sam
ple /etc/dhcpd.conf                      #将示例文件CP为/etc/dhcpd.conf
[root@bys etc]# vi dhcpd.conf            # 编辑/etc/dhcpd.conf
ddns-update-style interim;                # 动态DNS。可以设置为none.这里是默认设置,未作更改
ignore client-updates;

subnet 192.168.0.0 netmask 255.255.255.0 {                  #设置IP作用域为192.168.0.0/24

# --- default gateway
        option routers                  192.168.0.1;        #设置网关
        option subnet-mask              255.255.255.0;      #设置掩码

        option nis-domain               "bys.com";          #设置为与主机同样的域名
        option domain-name              "bys.com";          #设置为与主机同样的域名
        option domain-name-servers      202.102.224.68,202.102.227.68;        #设置DNS服务器IP(河南的)中间逗号隔开

        option time-offset              -18000; # Eastern Standard Time
#       option ntp-servers              192.168.0.5;        #设置NTP服务器IP
#       option netbios-name-servers     192.168.0.5;        #设置NETBIOS服务器IP
# --- 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.20 192.168.0.30;     #设置地址池范围
        default-lease-time 600;                            #设置地址的租期
        max-lease-time 1200;                               #设置地址的最大租期

        # we want the nameserver to appear at a fixed address
        host ns {                                          #用于为特定主机指定固定IP
                next-server marvin.redhat.com;
                hardware ethernet 12:34:56:78:AB:CD;   #特定主机MAC  
                fixed-address 207.175.42.254;                  #指定的IP
        }
}
[root@bys etc]# dhcpd                                 #启动dhcpd进程
Internet Systems Consortium DHCP Server V3.0.5-RedHat
Copyright 2004-2006 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
WARNING: Host declarations are global.  They are not limited to the scope you declared them in.
Wrote 0 deleted host decls to leases file.
Wrote 0 new dynamic host decls to leases file.
Wrote 1 leases to leases file.
Listening on LPF/eth0/00:0c:29:88:4e:9c/192.168.0/24
Sending on   LPF/eth0/00:0c:29:88:4e:9c/192.168.0/24
Sending on   Socket/fallback/fallback-net

[root@bys ~]# service dhcpd status       #查看DHCPD 服务状态
dhcpd (pid  4913) is running...
[root@bys etc]# ps -eaf|grep dhcp                   #查看进程是否启动
root      3506     1  0 07:23 ?        00:00:00 dhcpd
root      3510  3452  0 07:24 pts/1    00:00:00 grep dhcp

[root@bys etc]# netstat -an|grep :67                #查看67端口是否已经开始监听
udp        0      0 0.0.0.0:67                  0.0.0.0:*    

[root@bys ~]# tail -n 30 /var/log/messages       查看日志文件的输出,-n显示最近3条

 

附:租约文件dhcpd.leases部分内容,RHTL5中文件在/var/lib/dhcpd/dhcpd.leases

[root@bys dhcpd]# more dhcpd.leases
# All times in this file are in UTC (GMT), not your local timezone.   This is
# not a bug, so please don't ask about it.   There is no portable way to
# store leases in the local timezone, so please don't request this as a
# feature.   If this is inconvenient or confusing to you, we sincerely
# apologize.   Seriously, though - don't ask.
# The format of this file is documented in the dhcpd.leases(5) manual page.
# This lease file was written by isc-dhcp-V3.0.5-RedHat

lease 192.168.0.30 {
  starts 2 2011/06/28 01:02:53;
  ends 2 2011/06/28 01:05:52;
  tstp 2 2011/06/28 01:05:52;
  binding state free;
  hardware ethernet 00:a0:e8:09:01:17;
  uid "\001\000\240\350\011\001\027";
}
lease 192.168.0.29 {
  starts 2 2011/06/28 07:33:13;
  ends 2 2011/06/28 07:43:13;
  tstp 2 2011/06/28 07:43:13;
  binding state active;
  next binding state free;
  hardware ethernet 00:0c:29:1c:36:f8;
  uid "\001\000\014)\0346\370";
  client-hostname "bestbys";
}
lease 192.168.0.30 {
  starts 2 2011/06/28 07:37:14;
  ends 2 2011/06/28 07:47:14;
  binding state active;
  next binding state free;
  hardware ethernet 00:a0:e8:09:01:17;
  uid "\001\000\240\350\011\001\027";
  client-hostname "bys";
}
lease 192.168.0.30 {
  starts 2 2011/06/28 07:37:17;
  ends 2 2011/06/28 07:47:17;
  binding state active;
  next binding state free;
  hardware ethernet 00:a0:e8:09:01:17;
  uid "\001\000\240\350\011\001\027";
  client-hostname "bys"; 
  
 

RHEL 5客户端启动DHCP方法:修改配置文件/etc/sysconfig/network-scripts/ifcfg-eth0

 

DEVICE=eth0
BOOTPROTO=static             这个地方改成dhcp ,重启网络服务HWADDR=00:0C:29:88:4E:9C
ONBOOT=yes
DHCP_HOSTNAME=bys.com
IPADDR=192.168.0.5
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
TYPE=Ethernet
USERCTL=no
IPV6INIT=no
PEERDNS=yes
 本文转自  还不算晕  51CTO博客,原文链接:http://blog.51cto.com/haibusuanyun/598582


相关文章
|
5月前
|
应用服务中间件 网络安全 数据安全/隐私保护
网关服务器配置指南:实现自动DHCP地址分配、HTTP服务和SSH无密码登录。
哇哈哈,道具都准备好了,咱们的魔术秀就要开始了。现在,你的网关服务器已经魔法满满,自动分配IP,提供网页服务,SSH登录如入无人之境。而整个世界,只会知道效果,不会知道是你在幕后操控一切。这就是真正的数字世界魔法师,随手拈来,手到擒来。
320 14
|
6月前
|
网络协议 安全
DHCP服务器配置
DHCP(动态主机配置协议)是一种用于自动分配IP地址及相关网络参数的协议,旨在简化网络管理、减少手动配置的工作量并避免IP地址冲突。其工作过程包括发现、提供、请求和确认四个阶段,确保设备快速安全接入网络。关键概念包括IP地址池、租约、作用域和静态分配等。DHCP通过自动化、动态性和冲突避免等功能,支持网络设备高效接入与管理。
456 21
|
监控 安全 Linux
RHEL 环境下 Subversion 服务器部署与配置
【10月更文挑战第18天】在RHEL环境下部署Subversion服务器需依次完成安装Subversion、创建版本库、配置服务器、启动服务、客户端连接及备份维护等步骤。确保遵循安全最佳实践,保障数据安全。
273 1
|
网络协议 Windows
Windows Server 2019 DHCP服务器搭建
Windows Server 2019 DHCP服务器搭建
315 3
|
安全 Linux 数据安全/隐私保护
RHEL 环境下 Subversion 服务器部署与配置
【10月更文挑战第17天】在RHEL环境下部署Subversion服务器包括安装Subversion、创建和配置版本库、启动服务器、客户端连接以及备份与恢复等步骤。通过这些步骤,可确保服务器的安全性和稳定性,满足版本控制需求。
130 2
|
网络协议 Windows
Windows Server 2003 DHCP服务器搭建
Windows Server 2003 DHCP服务器搭建
134 2
|
网络协议 Linux Windows
构建 DHCP 服务器
DHCP(动态主机配置协议)是局域网中使用UDP工作的协议,负责自动分配IP地址等网络配置。它利用UDP端口67/68作为服务器/客户端通信端口。通过配置DHCP服务器(例如使用`yum install dhcp dhcp-devel -y`安装),可在`/etc/dhcpd.conf`中定义地址池、子网掩码、默认网关等参数。服务器需设置静态IP并运行TCP/IP协议。客户端只需简单配置为DHCP模式即可自动接收配置信息。
219 9
|
安全 Ubuntu 网络协议
在Linux中,如何配置DHCP服务器?
在Linux中,如何配置DHCP服务器?
|
监控 负载均衡 网络协议