Linux 树莓派没有IP地址?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17789947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:20:22  来源:igfitidea点击:

Raspberry Pi no IP address?

linuxipraspberry-pi

提问by Slidon

I want to transfer some files from my Mac to my Raspberry Pi via SSH, but when I try to find the Raspberry Pi's IP address with the ifconfig command in the lx terminal, the line which everyone says tells you the IP address is not there!, it's just gone. My terminal looks like this:

我想通过 SSH 将一些文件从我的 Mac 传输到我的 Raspberry Pi,但是当我尝试在 lx 终端中使用 ifconfig 命令查找 Raspberry Pi 的 IP 地址时,每个人都说的那行告诉您 IP 地址不存在! ,刚刚没了。我的终端看起来像这样:

      eth0      Link encap:Ethernet  HWaddr b8:27:eb:63:40:b8
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:27224 errors:0 dropped:0 overruns:0 frame:0
      TX packets:733 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:2801074 (2.6 MiB)  TX bytes:107019 (104.5 KiB)

      lo        Link encap:Local Loopback
      inet addr:127.0.0.1  Mask:255.0.0.0
      UP LOOPBACK RUNNING  MTU:16436  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

Because this is not from my actual Raspberry Pi, please don't make deductions from it. It's just since I can't transfer files from the Raspberry Pi I can't get a copy of the actual text.

因为这不是来自我实际的 Raspberry Pi,请不要从中进行推断。只是因为我无法从 Raspberry Pi 传输文件,所以我无法获得实际文本的副本。

Sorry for the code mess up, it looks exactly like this website: http://learn.adafruit.com/adafruits-raspberry-pi-lesson-3-network-setup/finding-your-pis-ip-address

抱歉代码搞砸了,它看起来就像这个网站:http: //learn.adafruit.com/adafruits-raspberry-pi-lesson-3-network-setup/finding-your-pis-ip-address

Except without line 2 in ethO.

除了在 ethO 中没有第 2 行。

采纳答案by deagh

You can add the IP address (until next reboot) with:

您可以添加 IP 地址(直到下次重新启动):

sudo ip addr add 192.168.0.100/32 dev eth0

回答by Dead-coder

You can also give your Raspberry Pi an IP address by adding 'ip = 192.168.0.4' at the end of cmdline.txt

您还可以通过在 cmdline.txt 末尾添加“ip = 192.168.0.4”来为您的 Raspberry Pi 提供 IP 地址

Do that using the command:

使用以下命令执行此操作:

sudo nano /boot/cmdline.txt

Make sure you add nothing else, not even a space or a return. After that, reboot your Raspberry Pi and type hostname -Ito see if the IP address is set.

确保不添加任何其他内容,甚至不添加空格或回车。之后,重新启动您的 Raspberry Pi 并键入hostname -I以查看是否设置了 IP 地址。

回答by user3725389

Configure your inet on the Raspberry Pi for auto (DHCP). Then, assign a fixed IP address to the Raspberry Pi using your router. That's very convenient and when considering the default configuration of the Raspberry Pi then you don't have to modify anything.

在 Raspberry Pi 上将您的 inet 配置为自动 ( DHCP)。然后,使用路由器为 Raspberry Pi 分配一个固定的 IP 地址。这非常方便,在考虑 Raspberry Pi 的默认配置时,您无需修改​​任何内容。

The appropriate line in /etc/network/inferfacesis:

适当的行/etc/network/inferfaces是:

iface eth0 inet dhcp

Regarding the router configuration: That's up to your device, but the manual should cover it.

关于路由器配置:这取决于您的设备,但手册应涵盖它。