linux的dhcp4.1.1服务部署
Centos6.5的dhcp4.1.1服务部署
实施步骤:
1:设置DHCP服务器静态IP和主机名
[root@sw ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 设置网络
DEVICE=eth0
HWADDR=08:00:27:47:92:32
TYPE=Ethernet
UUID=f5bdb328-4418-48bc-a461-6ef894ef5269
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none 设置为静态ip
IPADDR=192.168.1.254 手动添加ip地址
NETMASK=255.255.255.0手动添加子网掩码
[root@sw ~]# vim /etc/sysconfig/network设置主机名和网关
NETWORKING=yes
HOSTNAME=server.tarena.com
GATEWAY=192.168.1.254
[root@sw ~]# vim /etc/hosts 编辑ip和主机名对应解析
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.2.254 server.tarena.com添加解析
[root@sw ~]# vim /etc/resolv.conf 编辑默认搜索域名
# Generated by NetworkManager
search tarena.com
[root@sw ~]# shutdown -r 0 重启服务器使配置生效
2:安装DHCP软件包
联网环境下
[root@server ~]# yum -y install dhcp
3:配置DHCP主配置文件
[root@server ~]# cp /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.bak先备份配置文件
[root@server ~]# vim /etc/dhcp/dhcpd.conf编辑主文件(可从模板文件导入)
subnet 192.168.1.0 netmask 255.255.255.0 {设置局部待分配网段
range 192.168.1.20 192.168.1.200;设地址池
option domain-name-servers 192.168.1.253,114.114.114.114;设要分配的DNS服务器地址
option domain-name "tarena.com";设局域网域名
option routers 192.168.1.254;设要分配的网关地址
option broadcast-address 192.168.1.255;设广播地址
default-lease-time 600;
max-lease-time 7200;
}
host win7 {设保留地址(固定分配ip)
hardware ethernet 08:00:07:26:c0:a5;设要绑定的mac
fixed-address 192.168.1.7;设绑定ip地址
}
[root@server ~]# service dhcpd restart重启服务