16 · Troubleshooting a Simple Network疑難排解簡易網路

Troubleshooting Common Problems Associated with IPv4 Addressing疑難排解 IPv4 定址常見問題

Troubleshooting IPv4 addressing is an important skill and will prove valuable when resolving several network issues. For example, assume that a host cannot communicate to a server that is on a remote network.

疑難排解 IPv4 定址是一項重要技能,在解決許多網路問題時將非常有用。舉例來說,假設某主機無法與遠端網路上的伺服器通訊。

The following are recommended troubleshooting steps to perform from the host:

以下是建議在主機端執行的疑難排解步驟:

  1. Verify the host IPv4 address and subnet mask.確認主機的 IPv4 位址與子網路遮罩。
  2. Ping the loopback address.Ping 迴路位址(loopback address)。
  3. Ping the IPv4 address of the local interface.Ping 本地介面的 IPv4 位址。
  4. Ping the default gateway.Ping 預設閘道。
  5. Ping the remote server.Ping 遠端伺服器。

The following examples assume you are on a Windows host.

以下範例假設你使用的是 Windows 主機。

Verify the Host IPv4 Address and Subnet Mask

確認主機 IPv4 位址與子網路遮罩

Access the command prompt and use ipconfig command to display all current TCP/IP network configuration parameters. If the Media State of your adapter indicates that media is disconnected (like in an example of Wireless LAN adapter below), then you should troubleshoot the adapter or check the cable (for wired interfaces).

開啟命令提示字元,使用 ipconfig 指令顯示目前所有的 TCP/IP 網路設定參數。若你的介面卡 Media State(媒介狀態)顯示媒介已中斷連線(如下方無線 LAN 介面卡範例),則應疑難排解該介面卡,或檢查纜線(適用於有線介面)。

C:\> ipconfig
Windows IP Configuration
Ethernet adapter Ethernet:
   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::bc2e:95ce:a622:5c7a%18
   IPv4 Address. . . . . . . . . . . : 172.16.10.2
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 172.16.10.1
Wireless LAN adapter Wi-Fi:
   Media State . . . . . . . . . . . : Media disconnected
   Connection-specific DNS Suffix  . :

Ping the Loopback Address

Ping 迴路位址

Access the command prompt and ping 127.0.0.1. This address is the diagnostic or loopback address. If you get a successful ping, your IPv4 stack is considered to be initialized. If it fails, you have an IPv4 stack failure, and you need to reinstall TCP/IP on the host.

開啟命令提示字元並 ping 127.0.0.1。此位址為診斷或迴路位址。若 ping 成功,即表示你的 IPv4 協定堆疊已完成初始化。若失敗,則表示 IPv4 協定堆疊發生故障,你需要在主機上重新安裝 TCP/IP。

C:\> ping 127.0.0.1
Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes2 time<1ms TTL8
Reply from 127.0.0.1: bytes2 time<1ms TTL8
Reply from 127.0.0.1: bytes2 time<1ms TTL8
Reply from 127.0.0.1: bytes2 time<1ms TTL8
Ping statistics for 127.0.0.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

Ping the IPv4 Address of the Local Interface

Ping 本地介面的 IPv4 位址

From the command prompt, ping the IPv4 address of the local host. If the ping is successful, your network interface card (NIC) is functioning. If it fails, there is a problem with the NIC. If the ping is successful, it does not mean that a cable is plugged into the NIC, but only that the IPv4 protocol stack on the host can communicate to the NIC (via the LAN driver).

在命令提示字元中,ping 本地主機的 IPv4 位址。若 ping 成功,表示你的網路介面卡(NIC)運作正常。若失敗,則表示 NIC 有問題。若 ping 成功,並不代表纜線已插入 NIC,只表示主機上的 IPv4 協定堆疊可以(透過 LAN 驅動程式)與 NIC 通訊。

C:\> ping 172.16.10.2
Pinging 172.16.10.2 with 32 bytes of data:
Reply from 172.16.10.2: bytes2 time<1ms TTL8
Reply from 172.16.10.2: bytes2 time<1ms TTL8
Reply from 172.16.10.2: bytes2 time<1ms TTL8
Reply from 172.16.10.2: bytes2 time<1ms TTL8
Ping statistics for 172.16.10.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

Ping the Default Gateway

Ping 預設閘道

From the command prompt, ping the default gateway (router). If the ping works, the NIC is plugged into the network and can communicate on the local network. If it fails, you have a local physical network problem that could be anywhere from the NIC to the router.

在命令提示字元中,ping 預設閘道(路由器)。若 ping 成功,表示 NIC 已插入網路,可以在本地網路上通訊。若失敗,則表示本地實體網路發生問題,範圍可能從 NIC 到路由器之間的任何地方。

C:\> ping 172.16.10.1
Pinging 172.16.10.1 with 32 bytes of data:
Reply from 172.16.10.1: bytes2 time<1ms TTL8
Reply from 172.16.10.1: bytes2 time<1ms TTL8
Reply from 172.16.10.1: bytes2 time<1ms TTL8
Reply from 172.16.10.1: bytes2 time<1ms TTL8
Ping statistics for 172.16.10.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

