isc-dhcp-server 与 /etc/network/interfaces 冲突 - 多个实例匹配同一子网

isc-dhcp-server 与 /etc/network/interfaces 冲突 - 多个实例匹配同一子网

我正在运行 Raspbian 并尝试运行 cmd服务 isc-dhcp-server 启动。这将返回消息

[FAIL] Starting ISC DHCP server: dhcpd[....] check syslog for diagnostics. ... failed!

我的/var/sys/日志文件包含

dhcpd: Wrote 0 leases to leases file.
dhcpd: Multiple interfaces match the same subnet: wlan0 eth0
dhcpd: Multiple interfaces match the same shared network: wlan0 eth0
dhcpd:
dhcpd: No subnet declaration for wlan1 (no IPv4 addresses).
dhcpd: ** Ignoring requests on wlan1.  If this is not what
dhcpd:    you want, please write a subnet declaration
dhcpd:    in your dhcpd.conf file for the network segment
dhcpd:    to which interface wlan1 is attached. **
dhcpd:
dhcpd:
dhcpd: Not configured to listen on any interfaces!

我的/etc/网络/接口包含

auto lo
iface lo inet loopback


iface wlan1 inet static
        address 192.168.42.1
        netmask 255.255.255.0


iface eth0 inet static
        address 192.168.1.100
        netmask 255.255.255.0
        gateway 192.168.1.1

allow-hotplug wlan0

iface wlan0 inet static
        address 192.168.1.200
        netmask 255.255.255.0
        gateway 192.168.1.1

wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

up iptables-restore < /etc/iptables.ipv4.nat

分解错误日志

多个接口匹配同一子网:wlan0 eth0

子网是否标记为地址在 - 的里面/etc/网络/接口文件?如果是这样,以太网0地址 192.168.1.100无线局域网0地址 192.168.1.200。这些是不同的。

此外。当我重新安排我的/etc/网络/接口按以下方式对块进行归档和排序

auto lo
iface lo inet loopback

iface eth0 inet static
        address 192.168.1.100
        netmask 255.255.255.0
        gateway 192.168.1.1

allow-hotplug wlan0

iface wlan0 inet static
        address 192.168.1.200
        netmask 255.255.255.0
        gateway 192.168.1.1

wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

iface wlan1 inet static
        address 192.168.42.1
        netmask 255.255.255.0

up iptables-restore < /etc/iptables.ipv4.nat

我的错误变量/系统/日志文件更改为仅

dhcpd: Wrote 0 leases to leases file.
dhcpd: No subnet declaration for wlan1 (no IPv4 addresses).
dhcpd: ** Ignoring requests on wlan1.  If this is not what
...

为什么前面的** dhcpd: 多个接口匹配同一子网: wlan0 eth0** 就因为这个文件的排序而消失了呢?如果它们匹配相同的子网,那么无论声明如何,它们都应该始终匹配,对吗?

答案1

eth0和的子网wlan0具有相同的子网/网络地址。

输入接口的子网地址(也称为网络地址)eth0192.168.1(又称为192.168.1.0)。它是通过“地址”和“网络掩码”的“逻辑与”来确定的。 “地址”是192.168.1.100,“网络掩码”是255.255.255.0

在十进制表示法中,数字位置的值为... 10000,1000,100,10,1。

以二进制表示法,值为... 128、64、32、16、8、4、2、1。

                           128 64 32 16 8 4 2 1 
 Since 192=128+64  it is     1  1  0  0 0 0 0 0  or 11000000  in binary.
 Since 168=128+32+8 it is    1  0  1  0 1 0 0 0  or 10101000  in binary.
 Since 1=1  it is            0  0  0  0 0 0 0 1  or 00000001  in binary.
 Since 100=64+32+4  it is    0  1  1  0 0 1 0 0  or 01100100  in binary.
 Since 200=128+64+8 it is    1  1  0  0 1 0 0 0  or 11001000  in binary.
 255=128+64+32+16+8+4+2+1 or 1  1  1  1 1 1 1 1  or 11111111  in binary.

要查找子网或网络地址,我们必须对“地址”和“网络掩码”进行“逻辑与”。 0 和 0 = 0、1 和 0 = 0、0 和 1 = 0、最后 1 和 1 = 1 的“逻辑与”。因此192.168.1.100 逻辑与255.255.255.0

                  11000000.10101000.00000001.01100100
 "logical and"    11111111.11111111.11111111.00000000  gives
                  11000000.10101000.00000001.00000000 which equals
                       192.     168.       1.       0  or 192.168.1.0 

同样符合192.168.1.200 逻辑并且255.255.255.0

                  11000000.10101000.00000001.11001000
 "logical and"    11111111.11111111.11111111.00000000  gives
                  11000000.10101000.00000001.00000000 which equals
                       192.     168.       1.       0  or 192.168.1.0 

因此,两个子网具有相同的地址,因此是同一子网。

解决方法是更改192.168.1.200​​为192.168.2.200或 更改192.168.1.100192.168.2.100

相关示例请参见DHCP服务器:为不同的接口提供不同的子网地址

相关内容