- Reference 23.1 Troubleshoot General Network Issues
- Reference 23.2 Use Terminal to Troubleshoot Network Issues
- Exercise 23.1 Troubleshoot Network Connectivity
Exercise 23.1 Troubleshoot Network Connectivity
In this exercise, you intentionally misconfigure your network settings. You then use the macOS built-in troubleshooting tools to view symptoms and isolate the problem.
Break Your Network Settings
Log in as Johnny Appleseed.
Open Network preferences, then authenticate as Local Administrator.
Record the currently selected location so that you can return to it at the end of the exercise.
From the Location menu, choose Edit Locations.
Select the Static location, then choose Duplicate Location from the Action menu below the location list.
Name the new location Broken DNS, then click Done.
If necessary, switch to the Broken DNS location.
Click Apply.
Select the primary network service (the one at the top of the left sidebar), then click Advanced.
Click DNS.
If there are entries in the DNS Servers list, record them so you can reenter them, then use the Remove (–) button to remove them.
Click the Add (+) button under the DNS Servers list, then add the server address 127.0.0.55.
No DNS server is available at this address, which is in a block of addresses that do not legitimately appear on any network anywhere (with the exception of 127.0.0.1, which is the loopback address and outside the scope of this guide). As a result, 127.0.0.55 is an invalid address.
Click TCP/IP.
From the Configure IPv6 menu, choose “Link-local only.”
This prevents IPv6 from being an alternate internet connection.
Click OK, then click Apply.
Observe the Problem
Open Safari.
Type www.apple.com in the address bar, then press Return.
Safari attempts to load the webpage, but it doesn’t get far because it’s not able to reach anything. If you wait, it eventually gives up, then displays an error. Don’t wait.
Quit Safari.
Check the Network Status in Network Preferences
When you have a network problem, one of the first things you should check is the network service status in Network preferences. Viewing the status lets you spot simple problems without performing detailed diagnostics.
Open Network preferences.
Examine the status indicators and the network services order.
If the network service you expect to be active isn’t showing a green status indicator, something is wrong with the connection or a critical setting is missing. Examples could include a loose cable, not being joined to a Wi-Fi network, or a missing IP address.
If the wrong service is at the top of the list, the service order was set incorrectly or unexpected services are active. In this case, the expected service has a green indicator and is at the top of the list, so you must do more troubleshooting.
Use ping to Test Connectivity
In this section, you use the ping command. You can use ping to test network connectivity and DNS resolution.
Open Terminal.
Many of the macOS troubleshooting tools are available from the command-line interface.
In Terminal, type ping -c 5, followed by the domain name of the server you want to reach (www.apple.com).
The option -c 5 in the ping command indicates the number of ping requests to send to the host, which in this case is five.
Press Return.
After about 30 seconds, you receive a message telling you that ping couldn’t resolve www.apple.com. The message indicates that ping wasn’t able to use DNS to look up, or resolve, the name www.apple.com and match it to an IP address to send the ping to. In this case, you know that the name www.apple.com is valid because you have used it before, so this indicates that something is wrong with DNS.
Although this message gives you some information about the problem, it still doesn’t tell you where the problem is. It can be hard to differentiate between a DNS problem and a complete network failure. If DNS resolution is the only thing failing, it can mimic a complete failure because almost all network access starts with (and depends on) a DNS lookup. If the network is completely disconnected, most attempts to use the network fail at the DNS step, so the only symptoms are DNS errors.
Try to reach a server by its numeric IP address to distinguish between a DNS-only problem and a complete network failure. This approach bypasses the usual DNS lookup and works even if DNS is broken.
At the prompt, type ping -c 5 8.8.8.8.
This is an easy-to-remember address of a public DNS server maintained by Google.
Press Return.
This time, ping reaches its destination successfully and shows statistics for its five test pings. This tells you that your basic network connectivity is OK and that it’s likely only DNS isn’t working.
Use the host Command to Test DNS
Even though the ping error message “cannot resolve” indicates a DNS problem, try the host command to discover whether it reveals a more specific error.
In Terminal, type host www.apple.com.
The host command is used for performing DNS lookups. You use it to convert names to IP addresses, and vice versa.
Press Return.
After about 30 seconds, you receive a message that the connection timed out and that no servers could be reached. This is the same result you got using the ping command.
Switch to Working Network Settings
From the Apple menu, choose Locations, then click the Static location.
Unlike the Broken DNS location, this location has valid settings, so your internet connectivity should be back to normal.
In Terminal, type host www.apple.com again.
This time the host command reaches a DNS server and finds the IP address corresponding to the domain name www.apple.com.
The address displayed by host may differ from the address in the figure because the Apple website is hosted by a number of servers throughout the internet and uses DNS to direct you to a server near your network location for faster access.
If you knew the address the name should resolve to, you could verify that, but the fact that it resolved to an IP address at all is a good indication that DNS is working.
The stdout of the host command may also display both an IPv6 address and an IPv4 address, because network services in macOS Big Sur are configured to use IPv6 automatically.
Open Safari, then try browsing a website.
This time, Safari is able to load webpages from the internet.