How to check the IP of my Raspberry Pi?


25 posts
by anta40 » Thu Nov 22, 2012 4:50 am
Hi,

Since I don't have USB keyboard, USB wifi adapter, and HDMI cable, my only option is to connect the Pi directly to my laptop using ethernet cable. I already bridged the internet connection before, and it seems OK (the LEDs are displaying rainbow colors).

Now the problem is how can I detect its IP address? Already tried using Angry IP scanner, but it didn't show up on the list.
User avatar
Posts: 10
Joined: Mon Nov 19, 2012 3:33 pm
Location: Jakarta, Indonesia
by antacti » Thu Nov 22, 2012 5:17 am
I've run into the same problem. I'm using my Pi as a headless system so I needed to find out the ip address so i could ssh into it. My solution was to log into the routers web interface and it listed the IP address of all the connected devices. I've also done bridged connections but those are a little trickier.

If your laptop is running linux you could try running
Code: Select all
$netstat -rn


That should list the routing of connected devices.

There should be an equivalent for MS but i don't know it.

Also check in the properties of the bridged connection. Chances are you will only be able to connect to the Rpi with the laptop unless your doing some port forwarding trickery
Posts: 14
Joined: Thu Nov 22, 2012 4:18 am
by anta40 » Thu Nov 22, 2012 6:40 am
My solution was to log into the routers web interface


