在有些情况下,可能需要重新安装TCP/IP以使TCP/IP堆栈恢复为原始状态。可以使用 NetShell 实用程序重置 TCP/IP 堆栈,使其恢复到初次安装操作系统时的状态。
NetShell实用程序(netsh)是一个命令行脚本编写工具,您可以使用此实用程序配置并监视Windows Server 2003联网。此工具提供了交互式网络外壳程序接口。
您可以使用该实用程序的Internet协议(IP)上下文中的reset命令重写以下与TCP/IP相关的注册表项:
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\
SYSTEM\CurrentControlSet\Services\DHCP\Parameters\
运行此命令的结果与删除并重新安装 TCP/IP 协议的效果相同。
命令语法
netsh int ip reset [log_file_name]
要使用netsh 命令重置 TCP/IP 堆栈,您必须指定记录命令结果的日志文件的名称。如果输入了本文“命令示例”一节中介绍的任一命令,当前计算机中的 TCP/IP 堆栈将被重置,且该xx作的活动将被记录到命令行中指定的 Resetlog.txt 文件。在第一个示例中,日志文件被创建在当前文件夹中;在第二个示例中,则指定了 Resetlog.txt 日志文件的完整路径。
备注:如果该文件的名称与目标文件夹中的现有日志文件的名称相同,则会将新日志文件的信息附加到现有文件的结尾处。
命令示例
下面的示例说明了如何使用netsh 命令重置 TCP/IP 协议堆栈。
示例1
单击开始,然后单击运行。
在打开框中键入 cmd,然后单击确定。
在命令提示符后键入以下命令,然后按 ENTER 键:
netsh int ip reset resetlog.txt
备注:在上面的命令中,“int”是 interface 命令的缩写形式。
键入 exit,然后按 ENTER 键。
示例 2
单击开始,然后单击运行。
在打开框中键入 cmd,然后单击确定。
在命令提示符后键入以下命令,然后按 ENTER 键:
netsh int ip reset c:\resetlog.txt
键入 exit,然后按 ENTER 键。
要查看有关命令的帮助,请键入空格,然后键入 ?。即会显示有关netsh 命令子上下文中可用命令的其他帮助。例如,要查看上一节中介绍的netsh 命令,应在命令提示符后键入以下命令:
键入 netsh ?,然后按 ENTER 键。
键入 netsh int ?,然后按 ENTER 键。
键入 netsh int ip ?,然后按 ENTER 键。
键入 netsh int ip reset ?,然后按 ENTER 键。
NETSH INT IP RESET 的日志文件示例
以下是一个日志文件的示例,该日志文件是由运行ip reset 命令后的netsh 生成的。根据发出命令的计算机上不同的配置,实际的日志文件也会有所不同。通常,如果没有替换TCP/IP注册表项的原始配置,则不会在文件中记录任何操作。
resetSYSTEM\CurrentControlSet\Services\Dhcp\Parameters\Options\15\RegLocation
old REG_MULTI_SZ =
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\?\DhcpDomain
SYSTEM\CurrentControlSet\Services\TcpIp\Parameters\DhcpDomain
added
SYSTEM\CurrentControlSet\Services\Netbt\Parameters\Interfaces\Tcpip_{2DDD011E
-B1B6-4886-87AC-B4E72693D10C}\NetbiosOptions
added
SYSTEM\CurrentControlSet\Services\Netbt\Parameters\Interfaces\Tcpip_{BAA9D128
-54BB-43F6-8922-313D537BE03E}\NetbiosOptions
reset
SYSTEM\CurrentControlSet\Services\Netbt\Parameters\Interfaces\Tcpip_{BD2859BA
-B26A-4E2B-A3FE-3D246F90A81A}\NameServerList
old REG_MULTI_SZ =
10.1.1.2
deleted SYSTEM\CurrentControlSet\Services\Netbt\Parameters\EnableLmhosts
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{2DDD011E-B1B6-
4886-87AC-B4E72693D10C}\AddressType
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{2DDD011E-B1B6-
4886-87AC-B4E72693D10C}\DefaultGatewayMetric
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{2DDD011E-B1B6-
4886-87AC-B4E72693D10C}\DisableDynamicUpdate
deleted
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{2DDD011E-B1B6-
4886-87AC-B4E72693D10C}\DontAddDefaultGateway
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{2DDD011E-B1B6-
4886-87AC-B4E72693D10C}\EnableDhcp
old REG_DWORD = 0
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{2DDD011E-B1B6-
4886-87AC-B4E72693D10C}\NameServer
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{2DDD011E-B1B6-
4886-87AC-B4E72693D10C}\RawIpAllowedProtocols
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{2DDD011E-B1B6-
4886-87AC-B4E72693D10C}\TcpAllowedPorts
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{2DDD011E-B1B6-
4886-87AC-B4E72693D10C}\UdpAllowedPorts
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{5B3675C3-6EB9-
4936-B991-04DA31024C4E}\DisableDynamicUpdate
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{5B3675C3-6EB9-
4936-B991-04DA31024C4E}\EnableDhcp
old REG_DWORD = 0
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{5B3675C3-6EB9-
4936-B991-04DA31024C4E}\IpAddress
old REG_MULTI_SZ =
12.12.12.12
deleted
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{5B3675C3-6EB9-
4936-B991-04DA31024C4E}\IpAutoconfigurationAddress
deleted
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{5B3675C3-6EB9-
4936-B991-04DA31024C4E}\IpAutoconfigurationMask
deleted
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{5B3675C3-6EB9-
4936-B991-04DA31024C4E}\IpAutoconfigurationSeed
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{5B3675C3-6EB9-
4936-B991-04DA31024C4E}\RawIpAllowedProtocols
old REG_MULTI_SZ =
0
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{5B3675C3-6EB9-
4936-B991-04DA31024C4E}\SubnetMask
old REG_MULTI_SZ =
255.255.255.0
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{5B3675C3-6EB9-
4936-B991-04DA31024C4E}\TcpAllowedPorts
old REG_MULTI_SZ =
0
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{5B3675C3-6EB9-
4936-B991-04DA31024C4E}\UdpAllowedPorts
old REG_MULTI_SZ =
0
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BAA9D128-54BB-
43F6-8922-313D537BE03E}\AddressType
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BAA9D128-54BB-
43F6-8922-313D537BE03E}\DefaultGatewayMetric
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BAA9D128-54BB-
43F6-8922-313D537BE03E}\DisableDynamicUpdate
deleted
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BAA9D128-54BB-
43F6-8922-313D537BE03E}\DontAddDefaultGateway
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BAA9D128-54BB-
43F6-8922-313D537BE03E}\EnableDhcp
old REG_DWORD = 0
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BAA9D128-54BB-
43F6-8922-313D537BE03E}\NameServer
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BAA9D128-54BB-
43F6-8922-313D537BE03E}\RawIpAllowedProtocols
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BAA9D128-54BB-
43F6-8922-313D537BE03E}\TcpAllowedPorts
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BAA9D128-54BB-
43F6-8922-313D537BE03E}\UdpAllowedPorts
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BD2859BA-B26A-
4E2B-A3FE-3D246F90A81A}\DefaultGateway
old REG_MULTI_SZ =
10.1.1.2
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BD2859BA-B26A-
4E2B-A3FE-3D246F90A81A}\DefaultGatewayMetric
old REG_MULTI_SZ =
0
added
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BD2859BA-B26A-
4E2B-A3FE-3D246F90A81A}\DisableDynamicUpdate
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BD2859BA-B26A-
4E2B-A3FE-3D246F90A81A}\EnableDhcp
old REG_DWORD = 0
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BD2859BA-B26A-
4E2B-A3FE-3D246F90A81A}\IpAddress
old REG_MULTI_SZ =
10.1.1.1
deleted
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BD2859BA-B26A-
4E2B-A3FE-3D246F90A81A}\IpAutoconfigurationAddress
deleted
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BD2859BA-B26A-
4E2B-A3FE-3D246F90A81A}\IpAutoconfigurationMask
deleted
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BD2859BA-B26A-
4E2B-A3FE-3D246F90A81A}\IpAutoconfigurationSeed
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BD2859BA-B26A-
4E2B-A3FE-3D246F90A81A}\NameServer
old REG_SZ = 10.1.1.2,10.1.1.3
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BD2859BA-B26A-
4E2B-A3FE-3D246F90A81A}\RawIpAllowedProtocols
old REG_MULTI_SZ =
0
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BD2859BA-B26A-
4E2B-A3FE-3D246F90A81A}\SubnetMask
old REG_MULTI_SZ =
255.255.255.0
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BD2859BA-B26A-
4E2B-A3FE-3D246F90A81A}\TcpAllowedPorts
old REG_MULTI_SZ =
0
reset
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{BD2859BA-B26A-
4E2B-A3FE-3D246F90A81A}\UdpAllowedPorts
old REG_MULTI_SZ =
0
deleted
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DontAddDefaultGatewayDefau
lt
deleted
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\EnableIcmpRedirect
deleted
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\EnableSecurityFilters
deleted SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\SearchList
deleted
SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\UseDomainNameDevolution
文章来源于领测软件测试网 https://www.ltesting.net/