Sample Header Ad - 728x90

How do I get all MAC addresses of all devices on my LAN that have an IP address (equivalent of doas nmap -sn but for IPv6)?

0 votes
1 answer
125 views
#!/usr/bin/bash
echo "Give me your private IP and its mask";read given
if [[ "$given" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}/{0,1}[0-9]{1,3} ]]; then
    echo "version 4"
    doas nmap -sn "$given"
    arp
else
    echo "version 6"
    prefix=${given::6}
    mask=$(echo "$given"|sed -E 's|.*(/[0-9]{1,3})|\1|')
    echo "$mask"
    echo "$prefix"
    doas nmap -6 -sn "$given" #halts, I have to press Ctrl-C
    doas nmap -6 --script=neighbors "$given" #does not work
    doas nmap -6 --script=neighbors "$prefix$mask" #does not work
    doas ip -6 neighbour #empty line, no results
fi
Give me your private IP and its mask
fe80::xxxx:xxxx:xxxx:xxxx/64
version 6
/64
fe80::
doas (j@j-AERO-17-KC) password: 
Starting Nmap 7.80 ( https://nmap.org  ) at 2023-11-26 12:55 CET
Interrupt
doas (j@j-AERO-17-KC) password: 
Starting Nmap 7.80 ( https://nmap.org  ) at 2023-11-26 12:59 CET
NSE: failed to initialize the script engine:
/usr/bin/../share/nmap/nse_main.lua:818: 'neighbors' did not match a category, filename, or directory
stack traceback:

	/usr/bin/../share/nmap/nse_main.lua:818: in local 'get_chosen_scripts'
	/usr/bin/../share/nmap/nse_main.lua:1310: in main chunk


QUITTING!
doas (j@j-AERO-17-KC) password: 
Starting Nmap 7.80 ( https://nmap.org  ) at 2023-11-26 12:59 CET
NSE: failed to initialize the script engine:
/usr/bin/../share/nmap/nse_main.lua:818: 'neighbors' did not match a category, filename, or directory
stack traceback:

	/usr/bin/../share/nmap/nse_main.lua:818: in local 'get_chosen_scripts'
	/usr/bin/../share/nmap/nse_main.lua:1310: in main chunk


QUITTING!
I replaced with x some of the digits of my address - for the sake of preserving my privacy. **1.** Why does my script halt on doas nmap -6 -sn "$given" when an IPv6 address is given **2.** doas nmap -6 --script=neighbors "$prefix$mask" was suggested by ChatGPT to me - why doesn't it work? **3.** Why doesn't doas ip -6 neighbour work?
Asked by John Smith (827 rep)
Nov 26, 2023, 12:29 PM
Last activity: Dec 12, 2023, 10:16 AM