自动设置 KDNET 网络内核调试Setting Up KDNET Network Kernel Debugging Automatically

调试工具的 Windows 支持通过网络内核调试。Debugging Tools for Windows supports kernel debugging over a network. 本主题介绍如何设置网络会自动使用 kdnet.exe 安装工具进行调试。This topic describes how to set up network debugging automatically using the kdnet.exe setup tool.

运行调试器的计算机称为主机计算机,和正在调试的计算机称为目标计算机The computer that runs the debugger is called the host computer, and the computer being debugged is called the target computer. 在主计算机必须运行 Windows 7 或更高版本,并在目标计算机必须运行 Windows 8 或更高版本。The host computer must be running Windows 7 or later, and the target computer must be running Windows 8 or later.

确定主机计算机的 IP 地址Determining the IP Address of the Host Computer

  1. 确认目标和主机 Pc 连接到网络集线器或切换使用相应的网络电缆。Confirm that the target and host PCs are connected to a network hub or switch using an appropriate network cable.

  2. 主计算机上打开命令提示符窗口并输入IPConfig若要显示的 IP 配置。On the host computer, open a Command Prompt window and enter IPConfig to display the IP configuration.

  3. 在命令输出中,找到以太网适配器的 IPv4 地址。In the command output, locate the IPv4 address of the Ethernet adapter.

    ...
    
    Ethernet adapter Ethernet:
    ...
    
    IPv4 Address. . . . . . . . . . . : <YourHostIPAddress>
    ...
    
    
  4. 记下你想要用于调试的网络适配器的 IPv4 地址。Make a note of the IPv4 address of the network adapter that you intend to use for debugging.

设置主机和目标计算机Setting Up the Host and Target Computers

使用 kdnet.exe 实用程序自动配置调试器设置目标 PC 上,通过执行以下步骤。Use the kdnet.exe utility to automatically configure the debugger settings on the target PC, by following these steps.

  1. 确认主机系统上安装了 Windows 调试工具。Confirm that the Windows Debugging Tools are installed on the host system. 有关下载和安装调试器工具的信息,请参阅的 Windows 中下载调试的工具For information on downloading and installing the debugger tools, see Download Debugging Tools for Windows.

  2. 找到kdnet.exeVerifiedNICList.xml文件。Locate the kdnet.exe and VerifiedNICList.xml files. 默认情况下,它们位于此处。By default, they are located here.

    C:\Program Files (x86)\Windows Kits\10\Debuggers\x64
    

    备注

    这些说明假定这两台 Pc 上的目标和主机运行 Windows 的 64 位版本。These directions assumes that both PCs are running a 64 bit version of Windows on both the target and host. 如果这不是这样,最好的方法是运行在目标主机上运行工具的同一"位数"。If that is not the case, the best approach is to run the same "bitness" of tools on the host that the target is running. 例如,如果目标正在运行 32 位 Windows,请在主机上运行 32 版本的调试器。For example, if the target is running 32-bit Windows, run a 32 version of the debugger on the host. 有关详细信息,请参阅选择 32 位或 64 位调试工具For more information, see Choosing the 32-Bit or 64-Bit Debugging Tools.

  3. 在主机上将两个文件复制到网络共享或拇指驱动器,以便它们可在目标计算机上。On the host computer, copy the two files to a network share or thumb drive, so that they will be available on the target computer.

  4. 在目标计算机上创建一个 C:\KDNET 目录并复制kdnet.exeVerifiedNICList.xml文件复制到该目录。On the target computer, create a C:\KDNET directory and copy the kdnet.exe and VerifiedNICList.xml files to that directory.

    重要

    使用 kdnet 若要更改启动信息之前可能需要暂时挂起如 BitLocker 和安全引导测试 PC 上的 Windows 安全功能。Before using kdnet to change boot information you may need to temporarily suspend Windows security features such as BitLocker and Secure Boot on the test PC. 测试完成后重新启用这些安全功能和安全功能将被禁用时适当地管理测试 PC。Re-enable these security features when testing is complete and appropriately manage the test PC, when the security features are disabled.

  5. 在目标计算机上,以管理员身份打开命令提示符窗口。On the target computer, open a Command Prompt window as Administrator. 输入以下命令以验证目标计算机具有支持的网络适配器。Enter this command to verify that the target computer has a supported network adapter.

    C:\KDNET>kdnet
    Network debugging is supported on the following NICs:
    busparams=1.0.0, Broadcom NetXtreme Gigabit Ethernet, Plugged in.  
    This Microsoft hypervisor supports using KDNET in guest VMs.
    
  6. 如 kdnet 输出将指示该网络适配器上支持的目标,我们可以继续操作。As the output from kdnet indicates that network adapter on the target is supported, we can proceed.

  7. 此命令设置主机系统的 IP 地址和生成的唯一连接密钥类型。Type this command to set the IP address of the host system and generated a unique connection key. 使用 IP 地址或主机系统的名称。Use the IP address or the name of the host system. 对于每个目标/主机对选取一个唯一的端口地址与在 50000 50039 的建议的范围中,工作。Pick a unique port address for each target/host pair that you work with, with in the recommended range of 50000-50039.

    C:\>kdnet <HostComputerIPAddress> <YourDebugPort> 
    
    Enabling network debugging on Intel(R) 82577LM Gigabit Network Connection.
    Key=2steg4fzbj2sz.23418vzkd4ko3.1g34ou07z4pev.1sp3yo9yz874p
    
  8. 将返回的键复制到记事本.txt 文件。Copy the returned key into a notepad .txt file.

