Kr328 / clash-premium-installer

Simple clash premium core installer for Linux.
319 stars 88 forks source link

安装成功无法通过tun上网 #17

Open ycg31 opened 2 years ago

ycg31 commented 2 years ago

安装成功,未提示错误。通过socks5可以正常代理上网,通过tun,也就是把客户机的网关和dns都设置成clash的ip无法代理上网。 而且就算一个域名解析成同一个IP地址,网关设置成clash就ping不通,设置成主路由的就可以ping通。说明跟dns没关系。网关设置成clash的时候使用socks5代理照样可以上网,说明clash代理是成功运行的,只是无法通过redir转发。clash配置如下:

mixed-port: 7890
redir-port: 7892
#tproxy-port: 7893
allow-lan: true
mode: rule
log-level: warning # info / warning / error / debug / silent
ipv6: false
external-controller: 0.0.0.0:9090
# external-ui: /ui
#interface-name: ens18
tun:
  enable: true
  stack: system # or `gvisor'
#  dns-listen: 0.0.0.0:53
  dns-hijack:
    - 1.0.0.1:53
#  auto-route: true
dns: # DNS server settings
  enable: true
#  listen: 0.0.0.0:53
  ipv6: false
  default-nameserver:
    - 119.29.29.29
  enhanced-mode: redir-host # or fake-ip redir-host
  fake-ip-range: 198.18.0.1/16 # Fake IP addresses pool CIDR
  # use-hosts: true # lookup hosts and return IP record
  fake-ip-filter:
    - '*.lan'
    - localhost.ptlogin2.qq.com
    - '+.srv.nintendo.net'
    - '+.stun.playstation.net'
    - '+.msftconnecttest.com'
    - '+.msftncsi.com'
    - '+.xboxlive.com'
    - 'msftconnecttest.com'
    - 'xbox.*.microsoft.com'
    - '*.battlenet.com.cn'
    - '*.battlenet.com'
    - '*.blzstatic.cn'
    - '*.battle.net'
  nameserver: # 国内域名使用 nameserver 请求
    - https://doh.pub/dns-query #腾讯DNS
    - https://dns.alidns.com/dns-query #阿里DNS
    # - 119.29.29.29
  fallback: # 国外域名使用 fallback 请求 (没有被污染的DNS)
    - https://cloudflare-dns.com/dns-query #Cloudflare DNS
    - https://doh.dns.sb/dns-query #DNS.SB
  fallback-filter: # fallback请求过滤
    geoip: true
    ipcidr:
      - 240.0.0.0/4
    domain:
      - '+.google.com'
      - '+.youtube.com'

通过ifconfig查看, tun设备也成功建立了

utun: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 9000
        inet 198.18.0.1  netmask 255.255.0.0  destination 198.18.0.1
        inet6 fe80::5a70:e37f:3785:97e8  prefixlen 64  scopeid 0x20<link>
        unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  txqueuelen 500  (UNSPEC)
        RX packets 1040  bytes 115856 (113.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1042  bytes 115952 (113.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

通过nft list table clash -s查看,clash防火墙规则也有了

table ip clash {
        chain local {
                type route hook output priority 0; policy accept;
                ip protocol != { tcp, udp } accept
                cgroup 114514 accept
                ip daddr { 10.0.0.0/8, 127.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 224.0.0.0/4 } accept
                ct state new ct mark set 0x0001bf52
                ct mark 0x0001bf52 mark set 0x0001bf52
        }

        chain forward {
                type filter hook prerouting priority 0; policy accept;
                ip protocol != { tcp, udp } accept
                iif "utun" accept
                ip daddr { 10.0.0.0/8, 127.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 224.0.0.0/4 } accept
                mark set 0x0001bf52
        }

        chain local-dns-redirect {
                type nat hook output priority 0; policy accept;
                ip protocol != { tcp, udp } accept
                cgroup 114514 accept
                ip daddr 127.0.0.0/8 accept
                udp dport domain dnat to 1.0.0.1:domain
                tcp dport domain dnat to 1.0.0.1:domain
        }

        chain forward-dns-redirect {
                type nat hook prerouting priority 0; policy accept;
                ip protocol != { tcp, udp } accept
                udp dport domain dnat to 1.0.0.1:domain
                tcp dport domain dnat to 1.0.0.1:domain
        }
}
ycg31 commented 2 years ago

重新装了一个linux 可以用tun了 但是速度巨慢 socks5 就正常

fuwu1245 commented 2 years ago

现在这个问题解决了么? 同遇到此问题

lakako commented 2 years ago

遇到类似问题 使用redir-host时:curl -vvv "https://www.google.com" 提示curl: (35) OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to www.google.com:443 使用fake-ip的时候正常,同求解决办法

ajeecai commented 2 years ago

同样的问题,Linux 下用tun模式没法工作...

Update: 可以work,对于我的情况是,在config.yaml里面加上interface-name: en0 (your internet iface num)之后就可以了。