5 Essential Networking commands for quick Troubleshooting
As most of the organization these days have asked their employees to work from remote location due to covid crises and the duration may continue for some more time , even if the worksites are reopened most companies will probably support hybrid work mode, taking this into consideration most organization is transferring their work loads to cloud and asking their employees to start using virtual machines and containerized platforms like docker to deploy , build , test and integrate the projects so that things can done seamlessly in cloud.
As explained in the above paragraph to achieve the target criteria the process involves many Networking tasks for IT admin or for any developer in order to have smooth transition and setups. As a human nature we tend to create mistakes in the process hence here are few commands which can come handy during the process to troubleshoot Network related issues.
1. ipconfig
This command typically displays all the TCP/IP network configuration details including DNS, DHCP , netmask, IP version and gateway.
Following is the general syntax that is used :
ipconfig [/allcompartments] [/all] [/renew [<adapter>]] [/release [<adapter>]] [/renew6[<adapter>]] [/release6 [<adapter>]] [/flushdns] [/displaydns] [/registerdns] [/showclassid <adapter>] [/setclassid <adapter> [<classID>]]
The results looks something like below on windows host on linux the command is “ifconfig” does the same job as ipconfig.
ipconfig : Typically used to get IPAddress of the host
ipconfig /all : This will print details including hostname , status of DHCP and many more details.
2. nslookup
The command is used to check the Name server resolution and can also be used to check reverse forwarding meaning can check the DNS assigned for a given IP
- To check Nameserver details of the given IP : In this example it is resolving to reliance.reliance
2. performing a reverse lookup on the IP to get Nameserver details: In this example it is resolving to 192.168.29.1
3. ping
ping is the primary TCP/IP command used to troubleshoot connectivity, reachability, and name resolution.
- ping used without parameters, displays Help content.
ping to check the connectivity :
default number of packets sent is always = 4 , it can be modified using the count flag as below
Failure case when not reaching to a destination host for each packet it will print time out messages looks something like this
4. traceroute
A command-line utility that you can use to trace the path that a packet takes to its destination host.
Instead of nameserver we can also type in the IP of the destination that we are interested in , here each row indicates a hop that packet has made during its journey to reach the destination.
If the packet fails in the middle , lets say at row 6 and the packet is not finding no other machine to forward the data it indicates the failure in that particular junction helps to troubleshoot network connections very easily.
5. netstat
Displays active TCP connections, ports on which the computer is listening, Ethernet statistics, the IP routing table, IPv4 statistics (for the IP, ICMP, TCP, and UDP protocols), and IPv6 statistics (for the IPv6, ICMPv6, TCP over IPv6, and UDP over IPv6 protocols).
One of the main usecase of netstat is used to identify a PID of a process to to kill and restart process as and when required during the execution of testcases.
Used without parameters, this command displays active TCP connections.
To list the routing table details using -s flag → netstat -s
To define a fully qualified name of Domain Name (FQDN) → netstat -f
The second column indicates the port number to which the process is binding to.
command to list the port number , PID and protocol of a given process : netstat -ano -p tcp
furthur we can use → taskkill /F /PID command to kill the process using processID that we fetch from previous netstat command.
Reference Links
A must go to channel of network trouble shooting and to understand the networking concepts https://youtu.be/0Pk08wucjU8