netsh interface ipv4 show ipaddresses与netsh interface ipv6 show addresses 是一个在 Windows 操作系统中使用的命令,用于显示本地计算机上所有网络接口(如以太网卡、Wi-Fi 网络接口等)上配置的 IPv4 地址及相关信息。它提供了系统上各个网络接口的详细信息,包括 IP 地址、子网掩码、网关等内容。
netsh interface 全枚举实例(单命令 + 多参数混合组合,管理员权限)
前置说明
netsh interface是顶层上下文,包含:ipv4 / ipv6 / tcp / udp / portproxy / isatap / teredo / httpstunnel- 网卡示例名称:
Ethernet;名称带空格必须双引号包裹;修改 IP / 路由 / 端口转发必须管理员 CMD/PowerShellstore=persistent永久生效(重启保留);store=active临时生效,重启丢失;默认 persistent- 简写:
netsh int=netsh interface
一、顶层 interface 单命令实例
| 序号 | 命令 | 简要说明 |
|---|---|---|
| 1 | netsh interface help |
查看 interface 上下文帮助 |
| 2 | netsh interface show interface |
列出本机所有网卡(状态、名称、索引、介质类型) |
| 3 | netsh interface dump |
导出本机全部网络配置脚本,可保存为脚本用于批量恢复 |
| 4 | netsh interface set interface name="Ethernet" admin=enable |
启用网卡 Ethernet |
| 5 | netsh interface set interface name="Ethernet" admin=disable |
禁用网卡 Ethernet |
二、ipv4 单参数实例
| 序号 | 命令 | 简要说明 |
|---|---|---|
| 6 | netsh interface ipv4 show interfaces |
查看 IPv4 网卡参数(MTU、跃点、转发状态) |
| 7 | netsh interface ipv4 show addresses |
查看所有网卡 IPv4 地址、掩码、网关 |
| 8 | netsh interface ipv4 show routes |
查看 IPv4 路由表 |
| 9 | netsh interface ipv4 show neighbors |
查看 ARP 邻居缓存表 |
| 10 | netsh interface ipv4 show dnsservers |
查看网卡 DNS 服务器 |
| 11 | netsh interface ipv4 show dynamicportrange tcp |
查看 TCP 动态端口范围 |
| 12 | netsh interface ipv4 set address name="Ethernet" source=dhcp |
网卡改为 DHCP 自动获取 IP |
| 13 | netsh interface ipv4 set address name="Ethernet" static 192.168.1.100 255.255.255.0 |
设置静态 IP + 子网掩码 |
| 14 | netsh interface ipv4 set dnsservers name="Ethernet" source=dhcp |
DNS 改为 DHCP 获取 |
| 15 | netsh interface ipv4 set dnsservers name="Ethernet" static 223.5.5.5 |
设置主 DNS 服务器 |
| 16 | netsh interface ipv4 add dnsservers name="Ethernet" 223.6.6.6 index=2 |
添加备用 DNS,索引 2 |
| 17 | netsh interface ipv4 add route prefix="10.0.0.0/24" interface="Ethernet" nexthop="192.168.1.1" |
添加静态路由 |
| 18 | netsh interface ipv4 delete route prefix="10.0.0.0/24" interface="Ethernet" |
删除静态路由 |
| 19 | netsh interface ipv4 delete address name="Ethernet" address=192.168.1.100 |
删除网卡静态 IP |
| 20 | netsh interface ipv4 delete neighbors name="Ethernet" |
清空指定网卡 ARP 缓存 |
| 21 | netsh interface ipv4 set global forwarding=enable |
开启本机 IPv4 路由转发(多网卡软路由) |
三、ipv6 单参数实例
| 序号 | 命令 | 简要说明 |
|---|---|---|
| 22 | netsh interface ipv6 show interfaces |
查看 IPv6 网卡信息 |
| 23 | netsh interface ipv6 show addresses |
查看 IPv6 地址 |
| 24 | netsh interface ipv6 show routes |
查看 IPv6 路由表 |
| 25 | netsh interface ipv6 show neighbors |
查看 IPv6 邻居缓存 (NDP) |
| 26 | netsh interface ipv6 set address name="Ethernet" 2408::100/64 |
添加静态 IPv6 地址 |
| 27 | netsh interface ipv6 add route prefix="2408:100::/64" interface="Ethernet" nexthop="2408::1" |
添加 IPv6 静态路由 |
| 28 | netsh interface ipv6 set global forwarding=enable |
开启 IPv6 转发 |
四、tcp 单参数实例(TCP 全局调优)
| 序号 | 命令 | 简要说明 |
|---|---|---|
| 29 | netsh interface tcp show global |
查看 TCP 全局参数(自动调优、RSC 等) |
| 30 | netsh interface tcp show heuristics |
查看 TCP 启发式自动调优 |
| 31 | netsh interface tcp set global autotuninglevel=normal |
开启 TCP 窗口自动调优(推荐) |
| 32 | netsh interface tcp set global autotuninglevel=disabled |
关闭 TCP 自动调优 |
| 33 | netsh interface tcp set global rss=enabled |
开启 RSS 接收端缩放(服务器网卡) |
| 34 | netsh interface tcp set global rsc=disabled |
关闭 RSC TCP 段合并(部分虚拟化环境) |
五、portproxy 单参数实例(端口转发)
| 序号 | 命令 | 简要说明 |
|---|---|---|
| 35 | netsh interface portproxy show all |
查看全部端口转发规则 |
| 36 | netsh interface portproxy show v4tov4 |
查看 IPv4 转 IPv4 转发规则 |
| 37 | netsh interface portproxy add v4tov4 listenport=8080 connectport=80 connectaddress=192.168.1.10 |
添加 v4tov4 端口转发,本机 8080 转发内网 192.168.1.10:80 |
| 38 | netsh interface portproxy delete v4tov4 listenport=8080 listenaddress=0.0.0.0 |
删除 8080 端口转发规则 |
| 39 | netsh interface portproxy reset |
清空所有 portproxy 转发规则 |
六、双参数混合组合
| 序号 | 命令 | 简要说明 |
|---|---|---|
| 40 | netsh interface set interface name="Ethernet" admin=enable && netsh interface ipv4 set address name="Ethernet" source=dhcp |
启用网卡,设置 DHCP 获取 IP |
| 41 | netsh interface ipv4 set address name="Ethernet" static 192.168.1.100 255.255.255.0 gateway=192.168.1.1 |
静态 IP + 掩码 + 默认网关一次性配置 |
| 42 | netsh interface ipv4 set dnsservers name="Ethernet" static 223.5.5.5 validate=no |
设置主 DNS,跳过 DNS 有效性校验 |
| 43 | netsh interface ipv4 add route prefix="10.0.0.0/24" interface="Ethernet" nexthop="192.168.1.1" metric=20 |
添加静态路由,设置路由优先级 metric=20 |
| 44 | netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=8080 connectaddress=192.168.1.10 connectport=80 |
监听所有网卡 0.0.0.0:8080 转发到内网 192.168.1.10:80 |
| 45 | netsh interface tcp set global autotuninglevel=normal rss=enabled |
同时开启 TCP 自动调优与 RSS |
七、三参数混合组合
| 序号 | 命令 | 简要说明 |
|---|---|---|
| 46 | netsh interface ipv4 set address name="Ethernet" static 192.168.1.100 255.255.255.0 gateway=192.168.1.1 && netsh interface ipv4 set dnsservers name="Ethernet" static 223.5.5.5 |
配置静态 IP + 网关 + 主 DNS |
| 47 | netsh interface ipv4 add dnsservers name="Ethernet" 223.6.6.6 index=2 validate=no |
添加备用 DNS,索引 2,不校验 DNS 连通性 |
| 48 | netsh interface ipv4 add route prefix="10.0.0.0/24" interface="Ethernet" nexthop="192.168.1.1 metric=20 store=persistent |
永久添加静态路由,优先级 20 |
| 49 | netsh interface portproxy add v4tov4 listenaddress=127.0.0.1 listenport=9000 connectaddress=10.0.0.5 connectport=443 |
仅本机 127.0.0.1 监听 9000 转发至 10.0.0.5:443 |
八、多参数复杂混合组合(4 个及以上参数)
| 序号 | 命令 | 简要说明 |
|---|---|---|
| 50 | netsh interface ipv4 set address name="Ethernet" static 192.168.1.100 255.255.255.0 gateway=192.168.1.1 && netsh interface ipv4 set dnsservers name="Ethernet" static 223.5.5.5 && netsh interface ipv4 add dnsservers name="Ethernet" 223.6.6.6 index=2 |
完整静态 IP 环境:IP + 掩码 + 网关 + 主 DNS + 备用 DNS |
| 51 | netsh interface ipv4 set global forwarding=enable && netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=8080 connectaddress=192.168.1.10 connectport=80 |
开启系统 IP 转发 + 配置端口转发(必须同时开启转发,端口代理才生效) |
| 52 | netsh interface tcp set global autotuninglevel=normal rss=enabled rsc=disabled |
TCP 性能调优组合:自动调优开、RSS 开、RSC 关闭 |
九、系统网络重置(运维排障高频)
| 序号 | 命令 | 简要说明 |
|---|---|---|
| 53 | netsh interface ip reset C:\ipreset.log |
重置 TCP/IP 栈,写入日志文件,重启生效 |
| 54 | netsh interface ipv4 reset |
单独重置 IPv4 配置 |
| 55 | netsh interface ipv6 reset |
单独重置 IPv6 配置 |
十、无效 / 边界说明
| 无效命令 | 原因 |
|---|---|
netsh interface portproxy add v4tov4 listenport=8080 connectport=80 connectaddress=192.168.1.10 但未开启 ipv4 forwarding |
端口转发必须开启系统 IPv4 转发netsh interface ipv4 set global forwarding=enable,否则转发不生效,同时防火墙放行监听端口 |
netsh interface ipv4 add route prefix="10.0.0.0/24" nexthop="192.168.1.1" |
缺少interface=网卡参数,语法报错 |
netsh interface set interface admin=enable |
缺少name="网卡名",无法定位网卡 |
十一、运维场景快速选型
- 查看网卡列表:
netsh interface show interface - 网卡 DHCP 自动获取:
netsh interface ipv4 set address name="Ethernet" source=dhcp - 配置静态 IP 网关 DNS:
netsh interface ipv4 set address name="Ethernet" static 192.168.1.100 255.255.255.0 gateway=192.168.1.1 - 端口转发:
netsh interface portproxy add v4tov4 listenport=8080 connectport=80 connectaddress=192.168.1.10 - TCP 性能调优:
netsh interface tcp set global autotuninglevel=normal - 网络栈故障重置:
netsh interface ip reset C:\ipreset.log
在 Windows 系统中,进行多播通信的命令工具主要包括 netsh、ping、ipconfig 等。以下是一些常用的命令,帮助进行多播通信的设置、查看和测试:
netsh interface ipv6 show addresses 输出内容化后的结果:
| 接口 | 地址类型 | DAD 状态 | 有效寿命 | 首选寿命 | 地址 |
|---|---|---|---|---|---|
| Loopback Pseudo-Interface 1 | 其他 | 首选项 | infinite | infinite | ::1 |
| 以太网 | 其他 | 反对 | infinite | infinite | fe80::8060:3888:19cf:9960%13 |
| WLAN | 临时 | 首选项 | 54m55s | 54m55s | 240e:381:4588:8000:319b:ac41:cdd1:e131 |
| WLAN | 公用 | 首选项 | 54m55s | 54m55s | 240e:381:4588:8000:abd9:2e03:78cb:553a |
| WLAN | 其他 | 首选项 | infinite | infinite | fe80::fab9:73d2:36de:d91b%9 |
| 本地连接* 10 | 其他 | 反对 | infinite | infinite | fe80::fc28:98a2:273c:b787%10 |
| 本地连接* 11 | 其他 | 反对 | infinite | infinite | fe80::ca35:e4e2:445c:873c%17 |
说明:
- 接口:显示的是每个网络接口的名称或标识符。
- 地址类型:显示地址的类型(如临时地址、公共地址等)。
- DAD 状态:表示地址冲突检测(DAD,Duplicate Address Detection)的状态。
- 有效寿命:表示地址的有效时间(例如 "infinite" 表示无限有效期)。
- 首选寿命:地址首选的有效时间。
- 地址:显示该接口上配置的 IPv6 地址。
| 接口 | 地址类型 | DAD 状态 | 有效寿命 | 首选寿命 | 地址 | 描述/应用场景 |
|---|---|---|---|---|---|---|
| Loopback Pseudo-Interface 1 | 其他 | 首选项 | infinite | infinite | ::1 | 回环接口(Loopback):用于本地通信,通常用于网络调试和测试。这个地址只在本机内部使用,无法被其他设备访问。应用于软件开发、网络故障排查等场景。 |
| 以太网 | 其他 | 反对 | infinite | infinite | fe80::8060:3888:19cf:9960%13 | 有线网络接口(Ethernet):这是通过以太网连接的设备的本地链路地址。通常用于设备间的局域网通信。该地址是链路本地地址,意味着只在同一网络范围内有效。 |
| WLAN | 临时 | 首选项 | 54m55s | 54m55s | 240e:381:4588:8000:319b:ac41:cdd1:e131 | 无线网络接口(Wi-Fi):此地址用于设备通过无线局域网(Wi-Fi)进行的通信。临时地址通常用于隐私保护,防止设备长期使用相同的地址,适用于移动设备。 |
| WLAN | 公用 | 首选项 | 54m55s | 54m55s | 240e:381:4588:8000:abd9:2e03:78cb:553a | 公共网络地址(Public Address):用于连接到互联网的设备的地址。这个地址使得设备能够与其他网络或设备进行通信,适用于需要访问外部服务和网站的应用。 |
| WLAN | 其他 | 首选项 | infinite | infinite | fe80::fab9:73d2:36de:d91b%9 | 无线链路本地地址(Link-local Address):这是一个链路本地地址,只在同一网络段内有效,通常用于设备间的直接通信或自动配置。 |
| 本地连接 10* | 其他 | 反对 | infinite | infinite | fe80::fc28:98a2:273c:b787%10 | 虚拟网络接口(Local Connection):用于虚拟网络连接或虚拟化环境中的设备。它通常不用于日常网络通信,但在特定应用中(如虚拟机或容器网络)可能非常有用。 |
| 本地连接 11* | 其他 | 反对 | infinite | infinite | fe80::ca35:e4e2:445c:873c%17 | 虚拟网络接口(Local Connection):类似于 "本地连接* 10",也用于虚拟网络或特殊设备间的连接。 |
进一步描述和应用场景:
-
Loopback 接口(::1)
- 描述:回环接口用于设备内部通信,通常不会通过网络进行传输。它是系统进行自我通信的途径,通常用于测试和开发环境中。
- 应用场景:网络诊断、测试工具、调试和开发环境中,比如使用
ping ::1来测试网络栈是否正常工作。
-
以太网接口(fe80::8060:3888:19cf:9960%13)
- 描述:以太网接口通过物理网卡连接到局域网。链路本地地址(Link-local Address)只在当前网络中有效,不能跨越路由器或交换机访问。
- 应用场景:局域网内设备间的通信,例如家庭或办公环境中的打印机、计算机、交换机等设备间的互联。
-
无线网络接口(Wi-Fi):
- 临时地址(240e:381:4588:8000:319b:ac41:cdd1:e131):临时地址通常用于保护用户隐私,避免长期使用同一地址。
- 公用地址(240e:381:4588:8000:abd9:2e03:78cb:553a):用于设备与互联网或其他设备进行通信。
- 应用场景:移动设备如智能手机、笔记本电脑、平板等连接到 Wi-Fi 网络时,通常会获得这些类型的地址。临时地址保护用户的隐私,防止暴露设备的长期公网地址。
-
虚拟网络接口(fe80::fc28:98a2:273c:b787%10 和 fe80::ca35:e4e2:445c:873c%17)
- 描述:这些接口通常用于虚拟化环境中,如虚拟机或容器中使用的网络接口。它们通常是为特定虚拟网络连接提供服务。
- 应用场景:在虚拟机(VM)或容器环境中,虚拟网络接口用于设备间的通信,特别是虚拟化平台(如 VMware、Docker)中。
这些 IPv6 地址代表了不同类型的网络接口,它们各自有不同的用途和应用场景。在实际应用中,网络管理员可以根据不同的接口类型和地址,配置网络、解决问题并进行性能优化。如果你有更详细的需求,或希望了解某些接口的设置或配置方法,我可以进一步帮助你!
netsh interface ipv4 show ipaddresses 是一个在 Windows 操作系统中使用的命令,用于显示本地计算机上所有网络接口(如以太网卡、Wi-Fi 网络接口等)上配置的 IPv4 地址及相关信息。它提供了系统上各个网络接口的详细信息,包括 IP 地址、子网掩码、网关等内容。
解释:
- netsh:是一个命令行工具,允许你配置和监控 Windows 操作系统中的网络设置。
- interface ipv4:指定了要操作的对象是网络接口的 IPv4 地址设置。
- show ipaddresses:该参数用于显示当前所有网络接口的 IPv4 地址和相关配置。
输出示例:
运行该命令后,你会看到类似下面的输出:
Interface List
---------------
1 ... Microsoft Loopback Adapter
2 ... Ethernet
3 ... Wi-Fi
IPv4 Address(es)
---------------
Interface 1: 127.0.0.1
Interface 2: 192.168.1.100
Interface 3: 192.168.0.105
每个部分的含义:
- Interface List:显示了计算机上所有网络接口的列表,如回环接口、以太网接口、无线接口等。
- IPv4 Address(es):列出每个接口的 IPv4 地址。
使用场景:
- 查看本地配置:如果你想查看计算机上所有网络接口的 IPv4 地址配置,使用该命令可以快速得到。
- 网络故障排查:如果网络连接不正常,通过这个命令检查本地是否正确配置了 IPv4 地址。
- 手动网络配置:帮助网络管理员或用户了解当前的网络接口配置,方便进一步手动调整网络设置。
为什么使用这个命令:
- 诊断问题:当你遇到网络连接问题时,查看 IPv4 地址可以帮助确定是否已正确获取 IP 地址,是否存在冲突,或者是否使用了自动分配的私有 IP 地址。
- 配置验证:你可能在配置静态 IP 地址或进行网络管理时,需要验证所有接口的地址配置是否正确。
- 查看 DHCP 配置:如果某个接口配置为动态地址(DHCP),你可以通过这个命令查看它是否成功获取了有效的地址。
总结来说,netsh interface ipv4 show ipaddresses 是一个非常实用的命令,用于快速查看和验证计算机上所有网络接口的 IPv4 地址和相关网络配置。
1. 查看多播路由
- 使用
netsh命令查看网络接口的多播路由配置。
netsh interface ipv4 show ipaddresses
这个命令可以帮助查看当前接口的多播地址和相关配置。
netsh interface ipv4 show ipaddresses 输出的化版本:
| 接口 | 地址类型 | DAD 状态 | 有效寿命 | 首选寿命 | 地址 |
|---|---|---|---|---|---|
| 接口 1: Loopback Pseudo-Interface 1 | 其他 | 首选项 | infinite | infinite | 127.0.0.1 |
| 接口 13: 以太网 | 其他 | 暂时的 | infinite | infinite | 169.254.115.114 |
| 接口 9: WLAN | DHCP | 首选项 | 2d23h8m5s | 2d23h8m5s | 192.168.1.127 |
| 接口 10: 本地连接* 10 | 其他 | 暂时的 | infinite | infinite | 169.254.236.194 |
| 接口 17: 本地连接* 11 | 其他 | 暂时的 | infinite | infinite | 169.254.217.66 |
这个将原始输出以结构化的形式呈现,便于查看每个接口的详细信息。
| 接口 | 地址类型 | DAD 状态 | 有效寿命 | 首选寿命 | 地址 | 描述及应用场景 |
|---|---|---|---|---|---|---|
| 接口 1: Loopback Pseudo-Interface 1 | 其他 | 首选项 | infinite | infinite | 127.0.0.1 | 回环接口(Loopback):用于测试本地计算机上的网络堆栈,无需物理网络连接。通常用于网络诊断和开发时测试。 |
| 接口 13: 以太网 | 其他 | 暂时的 | infinite | infinite | 169.254.115.114 | 自动私有IP地址(APIPA):在没有DHCP服务器时,Windows会为以太网接口分配此地址,适用于局域网中设备自动获取临时IP时。 |
| 接口 9: WLAN | DHCP | 首选项 | 2d23h8m5s | 2d23h8m5s | 192.168.1.127 | 无线局域网(WLAN):通过DHCP分配的IP地址,表示该设备连接到Wi-Fi网络,适用于家庭或办公室的无线网络通信。 |
| 接口 10: 本地连接 10* | 其他 | 暂时的 | infinite | infinite | 169.254.236.194 | 自动私有IP地址(APIPA):与接口 13 类似,这个地址是没有连接到有效网络时自动分配的临时IP,通常用于无法获取到DHCP地址时。 |
| 接口 17: 本地连接 11* | 其他 | 暂时的 | infinite | infinite | 169.254.217.66 | 自动私有IP地址(APIPA):同上,代表该接口没有从DHCP服务器获取有效IP地址,可能与其他设备通信时存在问题。 |
描述及应用场景总结:
- 回环接口(Loopback):适用于网络服务测试、调试和本地连接,不依赖物理网络连接。
- 自动私有IP地址(APIPA):当计算机未能连接到网络(例如,未找到DHCP服务器时),系统会自动分配该地址。此类地址仅能在局域网内进行通信,无法与外部网络连接。
- DHCP(动态主机配置协议)分配的IP地址:此接口通过 DHCP 获取有效的动态IP地址,适用于有DHCP服务器的网络环境中,能够实现自动化的IP地址分配,简化网络配置过程。
这个和描述让你可以更清楚地理解每个接口的配置及其适用场景,帮助更好地进行网络故障排查或配置。
2. 查看多播组成员
- 使用
netsh命令列出所有的多播组成员。
netsh interface ipv4 show ipaddresses | findstr "multicast"
这个命令可以过滤出显示的多播地址,帮助了解哪些多播组是系统正在参与的。
3. 启用/禁用多播路由
- 要启用或禁用多播路由,您可以使用
netsh命令:
启用多播路由:
netsh interface ipv4 set interface "Ethernet" multicast
禁用多播路由:
netsh interface ipv4 set interface "Ethernet" nomulticast
这个命令用于配置网络接口是否支持多播通信。
4. 使用 ping 测试多播
- 通过
ping命令,可以测试多播地址的连通性。通常会使用特定的多播地址进行测试。
示例:ping 一个多播地址(比如 224.0.0.1):
ping 224.0.0.1
这将测试局域网内所有接收到该多播地址的设备是否能响应。如果多播地址正常,则网络中的设备将响应。
5. 查看网络接口的配置
- 使用
ipconfig命令查看当前所有网络接口的详细信息,包括是否配置了多播支持。
ipconfig /all
这个命令列出了所有网络适配器的详细配置,可以查看是否启用了多播支持。
6. 加入多播组
- 如果需要手动加入某个多播组,可以通过某些应用程序或服务来实现,但 Windows 并没有提供直接的命令行工具来加入多播组。通常,多播组的加入是通过应用程序自动进行的(例如,视频流、VoIP 等服务会自动处理多播加入)。
7. 使用 route 命令查看路由表
route命令可以用来查看当前计算机的路由表,其中包括多播路由。多播路由通常以224.0.0.0到233.255.255.255范围的地址为目标。
route print
这个命令列出当前系统的路由表,包括多播路由。
8. 启用/禁用 IGMP(Internet Group Management Protocol)
- IGMP 是一个多播协议,通常在多播通信中使用。虽然 Windows 没有直接的命令来管理 IGMP 设置,但可以通过网络设备(如路由器)来配置 IGMP。
在 Windows 中,常用的多播通信命令包括 ping、netsh 和 ipconfig,它们可以帮助进行多播测试、查看配置和管理网络接口的多播功能。对于更复杂的多播配置(如加入多播组、调整路由等),可能需要使用特定的应用程序或者通过网络设备进行设置。

浙公网安备 33010602011771号