eth0 的静态 IP 地址未显示在我的 Raspberry Pi 上

问题描述

我正在使用带有 Raspbian Buster 的 RaspBerry Pi 3 B。我将它与 Wifi 连接起来,它可以正常工作,没有任何问题。我想启用接口 eth0,以便将我的 Raspbi 与 Profinet(一种工业协议)一起使用。 所以,我修改文件 /etc/dhcpcd.conf/:

/etc/dhcpcd.conf/

但是“ifconfig”的输出是:

eth0

“route -v”的输出是: route

我希望接口“eth0”的IP地址是静态的并且出现并且能够被ping通。我在其他论坛上尝试了很多东西,例如 this one修改文件 /etc/network/interfaces。但这没有用。我还将 eth0 接口设置为“sudo ifconfig eth0 [ipadress] netmask 255.255.255.0 up”。 Ma wifi 在此之后崩溃了......有人可以帮助我吗?我已经坚持了几个星期了。非常感谢。如果您有任何问题,我可以提供一些屏幕截图。

干杯

解决方法

自 Raspbian Stretch 以来使用文件 /etc/dhcpcd.conf 而不是代替 /etc/network/interfaces

使用您选择的编辑器,编辑 /etc/dhcpcd.conf,向下滚动到示例配置,如下图来自 mi Pi3B+,取消注释行并根据您的需要配置参数。

# Example static IP configuration:
#interface eth0
#static ip_address=192.168.0.10/24
#static ip6_address=xxxx:xxxx:xxxx:xxxx::ff/64
#static routers=192.168.0.1
#static domain_name_servers=192.168.0.1 8.8.8.8 xxxx:xxxx:xxxx:xxxx::1
,

更新/etc/dhcpcd.conf

interface eth0
static ip_address=192.168.0.10/24

重启dhcp服务

 sudo service dhcpcd restart

并且不要忘记通知您的路由器的 dhcp 租用,如果您希望此路由器不将此 ip 分配给其他材料,这将避免不稳定

,

也调用 ethtool eth0 作为输出:

Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes:   10baseT/Half 10baseT/Full 
                        100baseT/Half 100baseT/Full 
Supported pause frame use: Symmetric Receive-only
Supports auto-negotiation: Yes
Supported FEC modes: Not reported
Advertised link modes:  10baseT/Half 10baseT/Full 
                        100baseT/Half 100baseT/Full 
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Advertised FEC modes: Not reported
Speed: Unknown!
Duplex: Unknown! (255)
Port: MII
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Cannot get wake-on-lan settings: Operation not permitted
Current message level: 0x00000007 (7)
               drv probe link
Link detected: no

这里有一些关于我的问题的更多细节。我将非常感谢您的帮助