我想将RPI(Raspbian Stretch)的eth0设置为DHCP,我的目标是当我连接任何使用TCP / IP协议进行通信的设备时,该设备将接收IP地址。
我发现很多指南都导致eth0 ip地址静态,这不是我的意图。
目前设备通过eth0连接,ifconfig
表示它有一些IP,但ping设备的主机名没有得到回复。 wlan0通过wifi连接。
这是一些信息:
pi@raspberrypi:~ $ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.31.197 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::ad5a:8219:4c27:b59b prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:f3:f2:87 txqueuelen 1000 (Ethernet)
RX packets 81 bytes 26568 (25.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 46 bytes 10544 (10.2 KiB)
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 31 bytes 3472 (3.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 31 bytes 3472 (3.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.71 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fd01::60ff:8818:5965:dc58 prefixlen 64 scopeid 0x0<global>
inet6 fe80::473d:110e:5474:8000 prefixlen 64 scopeid 0x20<link>
ether b8:27:eb:a6:a7:d2 txqueuelen 1000 (Ethernet)
RX packets 955 bytes 74427 (72.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 184 bytes 22096 (21.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
pi@raspberrypi:~ $ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
任何关于如何实现我的目标的建议都将得到愉快的接受。
您是否尝试过这样做:https://wiki.debian.org/NetworkConfiguration#Using_DHCP_to_automatically_configure_the_interface即将其添加到/ etc / network / interfaces:
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp
如果你真的很迂腐,你可以创建像/etc/network/interfaces.d/eth0-dhcp这样的文件并将这些行粘贴到其中 - 最终结果将是相同的。
NetWork Manager(nmcli)可能正在设备上运行,并且已配置为使用静态IP。
以下命令可以帮助您检查设备是否由nmcli管理:
运行以下命令,并将“有线连接1”替换为您的连接名称。
如果设置为DHCP,则ipv4.method将显示“auto”;如果设置为static,则显示“manual”。
http://www.intellamech.com/RaspberryPi-projects/rpi_nmcli.html