List All MACs on the Local Network
Per the manpage:
The
arptool manipulates or displays the kernel’s IPv4 network neighbor cache. It can add entries to the table, delete one or display the current content. ARP stands for Address Resolution Protocol, which is used to find the media access control address of a network neighbor for a given IPv4 Address.
You can use the arp command to list all of the devices on the local network. It is often useful to find the identities of hidden devices on your network. For example, if you just plugged a Raspberry Pi into your local network and need to find its IP address in order to connect to it via SSH.
Netstat
My most frequently used netstat command with parameters for checking port (active internet) connections is:
$ netstat -tulpn
You can also pipe the output to grep to filter for specific ports or addresses.
Here is a brief listing of some of the many options:
$ netstat [options]
| Option | Action |
|---|---|
| -a | Display the state of all sockets, not just the active. |
| -c | Continuously display information, updating every second. |
| -i | Include network device statistics. |
| -n | Display all network addresses as numbers. |
| -o | Display additional information. |
| -r | Display routing tables. |
| -t | Display only the TCP sockets. |
| -u | Display only the UDP sockets. |
| -v | Print the netstat version number and exit. |
| -w | List only the raw sockets. |
| -x | Display only the Unix sockets. |
Find the IP Addresses of KVM Virtual Machines (Command Line)
To find details about the virtual network you can use these commands:
root@slacker:~# virsh net-listName State Autostart Persistent--------------------------------------------default active yes yesroot@slacker:~# virsh net-info defaultName: defaultUUID: 14a90f27-9a85-42ca-b434-6ce6c142690cActive: yesPersistent: yesAutostart: yesBridge: virbr0root@slacker:~# virsh net-dhcp-leases defaultExpiry Time MAC address Protocol IP address Hostname Client ID or DUID------------------------------------------------------------------------------------------------------------2023-07-22 16:18:45 52:54:00:dd:7b:62 ipv4 192.168.122.216/24 centos7-bbk -
List TCP Connections Sorted By Host and Most Connections
Assuming your system still has netstat installed (Slackware 15.0 does :^), you can summarize the TCP connections on you host using the following command:
$ netstat -ntu|awk '{print $5}'|cut -d: -f1 -s|sort|uniq -c|sort -nk1 -r3 52.50.230.xxx3 104.18.27.xxx3 104.18.26.xxx2 205.166.94.xx2 192.168.1.xx2 142.251.40.xxx2 104.18.13.xx1 74.120.9.xxx1 66.255.245.xxx1 54.154.65.xxx1 52.96.182.xxx1 45.56.116.xxx1 45.33.73.xxx1 34.117.65.xx1 20.190.135.xx1 192.168.122.xxx1 192.168.1.xx1 172.253.63.xxx1 162.159.61.x1 162.125.21.x1 142.251.40.xxx1 142.251.32.xxx1 142.251.16.xxx1 127.0.0.x
Test If a Port is Open with Bash
If netcat isn’t available on your machine and you don’t have the priviledge to install it you can use this trick to test if a port is open or not. It will throw a connection refused message if a port is closed.
$ : </dev/tcp/127.0.0.1/80
And you can use it in a script like this:
(: </dev/tcp/127.0.0.1/80) &>/dev/null && echo "OPEN" || echo "CLOSED"
Recover Your Wi-Fi Password from Windows CLI
In case you misplaced your wi-fi password you can recover it very easily using 2 commands on Windoze:
Open the Terminal or PowerShell
PS C:\Users\user> netsh wlan show profile
The output will be similar to this. You need to obtain the User Profile of the connection that you’re interested in:
Profiles on interface Wi-Fi:Group policy profiles (read only)---------------------------------<None>User profiles-------------All User Profile : ROUTER21All User Profile : 4YWD8-5GAll User Profile : 4YWD8