Ping the External Router Interface

Ping 路由器的外部介面

From the command prompt, ping the router’s external interface. The external interface is the interface that connects your router to the upstream infrastructure or more commonly the internet. If the ping is successful, there is no issue in the LAN. It also means that the device can potentially reach the external networks, so the problem is on the path from the router that acts as a default gateway to the destination. This is a real-life tip on testing the LAN and the default gateway for problems with only one ping. The host’s default gateway is correctly configured and works as expected if you can reach the router's external interface.

在命令提示字元中,ping 路由器的外部介面。外部介面是指將路由器連接到上游基礎架構(通常是網際網路)的介面。若 ping 成功,表示區域網路沒有問題。這也表示裝置有可能到達外部網路,因此問題出在從作為預設閘道的路由器到目的地之間的路徑上。這是一項實用技巧:只用一次 ping 就能同時測試區域網路與預設閘道是否有問題。如果你能連通路由器的外部介面,表示主機的預設閘道設定正確且運作如預期。

C:\> ping 209.165.200.1
Pinging 209.165.200.1 with 32 bytes of data:
Reply from 209.165.200.1: bytes2 time<1ms TTL8
Reply from 209.165.200.1: bytes2 time<1ms TTL8
Reply from 209.165.200.1: bytes2 time<1ms TTL8
Reply from 209.165.200.1: bytes2 time<1ms TTL8
Ping statistics for 209.165.200.1:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), 
Approximate round trip times in milli-seconds:
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

Ping the Remote Server

Ping 遠端伺服器

If the previous steps are successful, try to ping the remote server. If the ping is successful, you know that you have IPv4 connectivity between the local host and the remote server. You also know that the remote physical network is working.

若前面的步驟都成功,請嘗試 ping 遠端伺服器。若 ping 成功,表示本地主機與遠端伺服器之間有 IPv4 連線能力,也表示遠端實體網路運作正常。

C:\> ping 172.16.20.2
Pinging 172.16.20.2 with 32 bytes of data:
Reply from 172.16.20.2: bytes2 time<1ms TTL8
Reply from 172.16.20.2: bytes2 time<1ms TTL8
Reply from 172.16.20.2: bytes2 time<1ms TTL8
Reply from 172.16.20.2: bytes2 time<1ms TTL8
Ping statistics for 172.16.20.2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds: 
    Minimum = 0ms, Maximum = 0ms, Average = 0ms

If the ping to the remote server fails, you may have some remote physical network problem. Verify and correct this by going to the server and performing the same steps as you just did from the host.

若 ping 遠端伺服器失敗,可能是遠端實體網路發生問題。請前往伺服器並執行與剛才在主機端相同的步驟,以確認並修正此問題。

Check the Default Gateway

檢查預設閘道

If the previous steps are unsuccessful, there may be an incorrect default gateway configuration on either the host or the server, or there may be a routing issue.

若前面的步驟都不成功,可能是主機或伺服器上的預設閘道設定錯誤,或存在路由問題。

You can use the traceroute utility to test the path that packets take through the network to ensure they are going through the router.

你可以使用 traceroute 工具測試封包在網路中所經過的路徑,以確認封包確實經過路由器。

To verify the host setting for the default gateway, use the appropriate CLI command or check the settings in the GUI. A useful command in Windows besides ipconfig is route print. In the example, the user host has a correct default gateway setting.

若要確認主機的預設閘道設定,請使用適當的 CLI 指令或檢查 GUI 中的設定。在 Windows 中,除了 ipconfig 之外,另一個實用指令是 route print。在此範例中,該使用者主機的預設閘道設定正確。

C:\> route print
Active Routes:
Network Destination    Netmask     Gateway       Interface         Metric
0.0.0.0                0.0.0.0     172.16.10.1   172.16.10.2       35
<--- output omitted --->

One of the possible problems is also a wrong setting of a default gateway on the server. Depending on the host operating system, you will need to use the proper CLI command or check the settings in the GUI. The server should have a default gateway of 172.16.20.1.

另一個可能的問題是伺服器上的預設閘道設定錯誤。視主機作業系統而定,你需要使用適當的 CLI 指令或檢查 GUI 中的設定。該伺服器的預設閘道應為 172.16.20.1。

Next, you should check the IPv4 addresses and subnet masks of the interfaces, and the routing table, on the default gateway router. You should connect to the router and check the status of interfaces using the show ip interface brief command. To confirm the IPv4 addresses and subnet masks, use the show running-config command. To check the routing table, use the show ip route command and confirm that all the networks are listed in the routing table.

接著,你應檢查預設閘道路由器上各介面的 IPv4 位址與子網路遮罩,以及路由表。你應連線到該路由器,使用 show ip interface brief 指令檢查介面狀態;使用 show running-config 指令確認 IPv4 位址與子網路遮罩;使用 show ip route 指令檢查路由表,並確認所有網路都列在路由表中。

Which troubleshooting step would you take to verify that your device is connected to the network?你會採取哪個疑難排解步驟來確認你的裝置已連上網路?