60.39 Useful Network Commands

We can find a list of hosts connected to the local network using the popular and powerful nmap application.

To scan our local network we first need to identify our network IP address and the network subnet mask. This is most readily obtained using ifconfig:

$ ifconfig              # List network interfaces
eth0      Link encap:Ethernet  HWaddr 00:a6:a9:a4:6e:a7  
          inet addr:192.168.178.11  Bcast:192.168.178.255  Mask:255.255.255.0
          inet6 addr: fa80::2a6:baff:fa74:6a87/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4759862 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5781951 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3159517671 (3.1 GB)  TX bytes:4083336807 (4.0 GB)
          Interrupt:17 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:949919 errors:0 dropped:0 overruns:0 frame:0
          TX packets:949919 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:307167934 (307.1 MB)  TX bytes:307167934 (307.1 MB)

From the eth0 entry we can see the host’s IP address is 192.168.178.11 and the mask is 255.255.255.0. From this we know that the IP address range for this network is 192.168.178.0 to 192.168.178.255. To scan this network range:

$ sudo nmap -sP 192.168.178.0/24    # List connected hosts
[sudo] password for kayon: 

Starting Nmap 6.40 ( http://nmap.org ) at 2014-01-11 08:40 EST
Nmap scan report for fritz.box (192.168.178.1)  # Router
Host is up (0.00041s latency).
MAC Address: 9C:27:A4:F0:87:6A (AVM GmbH)
Nmap scan report for ganesha (192.168.178.21)   # Web server
Host is up (0.00018s latency).
MAC Address: 11:14:B2:D1:EF:8F (Dell ESG Pcba Test)
Nmap scan report for belinos (192.168.178.23)   # Multimedia server
Host is up (0.000096s latency).
MAC Address: 40:16:2A:B4:AD:BA (Intel Corporate)
Nmap scan report for kyral (192.168.178.35) # Desktop
Host is up (0.00020s latency).
MAC Address: 01:6D:29:98:1C:FB (Dell)
Nmap scan report for soter.fritz.box (192.168.178.38) # Laptop
Host is up (0.015s latency).
MAC Address: B4:44:DE:1C:A2:C1 (Askey Computer)
Nmap scan report for rhesus (192.168.178.39)    # Media laptop
Host is up (0.015s latency).
MAC Address: 5C:4F:D6:A9:1A:39 (AzureWave)
Nmap scan report for brother-printer.fritz.box (192.168.178.40)
Host is up (0.00047s latency).
MAC Address: 10:1A:A3:23:5D:D1 (Brother Industries)
Nmap scan report for 192.168.178.41             # Laptop
Host is up (0.00026s latency).
MAC Address: 03:26:6C:79:FA:BA (Inventec)
Nmap scan report for theano (192.168.178.50)
Host is up (0.025s latency).
MAC Address: C4:55:08:35:7D:05 (Intel Corporate)
Nmap scan report for 192.168.178.61     # Wireless N Extender
Host is up (0.00072s latency).
MAC Address: 00:40:63:4A:B6:AF (Netcomm Limited)
Nmap scan report for nyx (192.168.178.22)
Host is up.
Nmap done: 256 IP addresses (11 hosts up) scanned in 1.36 seconds


Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0