RHEL6 上DHCP 服务器的搭建
来源:互联网 发布:加强网络基础设施建设 编辑:程序博客网 时间:2024/05/20 00:39
基础知识:
a. 端口号: 服务器上68, 客户机上67
b. 获取地址的过程
简单描述:
1. 客户机在局域网内放松一个广播包,说我要一个dhcp服务器我要地址。
2. 可能有一个或者多个dhcp服务器说,我有我给你。但是客户机只需要积极的那个,所以他认同了他收到一个offer包
3. 然后就是想服务器发送请求我要一个IP了。
4. 服务器丝毫不吝啬的给了他,但是这是有期限的(租约),这个期限是看服务器上是怎么配置的。
5. 注:一般租约期限到了50% 客户端或继续请求续租(renew)。正常情况下dhcp服务器是会同意的。但是服务器突然不见了,到了租约期限的85%,客户机还会再次请求一次。要是还没有,那用完就没了。系统自己给自己划分到169.254.0.0/24网段。当然服务器要是一直没有收到续租信息。不会直释放掉这个IP,会等到一定时间再释放。(这个一定时间在服务器中配置)。服务器的搭建过程
过程很简单, yum install -y dhcp* ,一次性解决依赖问题,把该装的都装了。(会装4个包,但是其实三个包就够了。)
然后就是配置了,按照套路来说配置文件肯定是放在etc中,里面肯定会有一个叫做dhcp的。事实却是是这样的。
我们进到文件夹里面。看到配置文件 dhcpd.conf。这就太熟悉了。然后打开。他说有模板在/usr/share/doc/dchp*/dhcp.conf.sa.. 然后就是直接把模板覆盖掉配置文件了。然后我们打开了呗覆盖后的dhcp配置文件。
注释和以分号结尾这都不用说了。
# dhcpd.conf## Sample configuration file for ISC dhcpd## option definitions common to all supported networks...option domain-name "example.org";option domain-name-servers ns1.example.org, ns2.example.org;default-lease-time 600;max-lease-time 7200;
这是配置文件的上面部分,很简单的可以看出,放在subnet域外面的就是全局作用。
第一条: 为dhcp设置域
第二条: 设置两个dns服务器的地址
第三条: 租约期限
第四条: 租约到期后,没有收到续租包,服务器保留ip的最大时间。
注: 这也可以写到subnet中,下面就描述一下这个域的意思。
# 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;}
这个是这实例中比较完整的配置文件。 subnet 后面的就是网段和和子网掩码 , range 就是配置的分配池的范围。 option routers 就是网关的意思。 (其他全部删除都没关系,这个配好了重启就能运行)
# 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;}
为指定的客户机分配固定的ip地址。当然这些要卸载subnet中的。做全局没意思。
# 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; }}
自定义分配规则,然后放到文件中。 一般来说配置一个符合的只要一个subnet就行,比如说这样:
。
注意: 服务器的网卡的ip地址一定要跟dhcp服务器规定的网络在同一网段。
局域网中可以有多台dhcp服务器。使用哪个dhcp服务器由客户机决定。
- RHEL6 上DHCP 服务器的搭建
- RHEL6下搭建DHCP服务器
- 搭建RHEL6网络安装服务器(PXEBOOT+DHCP)
- RHEL6.0上各种邮件服务器的搭建
- DHCP服务器的搭建
- DHCP服务器的搭建
- DHCP服务器的搭建
- linux下的dhcp服务器的搭建
- Linux环境下DHCP服务器的搭建
- 搭建IPv6的有状态DHCP服务器
- Linux系统上DHCP服务器的配置
- 解析路由器上的DHCP服务器是什么
- 搭建DHCP服务器
- linux 搭建DHCP 服务器
- DHCP服务器搭建
- ubuntu搭建dhcp服务器
- #9.DHCP服务器搭建
- Linux dhcp服务器搭建
- javaScript全面理解笔记(一)
- jstl
- Quartz学习笔记1:Quartz概述
- MyBatis Generator 1.3.4 扩展,可以设置 Mapper(Dao)后缀
- JFreeChart设置
- RHEL6 上DHCP 服务器的搭建
- [LeetCode] String to Integer (atoi)
- 【数据结构与算法】——交换排序
- 设计模式之抽象工厂模式
- LA 3266 || UVALive 3266 Tian Ji -- The Horse Racing 田忌赛马(贪心)
- 10.Java基础:常见IO流----->打印流:PrintStream、PrintWriter
- 04-贝叶斯概率
- leetcodd之candy的前后扫描得结果
- poj 2187