Linux 的dhcp启动异常之No subnet declaration for eth1 (192.168.48.134)

    最近折腾Centos自动化安装,需要Linux的dhcp服务,使用yum -y install dhcp安装dhcp、dhcp-common的rpm包,启动dhcp时异常报错,

由于dhcp是操作系统及服务,关于dhcp启动失败可以查看操作系统日志/var/log/messages,使用service dhcpd start时报错如下:

[root@localhost log]# tail -f messages

May 13 20:30:45 localhost dhcpd: Internet Systems Consortium DHCP Server 4.1.1-P1
May 13 20:30:45 localhost dhcpd: Copyright 2004-2010 Internet Systems Consortium.
May 13 20:30:45 localhost dhcpd: All rights reserved.
May 13 20:30:45 localhost dhcpd: For info, please visit https://www.isc.org/software/dhcp/
May 13 20:30:45 localhost dhcpd: Not searching LDAP since ldap-server, ldap-port and ldap-base-dn were not specified in the config file
May 13 20:30:45 localhost dhcpd: Wrote 0 leases to leases file.
May 13 20:30:45 localhost dhcpd: 
May 13 20:30:45 localhost dhcpd: No subnet declaration for eth1 (192.168.48.134).
May 13 20:30:45 localhost dhcpd: ** Ignoring requests on eth1.  If this is not what
May 13 20:30:45 localhost dhcpd:    you want, please write a subnet declaration
May 13 20:30:45 localhost dhcpd:    in your dhcpd.conf file for the network segment
May 13 20:30:45 localhost dhcpd:    to which interface eth1 is attached. **
May 13 20:30:45 localhost dhcpd: 
May 13 20:30:45 localhost dhcpd: 
May 13 20:30:45 localhost dhcpd: Not configured to listen on any interfaces!
May 13 20:30:45 localhost dhcpd: 
May 13 20:30:45 localhost dhcpd: This version of ISC DHCP is based on the release available
May 13 20:30:45 localhost dhcpd: on ftp.isc.org.  Features have been added and other changes
May 13 20:30:45 localhost dhcpd: have been made to the base software release in order to make
May 13 20:30:45 localhost dhcpd: it work better with this distribution.
May 13 20:30:45 localhost dhcpd: 
May 13 20:30:45 localhost dhcpd: Please report for this software via the CentOS Bugs Database:
May 13 20:30:45 localhost dhcpd:     http://bugs.centos.org/
May 13 20:30:45 localhost dhcpd: 
May 13 20:30:45 localhost dhcpd: exiting.

    针对dhcp启动No subnet declaration for eth的报错,需要排查确认信息:

1、dhcp报错提示的ethn网卡与dhcp配置文件在同一网段确定subnet为192.168.48.0

[root@myserver tftpboot]# cat /etc/dhcpd.conf
ddns-update-style none; #设置DHCP服务器模式
ignore client-updates; #禁止客户端更新
subnet 192.168.48.0 netmask 255.255.255.0 { #设置网段
  option routers 192.168.48.254; #设置网关
  range  192.168.48.160 192.168.48.200; #设置dhcp服务器IP地址租用的范围
  default-lease-time 604800; #默认租约时间
  max-lease-time 605800; #最大租约时间
  next-server 192.168.48.134; #tftp服务器地址
  filename "pxelinux.0"; #tftp服务器根目录下面的文件名
}
[root@myserver tftpboot]# 

2、使用vmware虚拟机时,需要注意dhcp配置的subnet在eth0网卡Ip所在网段,并且eth0不能是hostonly,可以是桥接模式或NAT模式,

同时需要在linux主机内ping通vmware自己的网卡Ip地址。

    然后,启动dhcp不使用service dhcpd start而使用dhcpd -cf /etc/dhcpd.conf eth1在dhcp启动的时候指定dhcp监听的网卡,

dhcp启动就能正常启动了。

[root@myserver tftpboot]# dhcpd -cf /etc/dhcpd.conf eth1
Internet Systems Consortium DHCP Server 4.1.1-P1
Copyright 2004-2010 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
he config file
Wrote 2 leases to leases file.
Listening on LPF/eth1/00:0c:29:89:78:3d/192.168.48.0/24
Sending on   LPF/eth1/00:0c:29:89:78:3d/192.168.48.0/24
Sending on   Socket/fallback/fallback-net
[root@myserver tftpboot]# There's already a DHCP server running.
This version of ISC DHCP is based on the release available
on ftp.isc.org.  Features have been added and other changes
have been made to the base software release in order to make
it work better with this distribution.
Please report for this software via the CentOS Bugs Database:
    http://bugs.centos.org/
exiting.
[root@myserver tftpboot]# service dhcpd status
dhcpd (pid  2501) is running...
[root@myserver tftpboot]#

    如果需要开机自动启动dhcp,这时再使用命令chkconfig dhcp on,可以将dhcpd -cf /etc/dhcpd.conf eth1添加到/etc/rc.local










  • 4
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CentOS 6.5 DHCP服务器配置实例 【例题】 配置dhcp服务器,服务器IP为192.168.1.10,分配地址范围为:192.168.1.100- 192.168.1.200,网关地址为192.168.1.2,DNS地址为10.11.10.23和10.11.10.25,默认 租约为1小时,最大租约为2小时,为MAC地址为08:60:3E:4C:1D:90的计算机固定分配IP 地址为192.168.1.45。 【配置】 1. 安装dhcp服务器程序包: #yum install dhcp –y #使用yum安装dhcp服务器 2. 拷贝主配置文件模板: #cp –p /usr/share/doc/dhcp-4.1.1/dhcpd.conf.sample /etc/dhcpd.conf #拷贝模板 3. 编辑dhcp主配置文件:修改添加下列字段: subnet 192.168.1.0 netmask 255.255.255.0 { #网段和子网掩码,必须跟主机相同网段 range 192.168.1.100 192.168.1.200; #IP地址分配范围 option domain-name-servers 10.11.10.23,10.11.10.25; #DNS地址 option routers 192.168.1.2; #网关地址 default-lease-time 3600; #默认租约时间 max-lease-time 7200; #最大租约时间 } host pc1 { #主机名称(可以自定义) hardware ethernet 08:60:3E:4C:1D:90; #计算机的MAC地址 fixed-address 192.168.1.45; #固定分配的IP弟子 } 4. 启动dhcp服务器: #service dhcpd start #启动服务器 #chkconfig dhcpd on #设置DHCP服务器 3 5级别开启自启 【测试】 使用客户端连接服务器,IP地址设置为自动获取测试是否能正常获取到相应IP地址 【小结】 1. DHCP启动失败,可能是一下原因,分配的网段没有跟主机在同一网段;语法字段书 写不规范。 2. 客户机获取不到ip地址,检查iptables是否开启,如果开启,可以关闭或者配置放 行规则。 ----------------------- CentOS-6全文共2页,当前为第1页。 CentOS-6全文共2页,当前为第2页。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值