1

Can you find out the IP Address of a Pi on a network where you don't have admin access (e.g. public Wi-Fi)? Can you do this via the Pi itself?

3

On the Pi itself you can find the IP address with the ip addr or hostname -I commands or from the Network Manager GUI (probably).

The official documentation has some tips on how to find the IP address from elsewhere on the network but something like ping raspberrypi.local might be the easier one to try first, depending on the OS you're using on the other device and if you've changed your Pi settings.

| improve this answer | |
  • 1
    Thanks for these suggesttions. I will try them out. – LegendusMaximus Dec 2 '19 at 12:58
  • 1
    And by the way, check out my other question on Google Drive (you can do this via my profile) – LegendusMaximus Dec 2 '19 at 12:59
4

If the local network is small (e.g. local IPv4 segment) or you know the exact pool of IP addresses of interest, you can find an open SSH port in seconds using nmap:

nmap -sS -p 22 192.168.10.0/24
| improve this answer | |
  • 1
    What happens if the network is huge? Any other way? – LegendusMaximus Dec 2 '19 at 12:17
  • 2
    @You can still use the same command, but depending on how huge the network is, it will take more time. It's still faster than reading router admin pages though. – Dmitry Grigoryev Dec 2 '19 at 12:35
  • 2
    I would use - preferably as root: nmap -n -sP 192.168.10.0/24 (ping sweep, no name resolution) because the SSH service may not be active on the Raspberry PI. In fact SSH is disabled on a default install. On the other hand the Raspberry PI will normally always respond to a ping. If you have lots of machines on the network you can also filter out by looking at the first half of the MAC addresses (DC:A6:32 or B8:27:EB). This nmap scan has to be done from another machine on the same network. – Anonymous Dec 2 '19 at 20:02
2

Open the Terminal and type

ifconfig

Output: It will list the Ip address of LAN,Wifi etc.

| improve this answer | |
  • 1
    ifconfig is deprecated. You should better advice to use ip addr. – Ingo Dec 3 '19 at 11:39
1

If you've got access to your Pi, you can use this answer. If not, use the command line of your laptop/linux pc/mac. Some of this won't work in Windows unless you've installed cygwin or the bash shell for windows

Try this first:

$ arp -a | grep --ignore-case b8:27:eb 

If you get a reply that looks like this, then there's your IP address!

? (192.168.1.131) at b8:27:eb:cd:2f:ff on en0 ifscope [ethernet]

If not, then your pi's arp cache doesn't have the IP address (details if you're interested). However, we can still find it with a 'brute force' search. There are several ways to do the search (e.g. nmap), but I'll show a method using bash 'cause it gives me an opportunity to practice :)

Copy the following into your editor, save it as pingpong.sh and make it executable:

#!/bin/sh
: ${1?"Usage: $0 ip subnet to scan. eg '192.168.0.'"}
subnet=$1
for addr in `seq 0 1 255 `; do
( ping -c 3 -t 5 $subnet$addr > /dev/null ) &
done
arp -a | grep b8:27:eb

Run the script with your network address as the only argument (my mac's IP is 192.168.1.75, and I know my RPi is on the same network):

$ ./pingpong.sh 192.168.1 

Note that the script uses the same arp command that we tried earlier. If it didn't work then, it was because your Pi wasn't in your computer's arp cache. However, since we've now pinged it, it is in the arp cache.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.