大网数据广告活动
服务器运维问答

No subnet declaration for WAN

· 52CE 我爱测

I have 2 netcards enp0s3 for WAN and enp0s8 for LAN. WAN has dynamic IP address (received from ISP). LAN has class C static IP address for my local network I have isc-dhcp-server with this config: nano /etc/dhcp/dhcpd.conf # ISC-…

问题原文

原帖链接 · acgbox · CC BY-SA 4.0

  • I have 2 netcards enp0s3 for WAN and enp0s8 for LAN.
  • WAN has dynamic IP address (received from ISP).
  • LAN has class C static IP address for my local network
  • I have isc-dhcp-server with this config:
nano /etc/dhcp/dhcpd.conf

# ISC-DHCP-Server Configuration
authoritative;
option wpad code 252 = text;
server-identifier 192.168.0.10;
deny duplicates;
one-lease-per-client true;
deny declines;
deny client-updates;
ping-check true;
log-facility local7;
ddns-update-style none;


    host user3 {
    hardware ethernet 40:e2:30:f4:00:04;
    fixed-address 192.168.0.90;
    }

    host user1 {
    hardware ethernet 40:e2:30:f4:00:02;
    fixed-address 192.168.0.50;
    }

class "blockdhcp" {
     match pick-first-value (option dhcp-client-identifier, hardware);
    }
    subclass "blockdhcp" 1:90:68:c3:00:00:00;

subnet 192.168.0.0 netmask 255.255.255.0 {
    option routers 192.168.0.10;
    option subnet-mask 255.255.255.0;
    option broadcast-address 192.168.0.255;
    #option domain-name "example.org";
    option domain-name-servers 8.8.8.8,8.8.4.4;
    min-lease-time 2592000; # 30 days
    default-lease-time 2592000; # 30 days
    max-lease-time 2592000; # 30 days
    pool {
        min-lease-time 60;
        default-lease-time 60;
        max-lease-time 60;
        deny members of "blockdhcp";
        range 192.168.0.100 192.168.0.250;
    }
}

The problem is that the isc-dhcp-server is showing error messages No subnet declaration for enp0s3 (10.0.2.15) because it asks me to assign a range for WAN, and this is not possible because it is dynamic and the ISP provider can eventually change the IP

sudo systemctl status isc-dhcp-server
● isc-dhcp-server.service - ISC DHCP IPv4 server
     Loaded: loaded (/lib/systemd/system/isc-dhcp-server.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-01-18 18:29:32 -05; 7min ago
       Docs: man:dhcpd(8)
   Main PID: 17055 (dhcpd)
      Tasks: 4 (limit: 19112)
     Memory: 4.9M
        CPU: 24ms
     CGroup: /system.slice/isc-dhcp-server.service
             └─17055 dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf

ene 18 18:29:32 uservm dhcpd[17055]: Sending on   LPF/enp0s8/08:00:27:8d:e7:c9/192.168.0.0/24
ene 18 18:29:32 uservm dhcpd[17055]: 
ene 18 18:29:32 uservm dhcpd[17055]: No subnet declaration for enp0s3 (10.0.2.15).
ene 18 18:29:32 uservm dhcpd[17055]: ** Ignoring requests on enp0s3.  If this is not what
ene 18 18:29:32 uservm dhcpd[17055]:    you want, please write a subnet declaration
ene 18 18:29:32 uservm dhcpd[17055]:    in your dhcpd.conf file for the network segment
ene 18 18:29:32 uservm dhcpd[17055]:    to which interface enp0s3 is attached. **
ene 18 18:29:32 uservm dhcpd[17055]: 
ene 18 18:29:32 uservm dhcpd[17055]: Sending on   Socket/fallback/fallback-net
ene 18 18:29:32 uservm dhcpd[17055]: Server starting service.

How do I avoid this situation so that these error messages that flood the log no longer appear? Thanks in advance

已采纳解答

原帖链接 · Nikita Kipriyanov · CC BY-SA 4.0

While the other answer is correct in that it is safe to ignore this warning, some people prefer "zero warning policy", by configuring the system in advance so it won't emit warnings for known situations. Then any warnings system will still generate would be meaningful and you won't accidentally miss them in the stream of "known and expected warnings".

You can configure dhcpd to only listen on interfaces that you want it to provide service on, which is configured in /etc/default/isc-dhcp-server:

INTERFACES="enp0s8"

(by default it is listening everywhere). On newer systems you might need to set it up like this:

INTERFACESv4="enp0s8"
INTERFACESv6=""

Other way to suppress the warning is to let it know the interface/subnet exists, but to not provide any service for it. There is an example how to do that in the stock dhcpd.conf file (probably not the one Ubuntu or Debian has installed in /etc):

# No service will be given on this subnet, but declaring it helps the 
# DHCP server to understand the network topology.

subnet 10.152.187.0 netmask 255.255.255.0 {
}

(replace it the network you have on the WAN NIC). This is exactly what the warning itself suggests.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2023-01-18)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。