DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一个局域网的网络协议
dhcp服务器端监控端口67
涉及的配置文件:/etc/dhcp/dhcpd.conf
实验环境:
vmware workstation 11
centos : 192.168.10.10
windows xp :?
centos 与windows xp 分别只连接到VMnet8上面 #此处VMware8可以理解为一个单独的交换机
基础命令:
1:查看开机启动项:
[root@cooca ~]# chkconfig --list | grep dhcpd
dhcpd :off :off :on :on :on :on :off
dhcpd6 :off :off :off :off :off :off :off
2:查看端口是否打开:
[root@cooca ~]# netstat -anulp | grep :
udp 0.0.0.0: 0.0.0.0:*
3:查看服务状态:
[root@cooca ~]# service dhcpd status
dhcpd (pid ) is running...
简单说明:
小型公司一般192.168.1.0/24基本上够用了,一般路由器也有dhcp功能,所以linux搭建dhcp可能用在大中型公司,那么这就涉及到多网段ip地址动态分配。
这里仅研究linux搭建dhcp功能的实现,至于更实用的多网段可用性,实用性方面暂且不谈。
配置过程:
1:配置静态ip地址:
192.168.10.10/24
主机名:
cooca.com
2:dhcp服务套件查询:
[root@cooca ~]# rpm -qa | grep dhcp
dhcp-common-4.1.-.P1.el6.centos..x86_64
dhcp-4.1.-.P1.el6.centos..x86_64
3:vi编辑:
[root@cooca ~]# cat /etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp*/dhcpd.conf.sample
# see 'man 5 dhcpd.conf'
#
default-lease-time ;
max-lease-time ; option domain-name "cooca.com";
option domain-name-servers 192.168.10.10;
authoritative; subnet 192.168.10.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.10.130 192.168.10.150;
option broadcast-address 192.168.10.255;
option routers 192.168.10.1;
}
其中:authoritative:拒绝不合法ip请求
4:查看windwos xp ip获取状态:
5:ping dhcp主机确认网络连接状态:
6:系统日志查看:
[root@cooca ~]# tali /var/log/messages
bash: tali: command not found
[root@cooca ~]# tail /var/log/messages
Jul :: cooca dhcpd: DHCPACK on 192.168.10.130 to :0c::2a:a2:6d (zkero-661eadb17) via eth0
Jul :: cooca dhcpd: DHCPREQUEST for 192.168.10.130 from :0c::2a:a2:6d (zkero-661eadb17) via eth0
Jul :: cooca dhcpd: DHCPACK on 192.168.10.130 to :0c::2a:a2:6d (zkero-661eadb17) via eth0
Jul :: cooca dhcpd: DHCPREQUEST for 192.168.10.130 from :0c::2a:a2:6d (zkero-661eadb17) via eth0
Jul :: cooca dhcpd: DHCPACK on 192.168.10.130 to :0c::2a:a2:6d (zkero-661eadb17) via eth0
Jul :: cooca dhcpd: DHCPREQUEST for 192.168.10.130 from :0c::2a:a2:6d (zkero-661eadb17) via eth0
Jul :: cooca dhcpd: DHCPACK on 192.168.10.130 to :0c::2a:a2:6d (zkero-661eadb17) via eth0
Jul :: cooca dhcpd: Wrote leases to leases file.
Jul :: cooca dhcpd: DHCPREQUEST for 192.168.10.130 from :0c::2a:a2:6d (zkero-661eadb17) via eth0
Jul :: cooca dhcpd: DHCPACK on 192.168.10.130 to :0c::2a:a2:6d (zkero-661eadb17) via eth0
其中可以看到:日志中显示的mac地址:00:0c:29:2a:a2:6d与zkero-661eadb17以及ip地址和查看xp系统mac地址与计算机名以及ip地址是一致的。