Get device network name potentially different due to router #28

Open
opened 2024-06-14 23:41:16 +02:00 by Benjamin_Loison · 21 comments
sudo nmap -sP 192.168.1.0/24
Output:
Starting Nmap 7.80 ( https://nmap.org ) at 2024-06-14 23:33 CEST
Nmap scan report for CENSORED-1.home (192.168.1.XXX)
Host is up (0.0060s latency).
MAC Address: XX:XX:XX:XX:XX:XX (Unknown)
Nmap scan report for CENSORED.home (192.168.1.XXX)
...
Host is up.
Nmap done: 256 IP addresses (X hosts up) scanned in 10.73 seconds

Source: the Super User answer 850453

returns as wanted CENSORED-1 but how to only scan current device?

sudo nmap -sP 192.168.1.X
Output:
Starting Nmap 7.80 ( https://nmap.org ) at 2024-06-14 23:40 CEST
Nmap scan report for CENSORED-1.home (192.168.1.X)
Host is up (0.15s latency).
MAC Address: XX:XX:XX:XX:XX:XX (Unknown)
Nmap done: 1 IP address (1 host up) scanned in 0.29 seconds

How to avoid what looks like a network request, this information is cached somewhere in Linux, no?

Note that removing the sudo usage removes lines about MAC Addresses.

+33

```bash sudo nmap -sP 192.168.1.0/24 ``` <details> <summary>Output:</summary> ``` Starting Nmap 7.80 ( https://nmap.org ) at 2024-06-14 23:33 CEST Nmap scan report for CENSORED-1.home (192.168.1.XXX) Host is up (0.0060s latency). MAC Address: XX:XX:XX:XX:XX:XX (Unknown) Nmap scan report for CENSORED.home (192.168.1.XXX) ... Host is up. Nmap done: 256 IP addresses (X hosts up) scanned in 10.73 seconds ``` </details> Source: [the Super User answer 850453](https://superuser.com/a/850453) returns as wanted `CENSORED-1` but how to only scan current device? ```bash sudo nmap -sP 192.168.1.X ``` <details> <summary>Output:</summary> ``` Starting Nmap 7.80 ( https://nmap.org ) at 2024-06-14 23:40 CEST Nmap scan report for CENSORED-1.home (192.168.1.X) Host is up (0.15s latency). MAC Address: XX:XX:XX:XX:XX:XX (Unknown) Nmap done: 1 IP address (1 host up) scanned in 0.29 seconds ``` </details> How to avoid what looks like a network request, this information is cached somewhere in Linux, no? Note that removing the `sudo` usage removes lines about `MAC Address`es. +33
Author
Owner
man nmap
Output:
...
       -sn (No port scan)
           This option tells Nmap not to do a port scan after host discovery,
           and only print out the available hosts that responded to the host
           discovery probes. This is often known as a “ping scan”, but you can
           also request that traceroute and NSE host scripts be run. This is
           by default one step more intrusive than the list scan, and can
           often be used for the same purposes. It allows light reconnaissance
           of a target network without attracting much attention. Knowing how
           many hosts are up is more valuable to attackers than the list
           provided by list scan of every single IP and host name.

           Systems administrators often find this option valuable as well. It
           can easily be used to count available machines on a network or
           monitor server availability. This is often called a ping sweep, and
           is more reliable than pinging the broadcast address because many
           hosts do not reply to broadcast queries.

           The default host discovery done with -sn consists of an ICMP echo
           request, TCP SYN to port 443, TCP ACK to port 80, and an ICMP
           timestamp request by default. When executed by an unprivileged
           user, only SYN packets are sent (using a connect call) to ports 80
           and 443 on the target. When a privileged user tries to scan targets
           on a local ethernet network, ARP requests are used unless --send-ip
           was specified. The -sn option can be combined with any of the
           discovery probe types (the -P* options, excluding -Pn) for greater
           flexibility. If any of those probe type and port number options are
           used, the default probes are overridden. When strict firewalls are
           in place between the source host running Nmap and the target
           network, using those advanced techniques is recommended. Otherwise
           hosts could be missed when the firewall drops probes or their
           responses.

           In previous releases of Nmap, -sn was known as -sP.
...
```bash man nmap ``` <details> <summary>Output:</summary> ``` ... -sn (No port scan) This option tells Nmap not to do a port scan after host discovery, and only print out the available hosts that responded to the host discovery probes. This is often known as a “ping scan”, but you can also request that traceroute and NSE host scripts be run. This is by default one step more intrusive than the list scan, and can often be used for the same purposes. It allows light reconnaissance of a target network without attracting much attention. Knowing how many hosts are up is more valuable to attackers than the list provided by list scan of every single IP and host name. Systems administrators often find this option valuable as well. It can easily be used to count available machines on a network or monitor server availability. This is often called a ping sweep, and is more reliable than pinging the broadcast address because many hosts do not reply to broadcast queries. The default host discovery done with -sn consists of an ICMP echo request, TCP SYN to port 443, TCP ACK to port 80, and an ICMP timestamp request by default. When executed by an unprivileged user, only SYN packets are sent (using a connect call) to ports 80 and 443 on the target. When a privileged user tries to scan targets on a local ethernet network, ARP requests are used unless --send-ip was specified. The -sn option can be combined with any of the discovery probe types (the -P* options, excluding -Pn) for greater flexibility. If any of those probe type and port number options are used, the default probes are overridden. When strict firewalls are in place between the source host running Nmap and the target network, using those advanced techniques is recommended. Otherwise hosts could be missed when the firewall drops probes or their responses. In previous releases of Nmap, -sn was known as -sP. ... ``` </details>
Author
Owner
Related to [Benjamin_Loison/nmap/issues/2](https://codeberg.org/Benjamin_Loison/nmap/issues/2).
Author
Owner

Being able to directly retrieve IP from MAC address would be nice.

sudo nmap -sP 192.168.1.0/24 | grep 'XX:XX:XX:XX:XX:XX' -B2 | grep -Eo '192.168.1.[0-9]{,3}'

is not direct.

Related to the Security Stack Exchange question 117710.

Being able to directly retrieve IP from MAC address would be nice. ```bash sudo nmap -sP 192.168.1.0/24 | grep 'XX:XX:XX:XX:XX:XX' -B2 | grep -Eo '192.168.1.[0-9]{,3}' ``` is not direct. Related to [the Security Stack Exchange question 117710](https://security.stackexchange.com/q/117710).
Author
Owner

In the context of network issues of Benjamin-Loison/PrismLauncher/issues/2 I get CENSORED-3.home and after a network issue I get CENSORED.home. But do I have changed my internal IPv4/IPv6?

The aim is to avoid fixing and using an IP with https://livebox.

In the context of network issues of [Benjamin-Loison/PrismLauncher/issues/2](https://github.com/Benjamin-Loison/PrismLauncher/issues/2) I get `CENSORED-3.home` and after a network issue I get `CENSORED.home`. But do I have changed my internal IPv4/IPv6? The aim is to avoid fixing and using an IP with https://livebox.
Author
Owner
Related to [Benjamin-Loison/termux-app/issues/27](https://github.com/Benjamin-Loison/termux-app/issues/27).
Author
Owner
nmap -sP 192.168.1.0/24
Output:
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-08-08 11:20 CEST
...
Nmap scan report for Fairphone-4-5G (192.168.XXX.XXX)
Host is up (0.038s latency).
...
Nmap done: 256 IP addresses (X hosts up) scanned in 2.91 seconds
On wifi:
-----BEGIN PGP MESSAGE-----

hF4DTQa9Wom5MBgSAQdAPBqNyKB2kD5BJP7wYANLPggKYIRVug7TXsoL6LinAg0w
48JLICCfJ7G2+9XgnEdChKsuCyrxRZ1tRyPf96Gss/e9ZcS/HPjsz15vbQC9ypPk
0koBzaotaea4bWR9MG1IQ+5ENkM6ro6mMBOigWdBOdKBIGJIdTeAXHcY3dRx4zxf
wOwWEwE1xc4SehWsiWEkYGkgs3Mi1KaK3ivfug==
=sCEz
-----END PGP MESSAGE-----
```bash nmap -sP 192.168.1.0/24 ``` <details> <summary>Output:</summary> ``` Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-08-08 11:20 CEST ... Nmap scan report for Fairphone-4-5G (192.168.XXX.XXX) Host is up (0.038s latency). ... Nmap done: 256 IP addresses (X hosts up) scanned in 2.91 seconds ``` </details> <details> <summary>On wifi:</summary> ``` -----BEGIN PGP MESSAGE----- hF4DTQa9Wom5MBgSAQdAPBqNyKB2kD5BJP7wYANLPggKYIRVug7TXsoL6LinAg0w 48JLICCfJ7G2+9XgnEdChKsuCyrxRZ1tRyPf96Gss/e9ZcS/HPjsz15vbQC9ypPk 0koBzaotaea4bWR9MG1IQ+5ENkM6ro6mMBOigWdBOdKBIGJIdTeAXHcY3dRx4zxf wOwWEwE1xc4SehWsiWEkYGkgs3Mi1KaK3ivfug== =sCEz -----END PGP MESSAGE----- ``` </details>
Author
Owner

Related to Benjamin_Loison/virt-manager/issues/{49,43}.

Related to Benjamin_Loison/virt-manager/issues/{[49](https://codeberg.org/Benjamin_Loison/virt-manager/issues/49),[43](https://codeberg.org/Benjamin_Loison/virt-manager/issues/49)}.
Author
Owner
Related to [Benjamin_Loison/Debian/issues/55](https://codeberg.org/Benjamin_Loison/Debian/issues/55).
Author
Owner

Sometimes nmap does not return anything while the device connection to the network has not changed.

sudo nmap -p 22 192.168.1.0/24

Source: https://linuxhandbook.com/nmap-scan-ports/#scanning-a-specific-port

does not help for the just mentioned issue.

Sometimes nmap does not return anything while the device connection to the network has not changed. ```bash sudo nmap -p 22 192.168.1.0/24 ``` Source: https://linuxhandbook.com/nmap-scan-ports/#scanning-a-specific-port does not help for the just mentioned issue.
Author
Owner
Related to [Benjamin_Loison/openssh/issues/4](https://salsa.debian.org/Benjamin_Loison/openssh/-/issues/4).
Author
Owner

Would be nice to be compatible with FileZilla too.

Would be nice to be compatible with FileZilla too.
Author
Owner

Would help reduce noticing Benjamin_Loison/nmap/issues/1.

Would help reduce noticing [Benjamin_Loison/nmap/issues/1](https://codeberg.org/Benjamin_Loison/nmap/issues/1).
Author
Owner

Maybe can leverage Livebox DHCP.

Maybe can leverage Livebox DHCP.
Author
Owner
nmap -sP 192.168.XXX.XXX
Output:
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-12-31 04:27 CET
Nmap scan report for benjamin-loison-hp-debian.home (192.168.XXX.XXX)
Host is up (0.36s latency).
Nmap done: 1 IP address (1 host up) scanned in 0.36 seconds

Specifying both options seems to lead to the wanted output.

```bash nmap -sP 192.168.XXX.XXX ``` <details> <summary>Output:</summary> ``` Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-12-31 04:27 CET Nmap scan report for benjamin-loison-hp-debian.home (192.168.XXX.XXX) Host is up (0.36s latency). Nmap done: 1 IP address (1 host up) scanned in 0.36 seconds ``` </details> Specifying both options seems to lead to the wanted output.
Author
Owner
nmap -sP 192.168.221.11
Output:
Starting Nmap 7.95 ( https://nmap.org ) at 2025-01-01 00:54 CET
Nmap scan report for 192.168.221.11
Host is up (0.0039s latency).
Nmap done: 1 IP address (1 host up) scanned in 0.02 seconds

on Termux for my Debian 12 GNOME work laptop connected to it.

```bash nmap -sP 192.168.221.11 ``` <details> <summary>Output:</summary> ``` Starting Nmap 7.95 ( https://nmap.org ) at 2025-01-01 00:54 CET Nmap scan report for 192.168.221.11 Host is up (0.0039s latency). Nmap done: 1 IP address (1 host up) scanned in 0.02 seconds ``` </details> on Termux for my Debian 12 GNOME work laptop connected to it.
Author
Owner

On my Ubuntu 24 work laptop:

ip a
Output:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
2: eno1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    altname enp0s31f6
3: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff
    inet 192.168.221.11/24 brd 192.168.221.255 scope global dynamic noprefixroute wlp0s20f3
       valid_lft 3388sec preferred_lft 3388sec
    inet6 XXXX::XXXX:XXXX:XXXX:XXXX/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
nmap -sP 192.168.221.11
Output:
Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-01 00:56 CET
Nmap scan report for Benjamin-Loison-HP-Ubuntu (192.168.221.11)
Host is up (0.000045s latency).
Nmap done: 1 IP address (1 host up) scanned in 0.02 seconds
On my Ubuntu 24 work laptop: ```bash ip a ``` <details> <summary>Output:</summary> ``` 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host noprefixroute valid_lft forever preferred_lft forever 2: eno1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000 link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff altname enp0s31f6 3: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether XX:XX:XX:XX:XX:XX brd ff:ff:ff:ff:ff:ff inet 192.168.221.11/24 brd 192.168.221.255 scope global dynamic noprefixroute wlp0s20f3 valid_lft 3388sec preferred_lft 3388sec inet6 XXXX::XXXX:XXXX:XXXX:XXXX/64 scope link noprefixroute valid_lft forever preferred_lft forever ``` </details> ```bash nmap -sP 192.168.221.11 ``` <details> <summary>Output:</summary> ``` Starting Nmap 7.94SVN ( https://nmap.org ) at 2025-01-01 00:56 CET Nmap scan report for Benjamin-Loison-HP-Ubuntu (192.168.221.11) Host is up (0.000045s latency). Nmap done: 1 IP address (1 host up) scanned in 0.02 seconds ``` </details>
Author
Owner

On Termux:

getent
Output:
No command getent found, did you mean:
 Command gettext in package gettext
 Command gentest in package samba
 Command getopt in package util-linux

On my work laptop:

getent hosts Benjamin-Loison-HP-Ubuntu | awk '{ print $1 }'
127.0.1.1
On Termux: ```bash getent ``` <details> <summary>Output:</summary> ``` No command getent found, did you mean: Command gettext in package gettext Command gentest in package samba Command getopt in package util-linux ``` </details> On my work laptop: ```bash getent hosts Benjamin-Loison-HP-Ubuntu | awk '{ print $1 }' ``` ``` 127.0.1.1 ```
Author
Owner

On Termux on home wifi:

ping -c 1 Benjamin-Loison-HP-Ubuntu
Output:
PING Benjamin-Loison-HP-Ubuntu.home (192.168.1.36) 56(84) bytes of data.
64 bytes from benjamin-loison-hp-ubuntu.home (192.168.1.36): icmp_seq=1 ttl=64 time=40.3 ms

--- Benjamin-Loison-HP-Ubuntu.home ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 40.386/40.386/40.386/0.000 ms

See Benjamin-Loison/android/issues/156.

On Termux on home wifi: ```bash ping -c 1 Benjamin-Loison-HP-Ubuntu ``` <details> <summary>Output:</summary> ``` PING Benjamin-Loison-HP-Ubuntu.home (192.168.1.36) 56(84) bytes of data. 64 bytes from benjamin-loison-hp-ubuntu.home (192.168.1.36): icmp_seq=1 ttl=64 time=40.3 ms --- Benjamin-Loison-HP-Ubuntu.home ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 40.386/40.386/40.386/0.000 ms ``` </details> See [Benjamin-Loison/android/issues/156](https://github.com/Benjamin-Loison/android/issues/156).
Author
Owner

When suffer the issue should try doc.ubuntu-fr.org: zeroconf#hostname-2.local (1707753073).

ps -ef | grep -i [a]vahi
Output:
avahi       1536       1  0 Jan27 ?        00:00:01 avahi-daemon: running [Benjamin-Loison-HP-Debian.local]
avahi       1547    1536  0 Jan27 ?        00:00:00 avahi-daemon: chroot helper

I also have read Wikipedia: Multicast DNS (1246373221).

When suffer the issue should try [doc.ubuntu-fr.org: zeroconf#hostname-2.local (1707753073)](https://doc.ubuntu-fr.org/zeroconf?rev=1707753073#hostname-2local). ```bash ps -ef | grep -i [a]vahi ``` <details> <summary>Output:</summary> ``` avahi 1536 1 0 Jan27 ? 00:00:01 avahi-daemon: running [Benjamin-Loison-HP-Debian.local] avahi 1547 1536 0 Jan27 ? 00:00:00 avahi-daemon: chroot helper ``` </details> I also have read [Wikipedia: Multicast DNS (1246373221)](https://en.wikipedia.org/w/index.php?title=Multicast_DNS&oldid=1246373221).
Author
Owner

Related to my Debian 12 GNOME laptop ~/.ssh/config.

Related to my Debian 12 GNOME laptop `~/.ssh/config`.
Author
Owner
sudo nmap -sP 192.168.1.0/24
Output:
Starting Nmap 7.93 ( https://nmap.org ) at 2025-01-28 21:50 CET
Nmap scan report for livebox.home (192.168.1.1)
Host is up (0.0071s latency).
MAC Address: XX:XX:XX:XX:XX:XX (Ingram Micro Services)
Nmap scan report for CENSORED.home (192.168.1.XXX)
Host is up (0.21s latency).
MAC Address: XX:XX:XX:XX:XX:XX (Intel Corporate)
...
Host is up.

There is .home as well.

```bash sudo nmap -sP 192.168.1.0/24 ``` <details> <summary>Output:</summary> ``` Starting Nmap 7.93 ( https://nmap.org ) at 2025-01-28 21:50 CET Nmap scan report for livebox.home (192.168.1.1) Host is up (0.0071s latency). MAC Address: XX:XX:XX:XX:XX:XX (Ingram Micro Services) Nmap scan report for CENSORED.home (192.168.1.XXX) Host is up (0.21s latency). MAC Address: XX:XX:XX:XX:XX:XX (Intel Corporate) ... Host is up. ``` </details> There is `.home` as well.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Benjamin_Loison/linux#28
No description provided.