我正在尝试使用 Phytron MCC-1 电机控制器,该控制器仅通过 DHCP 获取其 IP(无需手动设置)。我在 ubuntu 上设置了 isc-dhcp-server,如下所示:
# /etc/dhcp/dhcpd.conf
option domain-name "example.org";
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
subnet 192.168.0.0 netmask 255.255.255.0 {
default-lease-time 21600;
option subnet-mask 255.255.255.0;
}
host phytronmcc1 {
hardware ethernet 00:50:c2:b2:11:75;
fixed-address 192.168.0.30;
option host-name "phytronmmc1";
}
我想使用 enxd8eb97b9a6d4 上的 dhcp 服务器:
$ ifconfig
enp0s25: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 134.158.40.174 netmask 255.255.248.0 broadcast 134.158.47.255
inet6 fe80::193c:fd36:6263:9faf prefixlen 64 scopeid 0x20<link>
ether 70:5a:0f:ee:1e:80 txqueuelen 1000 (Ethernet)
RX packets 129829774 bytes 87461213325 (87.4 GB)
RX errors 0 dropped 435 overruns 0 frame 0
TX packets 34660884 bytes 3579056486 (3.5 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 20 memory 0xd2200000-d2220000
enxd8eb97b9a6d4: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.31 netmask 255.255.255.0 broadcast 192.168.0.255
ether d8:eb:97:b9:a6:d4 txqueuelen 1000 (Ethernet)
RX packets 2563 bytes 117898 (117.8 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 4950 bytes 1034703 (1.0 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 1905619 bytes 23318260587 (23.3 GB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1905619 bytes 23318260587 (23.3 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlp62s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether fa:5e:ff:b8:4a:22 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
现在系统日志看起来很好,只是我看不到设备:
# /var/log/syslog
dhcpd[22892]: Internet Systems Consortium DHCP Server 4.3.5
dhcpd[22892]: Copyright 2004-2016 Internet Systems Consortium.
sh[22892]: For info, please visit https://www.isc.org/software/dhcp/
dhcpd[22892]: All rights reserved.
dhcpd[22892]: For info, please visit https://www.isc.org/software/dhcp/
dhcpd[22892]: Config file: /etc/dhcp/dhcpd.conf
sh[22892]: Config file: /etc/dhcp/dhcpd.conf
sh[22892]: Database file: /var/lib/dhcp/dhcpd.leases
sh[22892]: PID file: /run/dhcp-server/dhcpd.pid
dhcpd[22892]: Database file: /var/lib/dhcp/dhcpd.leases
dhcpd[22892]: PID file: /run/dhcp-server/dhcpd.pid
dhcpd[22892]: Wrote 0 deleted host decls to leases file.
dhcpd[22892]: Wrote 0 new dynamic host decls to leases file.
dhcpd[22892]: Wrote 0 leases to leases file.
dhcpd[22892]: Listening on LPF/enxd8eb97b9a6d4/d8:eb:97:b9:a6:d4/192.168.0.0/24
dhcpd[22892]: Sending on LPF/enxd8eb97b9a6d4/d8:eb:97:b9:a6:d4/192.168.0.0/24
sh[22892]: in your dhcpd.conf file for the network segment
sh[22892]: in your dhcpd.conf file for the network segment
dhcpd[22892]:
dhcpd[22892]: No subnet declaration for wlp62s0 (no IPv4 addresses).
dhcpd[22892]: ** Ignoring requests on wlp62s0. If this is not what
dhcpd[22892]: you want, please write a subnet declaration
dhcpd[22892]: in your dhcpd.conf file for the network segment
dhcpd[22892]: to which interface wlp62s0 is attached. **
dhcpd[22892]:
dhcpd[22892]:
dhcpd[22892]: No subnet declaration for enp0s25 (134.158.40.174).
dhcpd[22892]: ** Ignoring requests on enp0s25. If this is not what
dhcpd[22892]: you want, please write a subnet declaration
dhcpd[22892]: in your dhcpd.conf file for the network segment
dhcpd[22892]: to which interface enp0s25 is attached. **
dhcpd[22892]:
dhcpd[22892]: Sending on Socket/fallback/fallback-net
dhcpd[22892]: Server starting service.
使用wireshark只显示2帧:
Frame 7219: 188 bytes on wire (1504 bits), 188 bytes captured (1504 bits) on interface 0
Ethernet II, Src: Trendnet_b9:a6:d4 (d8:eb:97:b9:a6:d4), Dst: Broadcast (ff:ff:ff:ff:ff:ff)
Destination: Broadcast (ff:ff:ff:ff:ff:ff)
Source: Trendnet_b9:a6:d4 (d8:eb:97:b9:a6:d4)
Type: IPv4 (0x0800)
Internet Protocol Version 4, Src: 192.168.0.31, Dst: 192.168.0.255
User Datagram Protocol, Src Port: 17500, Dst Port: 17500
Dropbox LAN sync Discovery Protocol
Frame 7138: 60 bytes on wire (480 bits), 60 bytes captured (480 bits) on interface 0
Ethernet II, Src: Phytron-_01:75 (00:50:c2:b2:11:75), Dst: LLDP_Multicast (01:80:c2:00:00:0e)
Destination: LLDP_Multicast (01:80:c2:00:00:0e)
Source: Phytron-_01:75 (00:50:c2:b2:11:75)
Type: 802.1 Link Layer Discovery Protocol (LLDP) (0x88cc)
Link Layer Discovery Protocol
Chassis Subtype = Network address, Id: 0.0.0.0
0000 001. .... .... = TLV Type: Chassis Id (1)
.... ...0 0000 0110 = TLV Length: 6
Chassis Id Subtype: Network address (5)
Network Address family: IPv4 (1)
Chassis Id: 0.0.0.0
Port Subtype = MAC address, Id: 00:50:c2:b2:11:75
0000 010. .... .... = TLV Type: Port Id (2)
.... ...0 0000 0111 = TLV Length: 7
Port Id Subtype: MAC address (3)
Port Id: Phytron-_01:75 (00:50:c2:b2:11:75)
Time To Live = 120 sec
System Description = MCCe
0000 110. .... .... = TLV Type: System Description (6)
.... ...0 0000 0100 = TLV Length: 4
System Description: MCCe
End of LLDPDU
因此,显然设备存在但没有获取 IP。是我的 DHCP 配置问题吗?还是其他原因?我可以尝试什么吗?