Hmm I'm afraid I couldn't do that (i'm in the office now).
BTW, I just remember that not every device can access the wifi in the office.
Only those whose MAC addresses already registered can.

Could this affect the Pi?
User avatar
Posts: 10
Joined: Mon Nov 19, 2012 3:33 pm
Location: Jakarta, Indonesia
by anta40 » Thu Nov 22, 2012 7:16 am
BTW, this is the output of "netstat -rn" on my Windows laptop:
http://pastebin.com/jLVBzRR1

I'm not sure if the R Pi is listed there :?
User avatar
Posts: 10
Joined: Mon Nov 19, 2012 3:33 pm
Location: Jakarta, Indonesia
by sdjf » Thu Nov 22, 2012 12:11 pm
I will have the same issue when my Pi arrives. I see I do have the netstat command on my system. So if the ethernet connection is active, "netstat -rn" will give the Pi's IP as a destination? I thought I would have to know the IP in order enter into some config files before I could connect the device.

Will be using Zaurus PDA + USB Ethernet Adapter > crossover cable > Raspberry Pi
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1294
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by antacti » Fri Nov 23, 2012 4:41 am
I'm not too familiar how netstat works on a windows device, but from what I can find online it lists active TCP connections. If the 10M light is blinking on the pi then its an active connection. The pi should be on that list. Which one on that list? Thats beyond me. I'm a linux guy. If you feel gutsy you could try ssh ing into the different ones with the format pi@x.x.x.x since you know the username. Which ever one connects is your guy. The default password is raspberry. But then again I'm assuming that SSH is automatically enabled on the Pi.

I know when I share an internet connection on a Linux computer it changes the IP prefix (the first three numbers) for connected devices. On my computer thats 10.0.2.x. I have no idea how windows behaves. So this is a question for a greater mind than mine.


I can rule a few of the IP addresses out for you if case you wanna try the guess and check.

127.xxx.xxx.xxx IPs are loop back and local for the most part. I highly doubt these are the pi
you can also rule out anything with 255 as that denotes a broadcast
Also you can probably rule out anything ending in x.x.x.0

If you know the windows pc IP you could rule that out as well.
and if you know the IP of your router, that can also be ruled out.

if you run netstat -er or ern that will only list ethernet connnections, might narrow down the list

the n modifier displays the connections as "numerical". What ever that means.

http://www.computerhope.com/netstat.htm


Sorry its not an eloquent solution this is a bit outside me. Hopefully someone else can help out. What can I say. I'm a linux guy. Cheers.
Posts: 14
Joined: Thu Nov 22, 2012 4:18 am
by sdjf » Fri Nov 23, 2012 9:24 am
@antacti: This is the Arch subforum and I am going to be running Arch on my Pi and ssh'ing in from a Linux PDA.

The default ssh login password for the Pi is root, as is the username.

Does any part of your answer apply to sshing in to Arch from a Linux box?

I would hope someone out there knows what default IP is broadcast by a Pi when it's only connected to the Linux box via an Ethernet cable.

And it also looks like I need to read the man page for netstat, but I still do not understand whether the two devices will automatically know each other exists without some other action on my part than just plugging everything in and turning on the pi for it's initial boot. Yes, I am fairly sure ssh is enabled on Arch.
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1294
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by pepedog » Fri Nov 23, 2012 10:52 am
This is what I would do, install netcfg and use the example dhcp file
https://wiki.archlinux.org/index.php/Netcfg
At the bottom of the file put this
Code: Select all
POST_UP="ifconfig eth0:0 10.10.10.2"

The name of this file (which ends up in /etc/networl.d/) goes in /etc/conf.d/netcfg where it says last
Test with systemctl start netcfg, and ifconfig to see it has 2 ip addresses
Remove the dh... link in
/etc/systemd/system/multi-user.target.wants/
enable netcfg

Generally speaking, you can have more than 1 ip address for an interface, in this case one is fixed
Next rootfs will have 90% of this done, and probably go back to ext3 file system
Posts: 968
Joined: Fri Oct 07, 2011 9:55 am
by sdjf » Fri Nov 23, 2012 11:13 am
@pepedog: but what is the Ethernet IP of the Pi at the initial boot, before any packages can be installed? I thought we were supposed to be able to do the initial boot over Ethernet using a standard Ethernet cable without a switch or router.
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1294
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by pepedog » Fri Nov 23, 2012 1:58 pm
Are you talking about nfs boot?
I guess the static part might work there, just edit cmdline.txt
http://raspberrypi.org/phpBB3/viewtopic ... 974#p94693
Other arm devices do a similar thing
Otherwise no ip address is allocated
Posts: 968
Joined: Fri Oct 07, 2011 9:55 am
by sdjf » Fri Nov 23, 2012 5:21 pm
Thanks Pepedog, an answer and more questions.

I have no idea what an nfs boot is, I know command line file management stuff real well, but know nothing about booting systems other than pushing a reboot button. I will be sticking a freshly dd'd SD card into the Pi and turning it on the first time.

FYI, the first system I will be booting the Pi with is the old March 2012 Arch image since it majorly crashed my lower memory PDA several times trying to unpack and dd that image. So my plan has been to do my initial boot with the March image, and once that system is up and running, let it unpack and dd the newer hf system onto another SD card.

cmdline.txt on the March image I have has just one line:

dwc_otg.dma_enable=1 dwc_otg.dma_burst_size=256 dwc_otg.lpm_enable=0 dwc_otg.dma_enable=1 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 loglevel=2 smsc95xx.macaddr=08:00:28:00:60:01 root=/dev/mmcblk0p2 rootfstype=ext3 rootwait

I suppose I should change burst size to 512 since I am getting a 512 MB?

Then can I add the line suggested in the link you gave to cmdline.txt, without modification?

ip=192.168.2.223:192.168.2.225:192.168.2.1:255.255.255.0:rpi:eth0:off

Syntax apparently is:

ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>

Since the Pi is the server, does that mean it's IP would be 192.168.2.225?
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1294
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by pepedog » Fri Nov 23, 2012 5:28 pm
That's an old image. Don't alter burst size, nothing to do with memory
I haven't tried the ip settings, but I would think so.
Posts: 968
Joined: Fri Oct 07, 2011 9:55 am
by tzread » Fri Nov 23, 2012 6:31 pm
I did this using the command ifconfig, the only problem is that this needs to be done on the actual raspberry, so you sort of need to use a tv and keyboard with the pi to set it up. I couldn't find a way round this but there probably is.
Posts: 12
Joined: Wed Nov 14, 2012 9:48 pm
by antiloquax » Fri Nov 23, 2012 6:36 pm
I'm not sure if this helps at all but I use the android app Fing. It works a treat.
Posts: 406
Joined: Sun Nov 20, 2011 11:37 am
by sdjf » Fri Nov 23, 2012 7:00 pm
@pepedog: yeah, I know the image is old, but at that time, did not know it would be 8-9 months before my Pi materialized. It should work for the basic command line utilities I need it for. And to unpack and dd the most recent image to another SD card hooked up via USB. I know it will be slower than HF, but infinitely faster than if my 64MB PDA had to do the work.

And I am really happy for the guidance, I can hardly wait to get this working.

@tzread: no monitor or tv on site at all so I think will be editing cmdline.txt to set the Pi's ethernet IP address. The point of this is to know the ethernet IP before the initial boot so as to be able to ssh in over ethernet for the initial setup.

@antiloquax: That should be helpful for the person starting this threat or others reading it. For me, I can run command line networking tools on the PDA that I will be connecting via ethernet to the Pi. But I think I will need to tell the PDA what the host's IP is. There may be a tool that will scan for IPs but the Pi has to assign itself an IP as I will not be using a switch or router. I do not want the added expense of getting one of those when have no other need for them.
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1294
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by pepedog » Fri Nov 23, 2012 7:05 pm
It just occurred to me, on the old image you set ip address in /etc/rc.conf
Example there.
Job done
Posts: 968
Joined: Fri Oct 07, 2011 9:55 am
by sdjf » Fri Nov 23, 2012 9:30 pm
pepedog wrote:It just occurred to me, on the old image you set ip address in /etc/rc.conf
Example there.
Job done

But /etc/ is not available until after the initial boot. I cannot perform the initial boot without being ssh'd in via ethernet to complete the process, can I? Performing initial boot headless. Only have access to partition 1, the other is not opened up at this point.

Editing cmdline.txt will still work on the old one, won't it?
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1294
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by pepedog » Fri Nov 23, 2012 10:04 pm
I see.
Think cmdline.txt will work
Posts: 968
Joined: Fri Oct 07, 2011 9:55 am
by sdjf » Fri Nov 23, 2012 11:57 pm
cool. thanks.
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1294
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by sdjf » Tue Nov 27, 2012 5:17 pm
I am still a little confused. Since I am connecting the Pi directly to my PDA, am I correct in understanding that the gateway IP is defined or set by that line in cmdline.txt? And the first three parts of that four part IP have to match the numbers for the server and client IP, and the fourth part is unique even though there is not any independent device that is a gateway?

example was:

ip=192.168.2.223:192.168.2.225:192.168.2.1:255.255.255.0:rpi:eth0:off

Syntax:

ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>

Does the fourth number in the gateway IP have to be a 1? Or can it be any number I want it to be?
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1294
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by sdjf » Mon Dec 10, 2012 1:27 am
antacti wrote: If the 10M light is blinking on the pi then its an active connection.


I have switched to trying to do this over USB instead of ethernet. But I do not see a 10M light on my Pi, I see 5 LEDs labelled ACT, PWR, FDX, LNK and 100. Where is the 10M light?

And there is no network connection to the Pi from netstat -nr, all it shows on my main box is ppp0.
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1294
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by jojopi » Mon Dec 10, 2012 2:22 am
sdjf wrote:I have switched to trying to do this over USB instead of ethernet. But I do not see a 10M light on my Pi, I see 5 LEDs labelled ACT, PWR, FDX, LNK and 100. Where is the 10M light?
The "100" LED was erroneously labelled "10M" on earlier boards. (And "ACT" was "OK".)

The 100¬10M LED does not blink. It is LNK that blinks off when there is traffic on the interface. But actually, since the blinking is controlled in hardware, it does not really help to determine if the connection is working. It is quite possible for LNK to be blinking when the Pi has no IP address, for instance, due to broadcast traffic.
User avatar
Posts: 2103
Joined: Tue Oct 11, 2011 8:38 pm
by sdjf » Mon Dec 10, 2012 3:07 am
@jojopi: thank you. where do I learn about what the LEDs mean? Are they different colors? All I have seen at this point is PWR turning red.
FORUM TIP: To view just one person's posting history, sign in, click on their user name, then click on "Search User's Posts." || This Pi owner is running Arch on 512MB Model B.
Posts: 1294
Joined: Fri Mar 16, 2012 5:20 am
Location: California
by denwer » Mon Apr 29, 2013 9:37 pm
How I did this.

* Connect RPi and Windows machine with ethernet cable
* Install simple DHCP server (I used this one: http://www.dhcpserver.de/dhcpsrv.htm)
* Turn on RPi

After sme time DHCP server will give RPi a new IP and notify you about it.

Job is done.
Posts: 1
Joined: Mon Apr 29, 2013 9:29 pm
by startrek.steve » Tue Apr 30, 2013 8:35 am
Everyone is overthinking on this...
Logg into your router and find the pi in in the Lan clients section, it will display the IP in there.
User avatar
Posts: 53
Joined: Thu Aug 30, 2012 7:19 pm