TUN 模式 |
您所在的位置:网站首页 › 检测到wifi代理是什么意思 › TUN 模式 |
对于不遵循系统代理的软件,TUN 模式可以接管其流量并交由 CFW 处理,在 Windows 中,TUN 模式性能比 TAP 模式好 ::: warning 注意 近期大部分浏览器默认已经开启“安全 DNS”功能,此功能会影响 TUN 模式劫持 DNS 请求导致反推域名失败,请在浏览器设置中关闭此功能以保证 TUN 模式正常运行 ::: Windows启动 TUN 模式需要进行如下操作: 点击General中Service Mode右边Manage,在打开窗口中安装服务模式,安装完成应用会自动重启,Service Mode 右边地球图标变为绿色即安装成功(无法安装参考:这里) 点击General中TUN Mode右边开关启动 TUN 模式::: tip NOTICE 如果使用system作为 TUN stack,需要同时在系统防火墙中将 clash core 放行,方法如下: 在0.19.27及以上版本中,点击 General 页面的盾牌按钮,并在 UAC 弹窗(若有)中允许运行,CFW 将自动配置对应的防火墙规则。 成功配置防火墙规则后该图标作为指示灯亮起。 在 Scoop 版上使用此功能需要0.20.3及以上版本,并且每次更新 CFW 后都需要更新防火墙规则。如果要通过 Scoop 安装脚本实现自动更新规则,可以参考:manifest script ::: ::: tip NOTICE 由于查询防火墙权限受限等原因,指示灯可能无法正常工作,请以系统防火墙列表及 Clash 网卡运行状态为准。 这里提供一个可用于自查的 PowerShell 脚本(可能需要管理员权限): #Requires -Version 3 #Requires -Modules NetSecurity $List = Get-NetFirewallRule -Enabled True -Action Allow -Description 'Work with Clash for Windows.' | Where-Object { 'Clash Core' -eq $_.DisplayName } $Report = foreach ($Rule in $List) { $Program = (Get-NetFirewallApplicationFilter -AssociatedNetFirewallRule $Rule).Program [pscustomobject] @{ Enabled = $Rule.Enabled Action = $Rule.Action Protocol = (Get-NetFirewallPortFilter -AssociatedNetFirewallRule $Rule).Protocol Program = $Program IsPathValid = Test-Path -PathType Leaf -LiteralPath $Program } } $Report Pause以 x86-64 版本为例,如果输出类似以下内容,那么规则添加成功(请自行验证 Program 路径的有效性): Enabled : True Action : Allow Protocol : TCP Program : C:\Program Files\Clash for Windows\resources\static\files\win\x64\clash-win64.exe IsPathValid : True Enabled : True Action : Allow Protocol : UDP Program : C:\Program Files\Clash for Windows\resources\static\files\win\x64\clash-win64.exe IsPathValid : True::: 在使用的配置文件中加入如下内容: dns: enable: true enhanced-mode: fake-ip nameserver: - 8.8.8.8 # 真实请求DNS,可多设置几个 - 114.114.114.114 # interface-name: WLAN # 出口网卡名称,或者使用下方的自动检测 tun: enable: true stack: gvisor # 使用 system 需要 Clash Premium 2021.05.08 及更高版本 dns-hijack: - 198.18.0.2:53 # 请勿更改 auto-route: true auto-detect-interface: true # 自动检测出口网卡::: tip NOTICE 从Clash Premium 2021.05.08开始,使用auto-*代替macOS-auto-*,往后数个版本将暂时兼容旧字段名。此版本同时添加了system stack支持。参考 ::: 注意事项当enhanced-mode设置为fake-ip时,会出现系统检测到网卡无法联网,微软系 APP 无法登陆使用等问题,可以通过添加fake-ip-filter解决: dns: enable: true enhanced-mode: fake-ip nameserver: - 114.114.114.114 fake-ip-filter: - "dns.msftncsi.com" - "www.msftncsi.com" - "www.msftconnecttest.com"::: tip TUN 模式更推荐使用 fake-ip 模式 ::: macOS启动 TUN 模式需要进行如下操作: 点击General中Service Mode右边Manage,在打开窗口中安装服务模式,安装完成应用会自动重启,Service Mode 右边地球图标变为绿色即安装成功 点击General中TUN Mode右边开关启动 TUN 模式 在使用的配置文件中加入如下内容: dns: enable: true enhanced-mode: fake-ip nameserver: - 114.114.114.114 # 真实请求DNS,可多设置几个 # interface-name: en0 # 出口网卡名称,或者使用下方的自动检测 tun: enable: true stack: system # 或 gvisor dns-hijack: # DNS劫持设置为系统DNS - 114.114.114.114 # 可任意设置,但为了保证CFW关闭后能不影响联网,建议设置真实能访问的DNS服务器 auto-route: true auto-detect-interface: true # 自动检测出口网卡::: tip NOTICE 从Clash Premium 2021.05.08开始,使用auto-*代替macOS-auto-*,往后数个版本将暂时兼容旧字段名。参考 ::: ::: tip dns-hijack 不可以劫持局域网地址的 DNS,如 192.168.0.0/16,请务必手动设置系统 DNS ::: ::: tip 若要将此 Mac 设置为代理网关,打开 IP 转发即可: sudo sysctl -w net.inet.ip.forwarding=1这种做法将在机器下次重启后失效,如果想要永久保存,编辑文件/etc/sysctl.conf,配置下面变量: net.inet.ip.forwarding=1 net.inet6.ip6.forwarding=1或者使用 LaunchDaemons 进行配置: 新建 network.forwarding.plist DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> Label Network Forwarding UserName root GroupName wheel ProgramArguments /usr/sbin/sysctl -w net.inet.ip.forwarding=1 net.inet6.ip6.forwarding=1 KeepAlive RunAtLoad 将文件添加进 /Library/LaunchDaemons sudo launchctl load /Library/LaunchDaemons/network.forwarding.plist ::: Linux启动 TUN 模式需要进行如下操作: 点击General中Service Mode右边Manage,在打开窗口中安装服务模式,安装完成应用会自动重启(某些系统需要手动重启 APP),Service Mode 右边地球图标变为绿色即安装成功 点击General中TUN Mode右边开关启动 TUN 模式 在使用的配置文件中加入如下内容: dns: enable: true enhanced-mode: fake-ip nameserver: - 114.114.114.114 # 真实请求DNS,可多设置几个 tun: enable: true stack: system # 或 gvisor dns-hijack: - 1.0.0.1:53 # 请勿更改::: tip Linux 下一般不需要设置interface-name字段 ::: 配置文件参考Clash Wiki ::: tip NOTICE 如熟悉使用代码启动,也可以使用 mixin 功能进行其他配置 ::: |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |