DHCP服务器

1、安装DHCP服务器组件:

#yum -y install dhcp

2、配置DHCP:
DHCP配置文件为/etc/dhcpd/dhcpd.conf,但该文件默认是没有内容的,所以需要手动添加

Subnet: 192.168.1.0/24
Gateway (Router IP Address): 192.168.1.1
DNS IP:  222.34.19.99,222.34.29.98
range:192.168.1.100 192.168.1.254

如果配置文件错误, DHCP服务启动失败, 不提示错误, 所以很难找到原因,但是/var/log/messages 里有记录
以下是我的完整配置文件,可以用来参考
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#


# This DHCP server to be declared valid
authoritative;

# Subnet 192.168.1.0/24
subnet 192.168.1.0 netmask 255.255.255.0 {

# default gateway
option routers 192.168.1.1;

# domain name
option domain-name "test.com";

# DNS's hostname or IP address
option domain-name-servers 222.34.19.99,222.34.29.98;

# range of lease IP address
range dynamic-bootp 192.168.1.100 192.168.1.254;

# default lease time
default-lease-time 600;

# max lease time
max-lease-time 7200;

# broadcast address
option broadcast-address 192.168.1.255;

#####   Reserved Hosts   #####

# Router
host router {
 hardware ethernet 20:DC:E6:72:B8:A2;
 fixed-address 192.168.1.1;
 }
} # end of Subnet 192.168.1.0/24
3.设置监听端口
# /etc/sysconfig/dhcp
DHCPDARGS="eth0"  
4.启动服务
# /etc/rc.d/init.d/dhcpd start

你可能感兴趣的:(DHCP)