Troubleshooting connectivity
Network troubleshooting involves identifying and resolving problems that prevent devices from connecting to each other or accessing the internet. Let’s break down the essential concepts and introduce basic commands to help you gain a strong foundational understanding.
1. Key Networking Concepts:
IP Address: The unique address of your device on a network. IPv4 addresses are common, like
192.168.1.10, and IPv6 addresses look likefe80::1.Subnet Mask: Defines the range of IP addresses within your local network. Usually,
255.255.255.0for home networks.Gateway: This acts as an entry point for accessing other networks. Typically, it's your router’s IP, like
192.168.1.1.DNS (Domain Name System): Translates human-friendly domain names (like
google.com) to IP addresses. Your ISP usually provides this, but alternatives like8.8.8.8(Google’s DNS) are common.MAC Address: A hardware address unique to each network device.
2. Types of Issues:
Physical Layer Issues: Broken cables, faulty network adapters, or loose connections.
Network Layer Issues: Misconfigured IP addresses, incorrect gateways, or unavailable DNS.
Service Layer Issues: Issues with specific services like DNS or application services not responding.
3. Basic Commands and Their Uses:
These commands will help you diagnose each layer of the connection:
Checking Physical Connections:
ifconfigorip addr: These commands display all active network interfaces and their IP addresses.ethtool <interface>: Displays the status of an Ethernet cable and other details (Linux only).nmcli: If using NetworkManager, this command helps manage network connections.
Basic Connectivity Checks:
ping <destination>: This command sends packets to a destination (like an IP or domain) to check if the destination is reachable. For example:A successful ping means the target is reachable. If not, it may indicate a DNS or network connectivity problem.
Routing and Gateway Checks:
route -n: Displays the current routing table. You can verify if the default route (0.0.0.0) points to your gateway.ip route: Provides the same information in a modern way.
DNS Resolution:
nslookup <domain>ordig <domain>: Checks whether DNS resolution is working. Example:If these commands return an IP address for the domain, DNS is functioning. Otherwise, DNS may be misconfigured.
Traceroute:
traceroute <destination>(ortracertin Windows) traces the path that packets take to reach the destination. This command helps identify where connectivity breaks down.For example:
This will show each hop (router or gateway) that the packet traverses until it reaches the destination.
Inspecting Interfaces and Status:
ifconfigorip link show: Provides details about the network interfaces, including whether they are up or down.netstat -r: Lists the routing table and checks current network connections.nmcli device status: If NetworkManager is in use, it provides the status of interfaces.
Inspecting ARP and MAC Table:
arp -a: Displays the current ARP (Address Resolution Protocol) table, which helps diagnose if a device knows how to reach another local device.ip neigh: A modern equivalent for ARP information.
Testing Specific Ports:
telnet <hostname> <port>: Checks if a specific port on a host is accessible. For example, to test HTTP on a web server:nc -zv <hostname> <port>(Linux only): A more modern approach for checking if a specific service or port is open and listening.
4. Steps to Troubleshoot Connectivity:
Physical Checks: Ensure all cables are connected, network interfaces are enabled, and your device is in a functioning state.
Check IP Configuration: Run
ifconfigorip addrto see if you have a valid IP address and if your subnet, gateway, and DNS settings are correct.Check Basic Connectivity: Use
pingto verify if you can reach your gateway (e.g.,ping 192.168.1.1). If successful, try pinging a public IP like8.8.8.8to ensure external connectivity.Check DNS Resolution: If the IP connectivity works, try resolving domain names using
nslookupordig. If DNS doesn’t work, you might have to reconfigure or switch DNS servers.Check Routes: Use
route -norip routeto verify that you have a default route set up. If missing, set a route to your gateway.Trace Routes: If connectivity fails beyond your gateway, use
tracerouteto see where packets drop or get delayed.Inspect Application-Specific Issues: If all the above works, but specific applications fail, the problem could be port or firewall related. Check ports with
telnetornc.
5. Other Helpful Commands:
systemctl status NetworkManager: To verify the status of the NetworkManager service (if it’s managing connections).journalctl -u NetworkManager: To inspect logs related to NetworkManager.
Example Workflow:
Identify the problem: If a website is not loading, check your physical connection first.
Verify IP assignment: Run
ip addrto see if your device has a valid IP.Check connectivity to your gateway: Run
ping <gateway IP>.Check DNS resolution: Run
nslookup <domain>.Use traceroute to identify network-level issues beyond your gateway.
Final Notes:
Network troubleshooting requires a methodical approach, starting from the basics (like cables and IP addresses) and moving toward complex issues (like routing, DNS, or firewalls). By mastering these commands and steps, you'll be able to independently diagnose many common networking problems.
Feel free to ask if you have specific scenarios or want to practice with examples!
Last updated