Centos 搭建dhcp服务器
dhcp是动态主机配置协议,使用udp协议,主要使用udp67和udp 68号端口
1client端会发送dhcp discover广播包
2dhcp服务器会回应dhcp offer广播包
3client端会发送dhcp request广播包
4dhcp服务器发送dhcp ack广播包
[root@mini ~]# rpm -qa dhcp
[root@mini ~]# cat /etc/centos-release
CentOS release 69 (Final)
[root@mini ~]# uname -r
2632-696el6i686
[root@mini ~]# uname -m
i686
[root@mini ~]# yum install -y dhcp
[root@mini ~]# rpm -qa dhcp
dhcp-411-53P1el6centos1i686
[root@mini ~]# rpm -qc dhcp
/etc/dhcp/dhcpdconf
/etc/dhcp/dhcpd6conf
/etc/openldap/schema/dhcpschema
/etc/portreserve/dhcpd
/etc/sysconfig/dhcpd
/etc/sysconfig/dhcpd6
/etc/sysconfig/dhcrelay
/etc/sysconfig/dhcrelay6
/var/lib/dhcpd/dhcpdleases
/var/lib/dhcpd/dhcpd6leases
[root@mini ~]# cat /etc/dhcp/dhcpdconf
#
# DHCP Server Configuration file
# see /usr/share/doc/dhcp/dhcpdconfsample
# see 'man 5 dhcpdconf'
#
查询dhcp sample文件(dhcpdconfsample文件为dhcp配置文件模板)
# rpm -ql dhcp
配置完成后的文件
[root@mini ~]# cat /etc/dhcp/dhcpdconf
#
# DHCP Server Configuration file
# see /usr/share/doc/dhcp/dhcpdconfsample
# see 'man 5 dhcpdconf'
#
# A slightly different configuration for an internal subnet
subnet 1721610 netmask 2552552550 {
range 17216110 17216130;
option domain-name-servers minilocaldomain;
option domain-name "minilocaldomain";
option routers 1721611;
option broadcast-address 1721611;
default-lease-time 600;
max-lease-time 7200;
}
查看配置是否正确
[root@mini ~]# /etc/initd/dhcpd configtest
Syntax: OK
DHCP启动失败,并查询到如下报错信息(/var/log/messages)
Nov 6 06:37:24 mini dhcpd: No subnet declaration for eth0 (19216828139)
Nov 6 06:37:24 mini dhcpd: Ignoring requests on eth0 If this is not what
Nov 6 06:37:24 mini dhcpd: you want, please write a subnet declaration
Nov 6 06:37:24 mini dhcpd: in your dhcpdconf file for the network segment
Nov 6 06:37:24 mini dhcpd: to which interface eth0 is attached
Nov 6 06:37:24 mini dhcpd:
Nov 6 06:37:24 mini dhcpd:
Nov 6 06:37:24 mini dhcpd: Not configured to listen on any interfaces!
Nov 6 06:37:24 mini dhcpd:
Nov 6 06:37:24 mini dhcpd: This version of ISC DHCP is based on the release available
Nov 6 06:37:24 mini dhcpd: on ftpiscorg Features have been added and other changes
Nov 6 06:37:24 mini dhcpd: have been made to the base software release in order to make
Nov 6 06:37:24 mini dhcpd: it work better with this distribution
Nov 6 06:37:24 mini dhcpd:
Nov 6 06:37:24 mini dhcpd: Please report for this software via the CentOS Bugs Database:
Nov 6 06:37:24 mini dhcpd: http://bugscentosorg/
Nov 6 06:37:24 mini dhcpd:
Nov 6 06:37:24 mini dhcpd: exiting
解决办法:
这是因为DHCP程序发现没有“Not configured to listen on any interfaces”,只需要配置相应的IP到目标网卡中便可以解决这个问题。
[root@mini ~]# ifconfig eth1 1721611/24
[root@mini ~]# /etc/initd/dhcpd start
Nov 6 06:43:11 mini dhcpd: Internet Systems Consortium DHCP Server 411-P1
Nov 6 06:43:11 mini dhcpd: Copyright 2004-2010 Internet Systems Consortium
Nov 6 06:43:11 mini dhcpd: All rights reserved
Nov 6 06:43:11 mini dhcpd: For info, please visit https://wwwiscorg/software/dhcp/
Nov 6 06:43:11 mini dhcpd: Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
Nov 6 06:43:11 mini dhcpd: Wrote 0 leases to leases file
Nov 6 06:43:11 mini dhcpd: Listening on LPF/eth1/00:0c:29:c5:2b:7e/1721610/24
Nov 6 06:43:11 mini dhcpd: Sending on LPF/eth1/00:0c:29:c5:2b:7e/1721610/24
Nov 6 06:43:11 mini dhcpd:
Nov 6 06:43:11 mini dhcpd: No subnet declaration for eth0 (19216828139)
Nov 6 06:43:11 mini dhcpd: Ignoring requests on eth0 If this is not what
Nov 6 06:43:11 mini dhcpd: you want, please write a subnet declaration
Nov 6 06:43:11 mini dhcpd: in your dhcpdconf file for the network segment
Nov 6 06:43:11 mini dhcpd: to which interface eth0 is attached
Nov 6 06:43:11 mini dhcpd:
Nov 6 06:43:11 mini dhcpd: Sending on Socket/fallback/fallback-net
[root@mini ~]# cat /var/lib/dhcpd/dhcpdleases
注意:如果Linux开启了防火墙,那么需要对UDP 67和UDP 68放行。或者直接将放火墙关闭
1、首先在IE浏览器中输入路由器地址19161,基本上都是19161或者191601。
2、,右击我的电脑,选择“管理”,然后打开“服务和应用程序”。2,再打开“服务”,找到DHCP,然后点击启用就行了。
3、在左边菜单栏里选择DHCP服务器——选择DHCP服务在右边的页面里,可以选择“开启”还是“关闭”DHCP服务器。
4、无线网络连接未启用DHCP的解决方法进入电脑后,打开开始菜单,然后再打开控制面板程序。
0条评论