我需要我的Raspberry Pi 4為以太網連接的客戶端分配本地靜態IP


1

我需要在Raspberry Pi和特殊傳感器之間建立TCP / IP和/或UDP連接,該傳感器不是很可配置,但是具有以太網。通常,此傳感器連接到運行特殊軟件的PC或類似PC的設備(直接通過以太網)。Raspberry Pi和傳感器都無法訪問Internet。

因此,為了使他們能夠通信,我需要Raspberry Pi為該傳感器分配本地IP。我試圖設置沒有運氣的DHCP服務器,服務無法啟動。這是我的配置:

2

You can use systemd-networkd to simply configure the wired ethernet interface. Please follow to Use systemd-networkd for general networking. You can just use section ♦ Quick Step there and then come back here. To configure the eth0 interface, create this file:

rpi ~$ cat > /etc/systemd/network/04-wired.network <<EOF
[Match]
Name=e*
[Network]
Address=192.168.50.1/24
DHCPServer=yes
EOF

Connect the sensor and reboot.