使用 WinDbg Using WinDbg

在主计算机上打开 WinDbg。On the host computer, open WinDbg. 文件菜单中,选择内核调试On the File menu, choose Kernel Debug. 在内核调试对话框中,打开Net选项卡。粘贴在你的端口号和到记事本.txt 文件中之前保存的密钥。In the Kernel Debugging dialog box, open the Net tab. Paste in your port number and key that you saved to in the notepad .txt file earlier. 单击 “确定”Click OK.

您还可以通过打开命令提示符窗口并输入以下命令,启动 WinDbg 会话其中是,上面所选的端口和是 kdnet 上面返回的密钥。You can also start a WinDbg session by opening a Command Prompt window and entering the following command, where is the port you selected above, and is the key that was returned by kdnet above. 粘贴该密钥,因为您保存到记事本.txt 文件中前面。Paste in the key in that you saved to in the notepad .txt file earlier.

windbg -k net:port=<YourDebugPort>,key=<YourKey> 

如果系统提示有关允许 WinDbg 能够通过防火墙访问端口,允许访问的端口的 WinDbg所有这三个的不同网络类型。If you are prompted about allowing WinDbg to access the port through the firewall, allow WinDbg to access the port for all three of the different network types.

windows 安全警报的 windows 防火墙已阻止此应用的某些功能windows security alert - windows firewall has blocked some features of this app

重新启动目标 PC Restarting the Target PC

调试器连接后,重新启动目标计算机。Once the debugger is connected, reboot the target computer. 不要重新启动 PC,一种方法是使用此命令从管理员命令提示符。One way to do restart the PC, is to use this command from an administrator's command prompt.

shutdown -r -t 0 

故障排除提示Troubleshooting Tips

调试应用程序必须允许通过防火墙Debugging application must be allowed through firewall

调试器必须具有通过防火墙进行访问。The debugger must have access through the firewall. 使用控制面板以允许通过防火墙进行访问。Use Control Panel to allow access through the firewall.

  1. 打开Control Panel>系统和安全然后单击允许通过 Windows 防火墙的应用程序Open Control Panel > System and Security and click Allow an app through Windows Firewall.

  2. 在应用程序列表中,找到Windows GUI 符号调试器Windows 内核调试程序In the list of applications, locate Windows GUI Symbolic Debugger and Windows Kernel Debugger.

  3. 使用复选框以允许这些两个应用程序所有这三个通过防火墙的不同网络类型。Use the check boxes to allow those two applications all three of the different network types through the firewall.

  4. 向下滚动并单击确定,若要保存防火墙更改。Scroll down and click OK, to save the firewall changes. 重新启动调试器。Restart the debugger.

    windows 控制显示所有三种网络类型启用了 Windows GUI 符号调试器和 Windows 内核调试器面板防火墙配置

使用 Ping 测试连接性Use Ping to test connectivity

如果调试器超时,并且不会连接,使用在目标电脑上的 ping 命令来验证连接。If the debugger times out and does not connect, use the ping command on the target PC to verify connectivity.

C:\>Ping <HostComputerIPAddress> 

选择用于网络调试的端口Choosing a Port for Network Debugging

如果调试器超时,并且不会连接,则可能是因为已在使用默认端口号为 50000 或被阻止。If the debugger times out and does not connect, it could be because the default port number of 50000 is already in use or it is blocked.

您可以选择任意端口号从 49152 到 65535。You can choose any port number from 49152 through 65535. 建议的范围是介于 50000 和 50039。The recommended range is between 50000 and 50039. 由调试器主机计算机上运行,将进行独占访问打开您选择的端口。The port that you choose will be opened for exclusive access by the debugger running on the host computer.

请注意  可能通过公司的网络策略限制可用于网络调试的端口号的范围。Note  The range of port numbers that can be used for network debugging might be limited by your company's network policy. 若要确定你公司的策略是否限制可以用于调试的网络端口的范围,请咨询网络管理员。To determine whether your company's policy limits the range of ports that can be used for network debugging, check with your network administrators.

支持的网络适配器Supported Network Adapters

如果"网络不支持调试任何在此计算机中的 Nic 上"将显示当您运行 kdnet.exe,它指的网络适配器不支持。If "Network debugging is not supported on any of the NICs in this machine" is displayed when you run kdnet.exe, it means that the network adapter is not supported.

主机计算机可以使用任何网络适配器,但在目标计算机必须使用的 Windows 调试工具支持的网络适配器。The host computer can use any network adapter, but the target computer must use a network adapter that is supported by Debugging Tools for Windows. 有关支持的网络适配器的列表,请参阅的 Windows 10 中的网络内核调试支持以太网 Nic对于 Windows 8.1 中的网络内核调试支持以太网 NicFor a list of supported network adapters, see Supported Ethernet NICs for Network Kernel Debugging in Windows 10 and Supported Ethernet NICs for Network Kernel Debugging in Windows 8.1.

相关主题Related topics

支持的网络内核调试在 Windows 10 中的以太网 NicSupported Ethernet NICs for Network Kernel Debugging in Windows 10

支持的网络内核调试在 Windows 8.1 中的以太网 NicSupported Ethernet NICs for Network Kernel Debugging in Windows 8.1

KDNET 网络内核调试手动设置Setting Up KDNET Network Kernel Debugging Manually