标签:dhcp dhcp服务器 dhcp分匹配 dhcp配置 dhcp教程
yum install dhcp* -y
[root@localhost ~]# ls /etc/dhcp/
dhclient.d dhcpd6.conf dhcpd.conf
[root@localhost ~]# vi /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample #模板文件
# see ‘man 5 dhcpd.conf‘
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#
# option definitions common to allsupported networks...
optiondomain-name "example.org"; #配置工作的域名
optiondomain-name-servers 202.96.128.86,202.96.134.133; # 配置DNS服务器 多个用逗号分隔
default-lease-time600; # 租期时间 600秒 10分
max-lease-time7200; # 120分钟 2H
# Use this to enble / disable dynamic dnsupdates globally.
#ddns-update-style none;
# If this DHCP server is the official DHCPserver for the local
# network, the authoritative directiveshould be uncommented.
#authoritative;
# Use this to send dhcp log messages to adifferent 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 networktopology.
# 指定网络号,子网掩码,大括号中给出 range分配范围,
# 多个网段可以写多条
# This is a very basic subnet declaration.
subnet192.168.1.0 netmask 255.255.255.0
{
range 192.168.1.100 192.168.1.200;
option domain-name-servers 192.168.1.10; #
option domain-name "hdbattery.cn";
option routers 192.168.1.1; # 网关
option broadcast-address 192.168.1.255; # 广播地址
default-lease-time 600;
max-lease-time 7200;
}
# 以下配置为固定分配MAC绑定
hostfantasia
{
hardware ethernet 08:00:07:26:c0:a5;
fixed-address 192.168.1.100;
}
# You can declare a class of clients andthen do address allocation
# based on that. The example below shows a case where allclients
# in a certain class get addresses on the10.17.224/24 subnet, and all
# other clients get addresses on the10.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;
}
}
测试配置文件语法:
service dhcpd configtest
# 测试DHCP语法是否正常
service dhcpd restart
# 配置完后重启
########################## 简单配置文件 ################################
ignoreclient-updates;
next-server192.168.1.11;
allowbooting;
allowbootp;
subnet192.168.0.0 netmask 255.255.255.0 {
optionrouters 192.168.0.1
optionsubnet-mask 255.255.255.0;
optiondomain-name-servers 8.8.8.8,114.114.114.114;
range dynamic-bootp 192.168.0.100 192.168.0.200;
hostns {
hardware ethernet 00:12:a0:2d:81;
fixed-address 192.168.0.101;
}
}
######################################################################################3
DHCP端口:67 68
开启防火墙DHCP
iptable -I INPUT 1 -p tcp --dport 67 -jACCEPT
iptable -I INPUT 1 -p udp --dport 67 -jACCEPT
iptable -I INPUT 1 -p tcp --dport 68 -jACCEPT
iptable -I INPUT 1 -p udp --dport 68 -jACCEPT
cd /var/lib/dhcpd
cat dhcpd.leases
cd /var/lib/dhclient/
cat dhclient.leases
vi /etc/sysconfig/dhcpd
# Command line options here
DHCPDARGS=‘eth0‘ # 指定接口
ether-wake -i eth0 00:11:22:33:44:55
1:权限问题?
[root@localhostdhcp]# vi /etc/rc.d/init.d/dhcpd
User=root
Group=root
2.接口问题
Not configured tolisten on any interfaces!
1.配置固定IP地址
2.检查dhcpd.cnf中的hsot ns {}有绑定没
3.vi/etc/sysconfig/dhcpd
本文出自 “linux技术交流” 博客,请务必保留此出处http://zhongliang.blog.51cto.com/4507905/1878840
标签:dhcp dhcp服务器 dhcp分匹配 dhcp配置 dhcp教程
原文地址:http://zhongliang.blog.51cto.com/4507905/1878840