LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-04-2024, 09:40 AM   #1
imanipourmeysam
LQ Newbie
 
Registered: May 2024
Posts: 6

Rep: Reputation: 0
can not find ip address of connected raspberry pi via nmap


hi, I have a raspberry pi which is connected to interenet with my phone (via hotspot)
I am sure the raspberry pi is connected because I see it in the connected device in my phone.
I wanted to find the ip address of my raspberry pi so I can ssh into it.
I used this command "nmap -sn 192.168.45.0/24" but I don't find the ip of my raspberry pi via this command.
I found this command by googling how to find the ip address of connected device.
For the command I used 192.168.45.0/24 because in my windows machine when I type ipconfig in cmd, I see in section wireless LAN adapter WiFi, there is IPv4 which is 192.168.45.202
So I thought I need to do nmap -sn 192.168.45.0/24 but I don't still get the ip of raspberry pi.

both my pc and raspberry pi are connected to my internet of phone.
If the question is not clear please let me know to improve it.
 
Old 05-04-2024, 10:02 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,335
Blog Entries: 3

Rep: Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731
Welcome to LQ.

Perhaps your phone's tethering does not pass ping through? The -sn option is a ping scan and not a port scan. Since you are wish to connect to the Raspberry Pi, you might try a port scan on just the SSH port:

Code:
nmap -p 22 192.168.45.0/24
Or even if there is also a web server,

Code:
nmap -p 22,80,443 192.168.45.0/24
If you have HTTP and HTTPS up and running there, too.

See "man nmap"
 
Old 05-04-2024, 10:11 AM   #3
imanipourmeysam
LQ Newbie
 
Registered: May 2024
Posts: 6

Original Poster
Rep: Reputation: 0
Thank you for your reply,
I tried as you said
Code:
nmap -p 22 192.168.45.0/24
the output is as follow:
Code:
Starting Nmap 7.80 ( https://nmap.org ) at 2024-05-04 17:06 CEST
Nmap scan report for 192.168.45.4
Host is up (0.0071s latency).

PORT   STATE  SERVICE
22/tcp closed ssh

Nmap scan report for 192.168.45.208
Host is up (0.072s latency).

PORT   STATE  SERVICE
22/tcp closed ssh

Nmap done: 256 IP addresses (2 hosts up) scanned in 6.63 seconds
the ip 192.168.45.208 correspond to the washing machine in my home.
For the ip 192.168.45.4 I don't know what device is it.
But I know if I write ipconfig in cmd in windows, I see this ip as default gateway.
I know nothing about the network and these stuff, I tried ssh 192.168.45.4 but I get this:
ssh: connect to host 192.168.45.4 port 22: Connection refused
I don't think it's the ip address of my raspberry pi.
 
Old 05-04-2024, 10:13 AM   #4
imanipourmeysam
LQ Newbie
 
Registered: May 2024
Posts: 6

Original Poster
Rep: Reputation: 0
Smile

by the way, what do you mean by
You can send me to college, but you can't make me think.
 
Old 05-04-2024, 10:21 AM   #5
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,335
Blog Entries: 3

Rep: Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731
Can you check the Raspberry Pi itself this first time and 1) verify that OpenSSH is up and running, 2) that there is no packet filter blocking incoming TCP port 22, and 3) that your Raspberry Pi is on the same subnet as your legacy OS?

Code:
systemctl status ssh

sudo nft list ruleset

ifconfig
You can set a "signature" block of your own for your account here by going to the menu "Edit Profile" and then the menu item there "Edit Signature".
 
Old 05-04-2024, 10:40 AM   #6
imanipourmeysam
LQ Newbie
 
Registered: May 2024
Posts: 6

Original Poster
Rep: Reputation: 0
the issue is that I can't use my raspberry pi, (I don't have monitor or screen)
I was using only ssh to use my raspberry pi but now the ssh is not working and I don't know how I can follow your instruction.
like you said to do
Code:
systemctl status ssh

sudo nft list ruleset

ifconfig
I need maybe to get a screen and connect it to my raspberry then I try the things you told me.
 
Old 05-04-2024, 10:45 AM   #7
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,335
Blog Entries: 3

Rep: Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731
Quote:
Originally Posted by imanipourmeysam View Post
I need maybe to get a screen and connect it to my raspberry then I try the things you told me.
Yes, that is probably the next step, since it seem that the most likely reason for not showing up may be that it is either not connecting to the wi-fi or might not have OpenSSH-server running.

