网络上的每个设备都有一个Internet 协议(Internet Protocol)或IP 地址(IP address)。IP 地址是您在所有其他设备中识别网络上特定设备的方式,就像街道或邮政地址一样。如果你想连接到网络上的设备,你需要知道它的 IP 地址,有时这很难找到。
本文将向您展示如何发现连接到您的网络的(network)Raspberry Pi的 IP 地址。在某些情况下,您的 Pi 的 IP 地址可能是动态的。这意味着它可以改变。如果您的 Raspberry Pi 的 IP 地址发生了变化,您需要一种方法来找出它的新 IP。由于您可能有也可能没有连接到您的 Pi 的显示器,我们将引导您通过几种方法来查找您的 Pi 的 IP 地址(有和没有显示器)。
使用连接到树莓派的显示器(Monitor)和键盘(Keyboard Connected)查找树莓派的IP 地址(IP Address)
查找 Pi 的 IP 地址的最简单方法是直接登录 Pi,无论您是否安装了包含GUI桌面的操作系统。
如果您有无头安装(Headless Install)(没有Linux桌面)
如果您在 Pi 上安装的操作系统不包含GUI桌面,您可以使用终端窗口搜索您的 Raspberry Pi 的 IP 地址。
- 登录您的 Pi。
- 键入ip a并按Enter。
- IP 地址将以下列形式显示:inet 192.168.xx。(inet 192.168.x.x)
- 在上面的示例中,Raspberry Pi通过以太网连接到网络,因此 IP 地址出现在eth0部分。如果它通过 wifi 连接,则 IP 地址将出现在wlan0部分。
如果你有 Linux 桌面
如果您的Pi 上安装了带有Desktop的(Desktop)Raspberry Pi OS,您可以通过将鼠标悬停在右上角的时钟旁边的网络图标(两个箭头)上轻松找到您的 Pi 的 IP 地址。将出现一个信息面板,显示您的 Raspberry Pi 的网络连接。
如果您的 Pi 通过以太网连接到网络,您将在eth0之后看到您的 Raspberry Pi 的 IP 地址。在上图中,IP 地址为 192.168.1.179。忽略斜线和它后面的数字。(这告诉您子掩码。)如果您的 Pi 通过 wifi 连接到您的网络,您将在wlan0之后看到您的 Pi 的地址。
如何从同一网络(Same Network)上的Windows 计算机中找到您的 Pi 的(Windows Computer)IP 地址(IP Address)
以下是从同一网络上的另一台计算机上查找 Pi 的 IP 地址的几种简单方法。
使用主机名命令
使用 hostname 命令是从同一网络上的不同计算机发现 Raspberry Pi 的 IP 地址的好方法。
- 在与您的 Pi 在同一网络上的Windows计算机上,通过在搜索框中键入(Windows)cmd并按Enter来启动命令提示符。
- 在命令提示符窗口中,键入nslookup raspberrypi。
- 如上所示,nslookup 命令返回了两个结果。第一个是网关地址(路由器的地址),第二个是Raspberry Pi的 IP 地址。
- 注意:如果命令返回“*** [NAME_OF_YOUR_NETWORK] 找不到 raspberrypi:不存在的域”,这意味着 Pi 不在同一个网络上,您的命令中有错字,或者您的计算机没有'无权查询DNS服务器。
使用 Ping 命令
大多数网络设备都启用了 ping 命令,并且绝大多数Raspberry Pi OS映像都默认启用了 ping。但是,您的 Pi 上可能已禁用 ping 命令,因此无法保证这种识别 Pi 的 IP 地址的方法有效。
使用 ping 命令就像玩马可波罗(Marco Polo)的游戏。您大喊“Marco”,您的网络设备会响应“Polo”,从而泄露其位置。
- 在与您的 Pi 在同一网络上的Windows计算机上,通过在搜索框中键入(Windows)cmd并按Enter来启动命令提示符。
- 在命令提示符窗口中,键入ping raspberrypi并按Enter。
- 在上面的屏幕截图中,您可以看到 IP 地址多次显示。如果 ping 命令失败,它返回的 IP 地址可能仍然是正确的,所以看看它是否有效。
- 注意:如果 ping 无法在您的网络上找到Raspberry Pi,您将收到一条错误消息:“Ping 请求找不到主机 raspberrypi。请(Please)检查名称,然后重试。” 在这种情况下,请尝试以下方法之一。
如何使用第三方工具查找 Pi 的(Third Party Tools)IP 地址(IP Address)
网络(Network)扫描工具会遍历网络上所有可能的 IP 地址,并尝试检测任何可用的主机,例如Raspberry Pi。请记住,这些工具只有在您的计算机或手机与您的(Remember)Raspberry Pi位于同一网络(即连接到同一路由器)时才能工作。
使用愤怒的 IP 扫描仪
Angry IP Scanner是(Angry IP Scanner)Anton Keks的开源程序,深受许多Raspberry Pi用户的喜爱。最好从其GitHub页面下载Angry IP Scanner 。这样,您一定会获得最新版本。此工具适用于 windows、Mac OS和Linux。
(Install)在与您的 Pi 位于同一网络的另一台计算机上安装并运行Angry IP Scanner 。这种方法的优点是可以找到网络上的每台(every )设备。查找以raspberrypi(raspberrypi)开头的主机名的结果。警告:仅当您拥有网络时才运行此工具!
在智能手机上使用 Fing 应用程序
Fing 是一款适用于Android和iPhone的应用程序,可扫描您的本地网络并显示该网络上所有设备的 IP 地址。
运行Fing应用程序将生成网络上所有设备的列表。查找以raspberrypi开头的结果,您的 Pi 的 IP 地址将被列出。
What Is My Raspberry Pi’s IP Address?
Evеry device on a network has an Internet Protocol or IP address. The IP address is how you identify a specific device on your network among all the others, just like a street or postal address. If you want to connect to a device on your network, you need to know its IP address, and sometimes that can be hard to find.
This article will show you how to discover the IP address of a Raspberry Pi that’s connected to your network. In some cases, your Pi’s IP address could be dynamic. That means it can change. If your Raspberry Pi’s IP address has changed, you need a way to find out its new IP. Since you may or may not have a display connected to your Pi, we’ll walk you through a few ways to find your Pi’s IP address with and without a display.
Finding Your Raspberry Pi’s IP Address with a Monitor and Keyboard Connected to the Pi
The easiest way to find your Pi’s IP address is to sign into the Pi directly, whether or not you have installed an OS that includes a GUI desktop.
If You Have a Headless Install (no Linux desktop)
If the OS you installed on your Pi doesn’t include a GUI desktop, you can use the terminal window to search for your Raspberry Pi’s IP address.
- Sign into your Pi.
- Type ip a and press Enter.
- The IP address will appear in the following form: inet 192.168.x.x.
- In the example above, the Raspberry Pi is connected to the network via ethernet, so the IP address appears in the eth0 section. If it were connected over wifi, the IP address would appear in the wlan0 section.
If You Have a Linux Desktop
If you have a Raspberry Pi OS with Desktop installed on your Pi, you can easily find your Pi’s IP address by hovering your mouse over the network icon (two arrows) in the top-right corner, next to the clock. An information panel will appear showing your Raspberry Pi’s network connections.
If your Pi is connected to the network via ethernet, you’ll see your Raspberry Pi’s IP address after eth0. In the image above, the IP address is 192.168.1.179. Ignore the slash and the numbers after it. (That’s telling you the submask.) If your Pi is connected to your network via wifi, you’ll see your Pi’s address after wlan0.
How to Find Your Pi’s IP Address from a Windows Computer on the Same Network
Here are a couple easy ways to find your Pi’s IP address from another computer on the same network.
Use the Hostname Command
Using the hostname command is a good way to discover your Raspberry Pi’s IP address from a different computer on the same network.
- On a Windows computer that’s on the same network as your Pi, launch the command prompt by typing cmd into the search box and pressing Enter.
- In the command prompt window, type nslookup raspberrypi.
- As you can see above, the nslookup command has returned two results. The first is the gateway address (the address of your router), and the second is the IP address of your Raspberry Pi.
- Note: If the command returns “*** [NAME_OF_YOUR_NETWORK] can’t find raspberrypi: Non-existent domain,” that means either the Pi isn’t on the same network, you had a typo in the command, or your computer doesn’t have access to query the DNS server.
Use the Ping Command
Most network devices have the ping command enabled, and the vast majority of Raspberry Pi OS images do have ping enabled by default. However, it is possible that ping commands have been disabled on your Pi, so this method of identifying your Pi’s IP address isn’t guaranteed to work.
Using a ping command is like playing the game of Marco Polo. You shout, “Marco” and your network device responds, “Polo,” giving away its location.
- On a Windows computer that’s on the same network as your Pi, launch the command prompt by typing cmd into the search box and pressing Enter.
- In the command prompt window, type ping raspberrypi and press Enter.
- In the screencap above, you can see that the IP address is shown multiple times. If the ping command fails, the IP address it returns may still be correct, so see if it works.
- Note: If ping cannot find the Raspberry Pi on your network, you’ll get an error message that says, “Ping request could not find host raspberrypi. Please check the name and try again.” In this case, try one of the methods below.
How to Find Your Pi’s IP Address with Third Party Tools
Network scanner tools loop through every possible IP address on your network and try to detect any available hosts, like your Raspberry Pi. Remember, these tools will only work if your computer or phone is on the same network (i.e., connected to the same router) as your Raspberry Pi.
Use Angry IP Scanner
Angry IP Scanner is an open source program from Anton Keks and is beloved by many Raspberry Pi users. It’s best to download Angry IP Scanner from its GitHub page. That way you’ll be sure to get the latest release. This tool is available for windows, Mac OS, and Linux.
Install and run Angry IP Scanner on another computer on the same network as your Pi. This method has the advantage of finding every device on your network. Look for the result with a hostname that begins with raspberrypi. Warning: Only run this tool if you own the network!
Use the Fing App on Your Smartphone
Fing is an app available for Android and iPhone that scans your local network and displays the IP addresses of all the devices on that network.
Running the Fing app will yield a list of all the devices on your network. Look for the result starting with raspberrypi, and your Pi’s IP address will be listed.