008Linux DHCP服务

Linux DHCP服务

服务端配置

1.网络环境准备

网卡

网卡配置文件:
DEVICE=eth1
HWADDR=00:0C:29:b2:36:2f
TYPE=Ethernet
UUID=7d158d35-0371-4592-a1ef-61aa57e32344
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static    //改为静态的IP
IPADDR=192.168.11.4
NETMASK=255.255.255.0

关闭 selinux

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0

关闭 iptables

/etc/init.d/iptables stop
chkconfig iptables off

2.dhcp服务

安装

yum -y install dhcp

dhcp配置文件

#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.sample
#   see 'man 5 dhcpd.conf'
#

# 全局配置
# 设置客户端域名
option domain-name "hotoem";

# 设置解析域名服务器
option domain-name-servers 114.114.114.114 ,223.5.5.5;

# 默认租约时间
default-lease-time 600;

#最大租约时间
max-lease-time 7200;

# 不要ddns设定
ddns-update-style none;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# 设置DHCP子网段
subnet 192.168.11.0 netmask 255.255.255.0 {
    range 192.168.11.80 192.168.11.180;
    option routers 192.168.31.1;
}

# 配置静态客户端
################ 设备静态IP地址 ###################
# 黑白打印机

host hb_print {
  hardware ethernet 00:26:73:0e:d4:79;
  fixed-address 192.168.31.77;
}

# 彩色打印机
host cs_print {
  hardware ethernet ac:16:2d:3a:40:ac;
  fixed-address 192.168.31.78;
}

vim /etc/sysconfig/dhcpd 设置dhcp监听网卡

# Command line options here
DHCPDARGS=eth1

service dhcpd start

注: 启动日志信息可以查看 /var/log/message
租约信息可查看 /var/lib/dhcpd/dhcpd.leases
静态分配的地址最好不在dhcp分配地址范围内(除非是长期开机并手动配置了IP地址)否则会出现IP冲突(这是有教训的)

客户端配置

网卡配置信息改为dhcp,重启

你可能感兴趣的:(008Linux DHCP服务)