Skip to content

Suncloyum/DontCloseIPv6

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DontCloseIPv6

DontCloseIPv6 是一个很小的 Windows 工具,用来应对校园网默认关闭IPV6的情况 \由于某天没注意到ipv6关闭而在月初下载了130G游戏后有感

它会安装一个 Windows 计划任务,在开机和用户登录时自动检查网卡的 IPv6 绑定项(ms_tcpip6)。如果发现 IPv6 被关闭,就自动重新打开。

功能

  • 默认只修复当前启用的物理网卡。
  • 支持指定某个网卡,例如只处理有线网卡。
  • 通过 Windows 任务计划程序以 SYSTEM 身份和最高权限运行。
  • 日志写入 %ProgramData%\DontCloseIPv6\ipv6-guard.log
  • 只使用 Windows 自带 PowerShell 命令,不需要第三方依赖。

系统要求

  • Windows 10/11,或带有 NetAdapter PowerShell 模块的 Windows Server。
  • 安装、卸载、手动修复都需要管理员权限。

快速开始

在本仓库目录中,以管理员身份打开 PowerShell,然后运行:

powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\install.ps1 -RunNow

安装完成后,Windows 会在开机和用户登录时自动运行检查任务。

查看当前状态

powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\scripts\Get-IPv6GuardStatus.ps1

如果只想手动测试一次修复脚本:

powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\scripts\Ensure-IPv6Enabled.ps1

指定网卡

先查看本机网卡名称:

Get-NetAdapter | Format-Table Name, InterfaceDescription, Status

然后只为指定网卡安装任务:

powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\install.ps1 -AdapterName "Ethernet" -RunNow

中文 Windows 上,有线网卡常见名称是 以太网

powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\install.ps1 -AdapterName "以太网" -RunNow

修复所有网卡

默认模式只修复当前启用的物理网卡。如果你想修复所有暴露 IPv6 绑定项的网卡,可以运行:

powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\install.ps1 -AllAdapters -RunNow

卸载

以管理员身份打开 PowerShell,然后运行:

powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\uninstall.ps1

卸载脚本只会移除计划任务,不会关闭 IPv6,也不会删除日志。

排查问题

如果 PowerShell 提示拒绝访问,请确认你是以管理员身份运行 PowerShell。

如果任务已经安装,但 IPv6 仍然被关闭,可以查看日志:

Get-Content "$env:ProgramData\DontCloseIPv6\ipv6-guard.log" -Tail 50

也可以查看计划任务的运行结果:

Get-ScheduledTaskInfo -TaskName DontCloseIPv6

工作原理

Windows 会把 IPv6 是否启用记录在每个网卡的网络绑定项中,这个绑定项名称是 ms_tcpip6。本工具主要使用下面两个命令:

Get-NetAdapterBinding -ComponentID ms_tcpip6
Enable-NetAdapterBinding -Name "<网卡名称>" -ComponentID ms_tcpip6

计划任务会让这项检查在开机和登录后自动重复执行。这样即使校园网客户端再次关闭 IPv6,工具也会在下次启动或登录时重新打开。

许可证

MIT

About

DLUT_EDA开机自动打开IPV6

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors