Debugging Local Network Issues with resolvectl and ss

Debugging Local Networks with resolvectl and ss

When I’m dealing with local network issues, I always reach for two essential tools: resolvectl and ss. These utilities provide valuable insights into DNS resolution and network socket connections, making it easier to identify and troubleshoot common network problems.

resolvectl for DNS Troubleshooting

I’ve seen this go wrong when DNS resolution fails, and resolvectl is a lifesaver. This command-line utility lets you query and control the systemd-resolved service, which handles DNS resolution on many modern Linux distributions. With resolvectl, you can perform DNS lookups, check the status of DNS servers, and even override default DNS settings for troubleshooting purposes.

To perform a DNS lookup using resolvectl, you can use the following command:

resolvectl query example.com

This will show you the DNS records for the specified domain, including the IP addresses associated with it. Don’t bother with other tools like dig or host when you have resolvectl - it’s more powerful and flexible.

Inspecting Network Sockets with ss

The real trick is to use ss to inspect network socket connections on your system. It provides detailed information about active connections, including the protocol, source and destination IP addresses, and port numbers. I usually start with the following command to list all active TCP connections:

ss -t -a

This will show you a list of all active TCP connections, including the source and destination IP addresses and port numbers. In practice, this helps you identify which services are listening on which ports and which connections are active.

Advanced Troubleshooting with resolvectl and ss

This is where people usually get burned - trying to troubleshoot network issues without the right tools. By combining resolvectl and ss, you can perform advanced network troubleshooting tasks, such as identifying DNS resolution issues or inspecting network connections to specific services.

For example, to inspect all network connections to a specific DNS server, you can use the following commands:

resolvectl query example.com
ss -t -a | grep <dns_server_ip>

This will show you the DNS records for the specified domain, as well as all active TCP connections to the DNS server.

Additional Resources

If you want to learn more about using resolvectl and ss, check out the systemd-resolved documentation and the ss man page. These resources will help you master these essential tools and improve your Linux networking skills.


See also