使用 isc-dhcp-server 和子接口获取“无 IPv4 地址”

使用 isc-dhcp-server 和子接口获取“无 IPv4 地址”

我已经尝试了子接口和辅助 IP 地址路由,但都不适用于 isc-dhcp-server。它拒绝获取正确的 IP。我正在使用 Debian 8 Jessie 和 ISC-DHCP-SERVER 4.3.1。

我的/etc/network/interfaces

## Corporate Network
auto eth0
allow-hotplug eth0
iface eth0 inet manual

## New Subnet
auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
    address 10.0.0.2
    gateway 10.0.0.1
    netmask 255.255.0.0
    dns-nameservers 127.0.0.1 10.0.0.3
    dns-search example.net
    dns-domain example.net

## Old Subnet
auto eth0:1
allow-hotplug eth0:1
iface eth0:1 inet static
    address 10.136.136.253
    netmask 255.255.255.0

如果配置

eth0      Link encap:Ethernet  HWaddr b8:27:eb:c0:59:e5
          inet6 addr: fe80::ba27:ebff:fec0:59e5/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:26688 errors:0 dropped:69 overruns:0 frame:0
          TX packets:7301 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:7174565 (6.8 MiB)  TX bytes:1286716 (1.2 MiB)

eth0:0    Link encap:Ethernet  HWaddr b8:27:eb:c0:59:e5
          inet addr:10.0.0.2  Bcast:10.0.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

eth0:1    Link encap:Ethernet  HWaddr b8:27:eb:c0:59:e5
          inet addr:10.136.136.253  Bcast:10.136.136.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

IP 地址

2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:c0:59:e5 brd ff:ff:ff:ff:ff:ff
    inet 10.0.0.2/16 brd 10.0.255.255 scope global eth0:0
       valid_lft forever preferred_lft forever
    inet 10.136.136.253/24 brd 10.248.28.255 scope global eth0:1
       valid_lft forever preferred_lft forever
    inet6 fe80::ba27:ebff:fec0:59e5/64 scope link
       valid_lft forever preferred_lft forever

启动 isc-dhcp-server 时的 /var/log/syslog

Aug 12 09:48:20 ns01 dhcpd: Wrote 0 deleted host decls to leases file.
Aug 12 09:48:20 ns01 dhcpd: Wrote 0 new dynamic host decls to leases file.
Aug 12 09:48:20 ns01 dhcpd: Wrote 5544 leases to leases file.
Aug 12 09:48:21 ns01 dhcpd:
Aug 12 09:48:21 ns01 dhcpd: No subnet declaration for eth0:1 (no IPv4 addresses).
Aug 12 09:48:21 ns01 dhcpd: ** Ignoring requests on eth0:1.  If this is not what
Aug 12 09:48:21 ns01 dhcpd:    you want, please write a subnet declaration
Aug 12 09:48:21 ns01 dhcpd:    in your dhcpd.conf file for the network segment
Aug 12 09:48:21 ns01 dhcpd:    to which interface eth0:1 is attached. **
Aug 12 09:48:21 ns01 dhcpd:
Aug 12 09:48:21 ns01 dhcpd:
Aug 12 09:48:21 ns01 dhcpd: No subnet declaration for eth0:0 (no IPv4 addresses).
Aug 12 09:48:21 ns01 dhcpd: ** Ignoring requests on eth0:0.  If this is not what
Aug 12 09:48:21 ns01 dhcpd:    you want, please write a subnet declaration
Aug 12 09:48:21 ns01 dhcpd:    in your dhcpd.conf file for the network segment
Aug 12 09:48:21 ns01 dhcpd:    to which interface eth0:0 is attached. **
Aug 12 09:48:21 ns01 dhcpd:
Aug 12 09:48:21 ns01 dhcpd: failover peer failover: I move from normal to startup
Aug 12 09:48:21 ns01 dhcpd: Server starting service.

答案1

因此,这对许多人来说可能是显而易见的,但您需要首先将相关接口的 DHCP 地址设置为手动(在我的情况下eno1,但通常如此eth1),并且手动 IP 地址应与 中的设置相匹配/etc/dhcp/dhcpd.conf。在 Ubuntu 22:04 上,这可以通过使用网络设置的界面来完成。

答案2

我最终在另一篇文章中找到了答案。需要将子网声明dhcpd.conf包装在共享网络声明中。

shared-network vlan1 {
    subnet 10.0.0.0 netmask 255.255.0.0 {
        ....
    }

    subnet 10.136.136.0 netmask 255.255.255.0 {
        ....
    }
}

相关内容