In this post, I am gonna discuss few simple network troubleshooting tools and how it can be used in day to day work.
Network management is the essential understanding needed for any sysadmin and unix guy. It mainly used in the below scenarios,
failure detection of networks,gateways and other devices
monitoring and reporting the failure to system administrators
ensuring the availabilty of network connectivity among machines.
In a large enterprise network, due to increase in the number of machines connected it is essential to automate the network management through shell scripts and/or any automation framework. The efficiency of any system/network administrator is determined how fast he solves the problem which largely depends of how well his troubleshooting skills and awareness about network debugging tools. Here we are going to see few quick tips on how to use network debugging tools
ping
traceroute
netstat
tcpdump
ping
One of the simple command which most of unix users be aware of and of course the first command be used if anything goes wrong in machines connected to the network. It sends an ICMP_ECHO_REQUEST packet to a target machine and will wait for the response back.
purpose
To check whether the target system is reachable or can say alive or not. If the ping command doesn’t succeed means something went wrong in target machine or anyone of the interfacting devices ( like gateway , routers). If the firewall which blocks the ICMP requests , come in between then can decide based on ping results.
options
Most of the times, ping is used without any options but with host name / ip address.
t - timeout - time in secs before ping exits
-c - count - stop sending and receiving number ECHO_RESPONSE packets
examples
traceroute
This is second tool which is used after checking the ping results. It gives the list/sequence of gateways involved when an IP packets travels through to reach the target machine.( tracert - windows version )
purpose
If something went wrong in any of the gateway device in the travel path, traceroute will give which device went wrong. Also based on the results, one can find how far ( how many hops ) the target machine is from source machine.
options
-S - prints the summary
-v - verbose
examples
netstat
netstat Network Statistics tool, provides the rich information about the network connections, interface details and routing tables.
purpose
List network connections
Interface configuration details
Routing table details
Statistics for all n/w protocols
options
netstat without any options display only the active connections of TCP/UDP protocols.
-a - lists all connections including the listening ports
-n - shows n/w address as numbers
-p - display protocol specific details ( valid proto listed in /etc/protocols )
-i - state of auto-configured interface details
-r - shows routing tables
-s - display per protocol statistics
-v - verbose
examples
packet sniffers
Packet sniffers which is widely used by network security admins for debugging and ensuring the safety of the network. Its useful to give the solutions and sometimes to find the problems in the network as well. tcpdump - king of network sniffers, is widely used for this purpose. Other n/w sniffer tools are wireshark in windows, nettl in HP-UNIX, snoop in solaris
purpose
Listen to the network traffic and record/print the network packets sent/received to/from other destination machines.
options
-i any - listen to all interfaces
-i <intf> - specific to an interface
-n - Not to resolve hostnames
-nn - Not to resolve hostnames and ports
-X - display contents in ascii and hex
-S - show absolute sequence number
-e - display ethernet header
-s <size> - sanplength size for capturing the packets
-w - writing to a file
-r - reading from a file
tcpdump provides features to specify expression to filter various of n/w traffic. There are three types of expression as below
type : host(based on ip addr) , net ( capture entire n/w based on CIDR ) and port
dir : src, dst, src or dst, src and dst
proto : tcp , udp
Packet size filter is also possible based on expression less <size> , greater <size> , > and <=. tcpdump provides some advanced features like logical and grouping in the expression.