Posted: . At: 11:32 AM. This was 2 years ago. Post ID: 16047
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


How to list interfaces with Nmap. This is a very useful tip.


It is possible to list interfaces with Nmap. This is a good way to see all active network devices attached to your computer. Use the –iflist parameter as shown below to show all network interfaces on your machine.

jason@jason-Lenovo-H50-55:~$ nmap --iflist
Starting Nmap 7.80 ( https://nmap.org ) at 2022-03-18 10:38 AEDT
************************INTERFACES************************
DEV     (SHORT)   IP/MASK                                    TYPE     UP MTU   MAC
enp0s25 (enp0s25) 192.168.1.2/24                             ethernet up 1500  D0:50:99:0D:AB:0F
enp0s25 (enp0s25) fe80::5b8d:5504:46d7:909/64                ethernet up 1500  D0:50:99:0D:AB:0F
enp0s25 (enp0s25) fdc8:1451:5fa9:4700:4cb3:855f:bd1f:3106/64 ethernet up 1500  D0:50:99:0D:AB:0F
enp0s25 (enp0s25) fdc8:1451:5fa9:4700:a015:eef:8696:632b/64  ethernet up 1500  D0:50:99:0D:AB:0F
lo      (lo)      127.0.0.1/8                                loopback up 65536
lo      (lo)      ::1/128                                    loopback up 65536
 
**************************ROUTES**************************
DST/MASK                                    DEV     METRIC GATEWAY
192.168.1.0/24                              enp0s25 100
169.254.0.0/16                              enp0s25 1000
0.0.0.0/0                                   enp0s25 100    192.168.1.1
::1/128                                     lo      0
fdc8:1451:5fa9:4700:4cb3:855f:bd1f:3106/128 enp0s25 0
fdc8:1451:5fa9:4700:a015:eef:8696:632b/128  enp0s25 0
fe80::5b8d:5504:46d7:909/128                enp0s25 0
::1/128                                     lo      256
fdc8:1451:5fa9:4700::/64                    enp0s25 100
fe80::/64                                   enp0s25 100
ff00::/8                                    enp0s25 256

To list only the active Ethernet addresses on your current PC, this one-liner will make this happen.

jason@jason-Lenovo-H50-55:~$ nmap --iflist | awk '/ethernet up/{print}'
enp0s25 (enp0s25) 192.168.1.2/24                             ethernet up 1500  D0:50:99:0D:AB:0F
enp0s25 (enp0s25) fe80::5b8d:5504:46d7:909/64                ethernet up 1500  D0:50:99:0D:AB:0F
enp0s25 (enp0s25) fdc8:1451:5fa9:4700:4cb3:855f:bd1f:3106/64 ethernet up 1500  D0:50:99:0D:AB:0F
enp0s25 (enp0s25) fdc8:1451:5fa9:4700:a015:eef:8696:632b/64  ethernet up 1500  D0:50:99:0D:AB:0F

To list only the active network interfaces and the interfaces that are IPv6, use this awk one-liner.

jason@jason-Lenovo-H50-55:~$ nmap --iflist | awk '/ethernet up/ && /\/64/{print}'
enp0s25 (enp0s25) fe80::5b8d:5504:46d7:909/64                ethernet up 1500  D0:50:99:0D:AB:0F
enp0s25 (enp0s25) fdc8:1451:5fa9:4700:4cb3:855f:bd1f:3106/64 ethernet up 1500  D0:50:99:0D:AB:0F
enp0s25 (enp0s25) fdc8:1451:5fa9:4700:a015:eef:8696:632b/64  ethernet up 1500  D0:50:99:0D:AB:0F

These tips should be very useful, it is great when you discover yet another way to find out networking information and use it to your advantage.

This is how to only list IPv4 network interfaces that are currently active.

jason@jason-Lenovo-H50-55:~$ nmap --iflist | awk '/ethernet up/ && /\/24/{print}'
enp0s25 (enp0s25) 192.168.1.2/24                             ethernet up 1500  D0:50:99:0D:AB:0F

Finally, this example will list all /24 and /64 network interfaces that are currently up and running.

jason@jason-Lenovo-H50-55:~$ nmap --iflist | awk '/ethernet up/ || /\/24/ {print}'
enp0s25 (enp0s25) 192.168.1.2/24                             ethernet up 1500  D0:50:99:0D:AB:0F
enp0s25 (enp0s25) fe80::5b8d:5504:46d7:909/64                ethernet up 1500  D0:50:99:0D:AB:0F
enp0s25 (enp0s25) fdc8:1451:5fa9:4700:4cb3:855f:bd1f:3106/64 ethernet up 1500  D0:50:99:0D:AB:0F
enp0s25 (enp0s25) fdc8:1451:5fa9:4700:a015:eef:8696:632b/64  ethernet up 1500  D0:50:99:0D:AB:0F
192.168.1.0/24                              enp0s25 100

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.