Network Troubleshooting - ITCK

Kabul University
Information Technology Center
IT Manager Training Course
Linux Administration
Network Troubleshooting
Date: December 07,2016
1
Ping ➢
➢
➢
➢
PING (Packet INternet Groper) command is the best
way to test connectivity between two nodes
Whether it is Local Area Network (LAN) or Wide
Area Network (WAN)
Ping use ICMP (Internet Control Message Protocol) to
communicate to other devices
You can ping by host name or ip address
2
Ping ➢
In a shell window you simply type "ping" followed
by the URL or IP address of the computer you want
to test.
➢
ping www.google.com
➢
Ping 8.8.8.8
In Linux ping command keep executing until you
interrupt.
➢ You can terminate the process with Ctrl-c
➢
3
Ping ➢
4
Ping ➢
➢
By default, the ‘ping’ command will only send four
packets in Windows Operating Systems
the ‘ping’ command can be used to send an infinite
number of these small packets to the IP address
➢
ping www.google.com ­t
➢
Ping 8.8.8.8 -t
5
6
Ping ➢
➢
➢
By default ping waits for 1 second before sending
the next packet. You can increase or decrease this
using option -i as shown below
Increase Ping Time Interval
➢ ping -i 5 8.8.8.8
Decrease Ping Time Interval
➢ ping -i 0.1 8.8.8.8
7
Ping ➢
Before checking whether the peer machine is
reachable, first check whether the local
network network is up and running
i.Ping localhost using zero (0)
=>>ping 0
ii.Ping localhost using name
=>>ping localhost
iii.Ping localhost using ip
=>>ping 127.0.0.1
8
Ping ➢
➢
Send N packets and stop (In the following example,
ping command sends 5 packets)
=>>ping -c 5 8.8.8.8
Give beep when the peer is reachable
●
This option is useful for sysadmin during troubleshooting.
There is no need for you to look at the ping output after
each and every change. You can continue working with
your changes, and when the remote machine become
reachable you’ll hear the beep
automatically.
=>>ping ­a 8.8.8.8
9
Ping ➢
➢
Find out the IP address
=>>ping -c 1 google.com
Specify path for ping to send the packet
=>>ping hop1 hop2 hop3 .. hopN destination
=>>ping 192.168.3.33 192.168.7.1 192.168.4.45
10
Traceroute command
➢
➢
➢
traceroute is a network troubleshooting utility which
shows number of hops taken to reach destination
also determine packets traveling path
The traceroute command shows how a data
transmission travelled from a local machine to a
remote one
The traceroute command can show the route taken
and the IP and hostnames of routers on the network.
It can be useful for understanding latency or
diagnosing network issues.
11
traceroute
➢
To trace the route to a network host pass the ip address or
name of the server you want to connect to.
➢ =>>traceroute google.com
12
traceroute
➢
➢
➢
By default traceroute sends three packets for each
host so three response times are listed.
In this example the asterisks show packet loss. This
could mean a network outage, high amounts of
traffic leading to network congestion or a firewall
dropping traffic
To disable IP address mapping in traceroute use the ­n option.
➢
=>>traceroute -n google.com
13
traceroute
➢
To set the number of queries per hop in traceroute
use the -q option.
➢ =>>traceroute -q 1 google.com
➢
14
NETSTAT Command
➢
➢
➢
netstat (network statistics) is a command line tool for
monitoring network connections both incoming and
outgoing as well as viewing routing tables, interface
statistics etc
netstat is available on all Unix-like Operating
Systems and also available on Windows OS as well
Listing all the LISTENING Ports of TCP and UDP
connections
➢
=>>netstat -a | more
15
NETSTAT Command
➢
When you perform a "netstat -a" on your machine
and see a number of service ports listed as
"LISTENING". This means that some application is
running in the background and holding these ports
open in order to accept inbound connections.
16
17
NETSTAT Command
➢
Listing only TCP (Transmission Control Protocol) port
connections using netstat -at.
=>>netstat ­at
➢
Listing only UDP (User Datagram Protocol ) port
connections using netstat -au.
=>>netstat ­au
18
NETSTAT Command
➢
Listing all LISTENING Connections
=>>netstat ­l
➢
Listing all TCP Listening Ports
=>>netstat ­lt
➢
Listing all UDP Listening Ports
=>>netstat ­lu
➢
Displaying Service name with PID
=>>netstat ­tp
19
netcat command
➢
➢
nc is the command which runs netcat, a simple Unix utility that reads and writes data across network connections, using the TCP or UDP protocol
Netcat is a terminal application that is similar to the telnet program but has lot more features
20
How To Communicate through Netcat
➢
➢
Netcat is not restricted to sending TCP and UDP packets. It also can listen on a port for connections and packets.
This gives us the opportunity to connect two
instances of netcat in a client-server relationship.
21
How To Communicate through Netcat
➢
On one machine, you can tell netcat to listen to a specific port for connections. We can do this by providing the ­l parameter and choosing a port:
=>>netcat -l -p 50
➢
On a second server, we can connect to the first
machine on the port number we choose. We do this
the same way we've been establishing connections
previously:
=>>nc localhost/remote-host-ip 50
22
23
24
How To Send Files through Netcat
➢
➢
➢
Building off of the previous example, we can
accomplish more useful tasks.
Because we are establishing a regular TCP
connection, we can transmit just about any kind of
information over that connection
It is not limited to chat messages that are typed in by a user. We can use this knowledge to turn netcat into a file transfer program.
25
How To Send Files through Netcat
➢
➢
Once again, we need to choose one end of the
connection to listen for connections.
instead of printing information onto the screen, as
we did in the last example, we will place all of the
information straight into a file:
26
How To Send Files through Netcat
➢
PC1: >>netcat ­l ­P 33 > received_file
➢
PC2: echo "Hello, this is a file" > original_file
➢
PC2:>>netcat localhost/ip 33 < original_file
➢
PC1: cat received_file
27
Dig (Domain Information Groper)
➢
➢
➢
➢
nslookup is a command­line administrative tool for testing and troubleshooting DNS servers (Domain Name Server).
Most operating systems comes with built-in nslookup
feature.
Find out “A” record (IP address) of Domain
=>>nslookup yahoo.com
Find out Reverse Domain Lookup
=>>nslookup 209.191.122.70
28
Dig (Domain Information Groper)
➢
Dig stands for (Domain Information Groper) which is much similar to Linux Nslookup tool is a network administration command­line tool for querying Domain Name System (DNS) name servers.
It is useful for verifying and troubleshooting DNS
problems
➢ dig is part of the BIND domain name server software
suite.
➢
29
Dig (Domain Information Groper)
➢
Query Domain “A” Record with +short
=>>dig yahoo.com +short
➢
➢
DNS Reverse Look-up with +short
=>>dig -x 72.30.38.140 +short
host command to find name to IP or IP to name in IPv4 or IPv6 and also query DNS records.
=>>host www.google.com
30
31