Question: What is the IP address of my Raspberry Pi?
Answer: in a shell, execute the following command:
sudo ifconfig
This will list the inet/IP address:
Happy IPing 🙂
Question: What is the IP address of my Raspberry Pi?
Answer: in a shell, execute the following command:
sudo ifconfig
This will list the inet/IP address:
Happy IPing 🙂
Hi Erich! Come to the Linux world and makes your PC a awesome thing 😉
LikeLike
I had started that journey a while back, and I think it is time to start sharing things from that world, even if it is the most basic thing 🙂
LikeLike
I think the problem is a bit more complicated, and generally affects many embedded devices with a TCP/IP connection. Most such devices, even small Cortex-M ones, running lwip and a simple web, are able to get a dynamic address via DHCP.
If the device is headless (i.e. has no display), how can you tell the address, so you can point your browser to it, or to open a ssh session?
Although this seems a minor problem, it is a real one. For example I have a J-Link with Ethernet, and to use it in Eclipse, I need to configure the IP address. When I asked SEGGER how to get it, I was suggested to check the router DHCP allocation table, but my Apple router does not provide access to this information, and up to know I could not use the expensive J-Link probe.
One workaround is to configure the DHCP server to allocate a static IP address, based on the MAC address, so at least the address will not change over time.
Although it depends on the type of the application, for devices that provide server type services, regardless of the protocol, the correct solution is to use a discovery protocol, and Bonjour (https://en.wikipedia.org/wiki/Bonjour_(software)) is such a good example.
LikeLike
Agreed, there is an even bigger problem if I cannot go to the device in question and ask what IP address it has. And I’m using the DHCP table of my server as a hint too.
LikeLike
In case of Raspberry Pi, the case is pretty easy: it is possible to set IP address by hand by adding “ip=xxx.xxx.xxx.xxx” at the end of cmdline.txt file. More details: http://elinux.org/RPi_cmdline.txt
I use this method every time I need to start using Raspberry Pi. In case of systems with UART this is even simpler.
LikeLike
Ah, that’s a very useful tip, thanks for sharing!
LikeLike
Pingback: Installing openHAB Home Automation on Raspberry Pi | MCU on Eclipse
I’ve used (successfully) nmap to discover my end nodes. See this link: http://security.stackexchange.com/questions/36198/how-to-find-live-hosts-on-my-network .
LikeLike
Use nmap to find devices on your network: nmap -sn 192.168.2.0/24
https://nmap.org/book/man-host-discovery.html
nmap is available for both Windows and Linux.
LikeLike
Hello Erich,
When using the Raspberry Pi with a HDMI screen it works, bun when using it headless, it doesn’t work. There is a workaround. You can use raspberry’s hostname to SSH into it, and then run ifconfig. For example, I have set my Raspberry’s hostname to AlexPi, and I can connect to it with PuTTY writing the hostname instead of the IP adress.
Alex
LikeLike
Hi Alex,
thanks for that hint! Another way I have used is to check the DHCP table of the router, then usually the IP address is easy to find.
LikeLike
Yes, you surely can check that, but sometimes you do not have the password for the router. If you use the Pi in a university or a school you don’t always have the acces to the DHCP table.
Alex
LikeLike