DHCPD 忽略我的子网声明

DHCPD 忽略我的子网声明

eth0,我的内部接口,有一个静态地址10.0.0.1。我还有一个接口 ,p4p1作为我的外部接口。如果重要的话,我的外部接口没有物理连接并且iptables已关闭/仍在写入。

/etc/sysconfig/dhcpd:

DHCPDARGS=eth0

子网子句来自/etc/dhcpd.conf

subnet 10.0.0.0 netmask 255.255.255.0 {
  option routers 10.0.0.1;
  option domain-name-servers 10.0.0.1;
  option ntp-servers 10.0.0.1;
  default-lease-time 86400; # 1 day 
  max-lease-time 604800;    # 7 days
  use-host-decl-names on;
  ddns-updates on;

  use-host-decl-names on;
  allow unknown-clients;
  ignore client-updates;

  option domain-name "localdomain";
  ddns-domainname "localdomain";
  next-server 10.0.0.1;
  filename "pxelinux.0";

  group # known hosts
  {
    host host1.localdomain  {hardware ethernet [REDACTED]; fixed-address host1.localdomain;}
    host host2.localdomain  {hardware ethernet [REDACTED]; fixed-address host2.localdomain;}
  {

  pool
  {
    one-lease-per-client true;
    ping-check true;
    range 10.0.0.51 10.0.0.60;
  }
}

那么,为什么我在启动时仍然收到“无子网声明”错误消息?

No subnet declaration for eth0 (10.0.0.1).
** Ignoring requests on eth0.  If this is not what
   you want, please write a subnet declaration
   in your dhcpd.conf file for the network segment
   to which interface eth0 is attached. **

更新 4/1 1900h

在今晚的实验之前:

[root@father ~]# ip addr show dev eth0
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 90:e2:ba:2d:92:4d brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.1/24 brd 10.0.0.255 scope global eth0
    inet6 fe80::92e2:baff:fe2d:924d/64 scope link 
       valid_lft forever preferred_lft forever

我将内部网络 IP 地址切换为 ,192.168.100.0/24并将匹配的更改更改为 ,/etc/dhcpd.conf但行为没有变化。

[root@father ~]# ip addr show dev eth0
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 90:e2:ba:2d:92:4d brd ff:ff:ff:ff:ff:ff
    inet 192.168.100.1/24 brd 192.168.100.255 scope global eth0
    inet6 fe80::92e2:baff:fe2d:924d/64 scope link 
       valid_lft forever preferred_lft forever

[root@father ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 p4p1
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 p4p1
169.254.0.0     0.0.0.0         255.255.0.0     U     1003   0        0 eth0

噢!嗨!那里没有网关!使用 和 文件GATEWAY=192.168.0.1中的ifcfg-eth0和文件很容易修复ifcfg-p4p1service network restart和...

[root@father ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.100.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U     0      0        0 p4p1
169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 p4p1
169.254.0.0     0.0.0.0         255.255.0.0     U     1003   0        0 eth0
0.0.0.0         192.168.0.1     0.0.0.0         UG    0      0        0 p4p1

所以,我有一个网关,但service dhcpd start失败并出现同样的错误。

其他注意事项:

  • p4p1没有物理连接。
  • service dhcpd configtestSyntax: OK。因此,这几乎可以肯定不是支架错位的情况。

答案1

好吧,我能得到一个“D'oh!”吗?来自会众!

在 RHEL6 及衍生版本中,dhcpd 配置文件现在位于/etc/dhcp/dhcpd.conf,而不是/etc/dhcpd.conf.移动了文件,一切都很好。

答案2

您指定的子网掩码dhcpd.conf必须与您的接口子网掩码匹配。

跑步:

/sbin/ifconfig eth0

您将子网掩码指定为255.255.255.0,这很可能是错误的。更改您的dhcpd.conf以匹配您的界面。

DHCP 服务器侦听的接口必须具有与您在 DHCP 配置中使用的同一子网的静态 IP。

答案3

在 RedHatEnterprise 8.3 上,我的根本原因是防火墙。尽管firewalld启用了dhcp服务并且正在管理两个接口,但当firewalld停止时,dhcpd问题就消失了。我对 /etc/firewalld/zones/public.xml 进行了以下更改:

[root@lab-dns1 zones]# pwd
/etc/firewalld/zones
[root@lab-dns1 zones]# 
[root@lab-dns1 zones]# diff -c public.xml.20210304 public.xml
*** public.xml.20210304 2021-03-02 12:55:13.897419070 -0700
--- public.xml  2021-03-04 09:18:53.033552618 -0700
***************
*** 4,10 ****
    <description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
    <service name="ssh"/>
    <service name="ntp"/>
-   <service name="dhcp"/>
    <rule family="ipv4">
      <source address="10.220.18.0/25"/>
      <port port="53" protocol="tcp"/>
--- 4,9 ----
***************
*** 25,28 ****
--- 24,37 ----
      <port port="53" protocol="udp"/>
      <accept/>
    </rule>
+   <rule family="ipv4">
+     <source address="10.220.18.0/25"/>
+     <port port="67" protocol="udp"/>
+     <accept/>
+   </rule>
+   <rule family="ipv4">
+     <source address="10.220.99.0/24"/>
+     <port port="67" protocol="udp"/>
+     <accept/>
+   </rule>
  </zone>
[root@lab-dns1 zones]# 

相关内容