If you have a system which can read EXT4 file systems, a second approach might be to check the system files directly. But a far easier way is to connect the Raspberry Pi to a monitor or television long enough to ensure that it is connecting to the wi-fi and that OpenSSH-server is starting automatically using the raspi-config utility if necessary.

Out of curiosity, which method did you use to install the Raspberry Pi OS on the microSD card? Usually there is a step there to turn on SSH, but on some older versions of the rpi-imager utility there can be problems getting that to stick.

Last edited by Turbocapitalist; 05-04-2024 at 10:55 AM. Reason: typo
 
Old 05-04-2024, 10:59 AM   #8
imanipourmeysam
LQ Newbie
 
Registered: May 2024
Posts: 6

Original Poster
Rep: Reputation: 0
well I used dietpi image from this link : https://dietpi.com/#downloadinfo
Then I used a software called Rufus, to burn the image into sd card.
Then after that I opend ssd directory in my windows, and inside the file "dietpi.txt" set IP address that I will use for ssh connection.
Then I put the sd card into raspberry pi and then after first boot I was able to ssh into it.
I used to ssh for some days then after a week, I suddenly see I can no longer ssh into it.
here is a video that I followed for installation of dietpi os into sd card for raspberry.
https://www.youtube.com/watch?v=vlMpn9u0Y4o
 
Old 05-04-2024, 11:07 AM   #9
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,335
Blog Entries: 3

Rep: Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731
Thanks. If it used to connect, then that raises new questions. Since that is the case I think that checking it at its own console is the way to go. For now that means attaching a monitor or television, and a keyboard.

(Though later if you go really advanced and if you have a serial-to-USB adapter to connect to the right GPIO pins, you can prepare the system to use a serial console.)

By the way, both the rpi-imager and the Raspberry Pi OS image can be found here:

https://www.raspberrypi.com/software/

The option to install Raspberry Pi OS Lite might be the closest to dietpi.
 
Old 05-04-2024, 11:13 AM   #10
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,616

Rep: Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555Reputation: 2555
Quote:
Originally Posted by imanipourmeysam View Post
I am sure the raspberry pi is connected because I see it in the connected device in my phone.
How sure are you that the phone's information is accurate and up to date? (Could it be a list including previously connected devices?)

Can you send commands to the Pi from the phone itself? (e.g. via Termux/similar.)

 
Old 05-04-2024, 01:23 PM   #11
lvm_
Member
 
Registered: Jul 2020
Posts: 964

Rep: Reputation: 342Reputation: 342Reputation: 342Reputation: 342
On android simply open terminal and run 'ip neigh' to list all connected devices.
 
Old 05-05-2024, 02:06 AM   #12
imanipourmeysam
LQ Newbie
 
Registered: May 2024
Posts: 6

Original Poster
Rep: Reputation: 0
I actually see when I unplug the raspberry pi on there is new device added and when I plug it off, that device is gone from the connected list in my phone.
that's why I say that I am sure the raspberry pi is connected to the interenet.
 
Old 05-05-2024, 02:26 AM   #13
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,335
Blog Entries: 3

Rep: Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731Reputation: 3731
That's a good sign then. It is connecting to the LAN. However, it does look like OpenSSH-server is not running on the Raspberry Pi at the moment. As mentioned that would be the next thing to check once you can connect a screen to it.
 
Old 05-05-2024, 03:38 AM   #14
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,762

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
If you normally unplug the Pi without shutdown the filesystem may of become read only which maybe why you can see it but not login. As suggested the easiest way to check would be to attach a monitor and keyboard. You could use your Windows omputer but need a live linux distribution to actually check it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Find Devices Connected to Your Network with nmap LXer Syndicated Linux News 0 11-30-2018 04:21 PM
nmap ? how do i do nmap in linux ? command not found abbasakhtar Linux - Newbie 2 01-02-2011 01:08 AM
LXer: Learn how to use nmap, and nmap GUI, a great port scan tool LXer Syndicated Linux News 0 01-03-2008 09:10 AM
nmap increase send delay for nmap 4.20 matters Slackware 1 10-01-2007 11:37 PM
Cant nmap from but can nmap to procfs Linux - General 6 08-01-2006 02:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration