DHCP服务整理

来源:互联网 发布:下载软件 支持thunder 编辑:程序博客网 时间:2024/05/29 12:25

DHCP服务整理

Centos 6.5
主要配置文件:

/etc/dhcpd.conf              DHCP的主要配置文件 /etc/sysconfig/dhcpd         DHCP的网卡设置文件,多个网卡时设置通过那个网卡提供dhcp服务 /etc/sysconfig/dhcrelay      DHCP中继配置文件 /var/lib/dhcpd/dhcpd.leases  DHCP记录客户端连接后租约等信息的文件

1.安装配置DHCP服务

[root@localhost ~]# yum -y install dhcp[root@localhost ~]# cd /etc/dhcp[root@localhost dhcp]# cp /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample dhcpd.confcp:是否覆盖"dhcpd.conf"? y[root@localhost dhcp]#vim dhcpd.conf# A slightly different configuration for an internal subnet.subnet 192.168.1.0 netmask 255.255.255.0 {  range 192.168.1.26 192.168.1.30;  option domain-name-servers 192.168.1.1;   #目前发现只能写一个DNS地址,多个待我测试。  option domain-name "abc.com";  option routers 192.168.1.1;  option broadcast-address 192.168.1.255;  default-lease-time 600;  max-lease-time 7200;}#为指定机器分配IPhost fantasia {  hardware ethernet 08:00:07:26:c0:a5;  fixed-address 192.168.1.27;}:wq  #保存退出[root@localhost dhcp]# service dhcpd configtest    #检查配置文件语法是否有错误Syntax: OK[root@localhost dhcp]# service dhcpd restart    #启动dhcp服务#开启允许通过防火墙[root@localhost dhcp]# iptables -I INPUT 1 -p tcp --dport 67:68 -j ACCEPT[root@localhost dhcp]# iptables -I INPUT 1 -p udp --dport 67:68 -j ACCEPT

2.指定DHCP服务监听网卡

[root@localhost dhcp]# vim /etc/sysconfig/dhcpd DHCPDARGS='eth0'

3.配置多作用域

option domain-name "fighting";option domain-name-servers 172.16.51.254;default-lease-time 86400;max-lease-time 604800;log-facility local7;subnet 172.16.51.0 netmask 255.255.255.0 {        range 172.16.51.100 172.16.51.110;        option routers 172.16.51.254;        host zijian {        hardware ethernet 08:00:27:8F:54:2C;        fixed-address 172.16.51.108;        }}subnet 172.16.52.0 netmask 255.255.255.0 {        range 172.16.52.120 172.16.52.123;        option routers 172.16.52.154;        host lijian{        hardware ethernet 08:00:27:8F:74:7C;        fixed-address 172.16.52.254;        }}

4.超级作用域配置

shared-network 224-29 {             #定义一个名叫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;  }}

5.客户端验证

linux client 验证

[root@client ~]## dhclient -d eth0

win7 clinet 验证

cmd>ipconfig /release释放ip

cmd>ipconfig /renew重新获取ip

常见dhcpd.conf文件参数

参数 注释 ddns-update-style 配置DHCP-DNS 互动更新模式 default-lease-time 指定确省租赁时间的长度,单位是秒 max-lease-time 指定最大租赁时间长度,单位是秒 hardware 指定网卡接口类型和MAC地址 server-name 通知DHCP客户服务器名称 get-lease-hostnames flag 检查客户端使用的IP地址 fixed-address ip 分配给客户端一个固定的地址 authritative 拒绝不正确的IP地址的要求 shared-network 用来告知是否一些子网络分享相同网络 subnet 描述一个IP地址是否属于该子网 range 起始IP 终止IP 提供动态分配IP 的范围 host 主机名称 参考特别的主机 group 为一组参数提供声明 allow unknown-clients;deny unknown-client 是否动态分配IP给未知的使用者 allow bootp;deny bootp 是否响应激活查询 allow booting;deny booting 是否响应使用者查询 filename 开始启动文件的名称,应用于无盘工作站 next-server 设置服务器从引导文件中装入主机名,应用于无盘工作站 subnet-mask 为客户端设定子网掩码 domain-name 为客户端指明DNS名字 domain-name-servers 为客户端指明DNS服务器IP地址 host-name 为客户端指定主机名称 routers 为客户端设定默认网关 broadcast-address 为客户端设定广播地址 ntp-server 为客户端设定网络时间服务器IP地址 time-offset 为客户端设定和格林威治时间的偏移时间,单位是秒
0 0
原创粉丝点击