heiher / hev-socks5-tunnel

A high-performance tun2socks for Linux/Android/FreeBSD/macOS/iOS/WSL2 (IPv4/IPv6/TCP/UDP)
MIT License
636 stars 130 forks source link

help, android root terminal usage #122

Closed anasfanani closed 1 month ago

anasfanani commented 1 month ago

I have set this config

tunnel:
  # Interface name
  name: socks0
  # Interface MTU
  mtu: 8500
  # Multi-queue
  multi-queue: false
  # IPv4 address
  ipv4: 198.18.0.1
  # IPv6 address
  ipv6: 'fc00::1'
  # Post up script
# post-up-script: up.sh
  # Pre down script
# pre-down-script: down.sh

socks5:
  # Socks5 server port
  port: 1099
  # Socks5 server address (ipv4/ipv6)
  address: 127.0.0.1
  # Socks5 UDP relay mode (tcp|udp)
  udp: 'udp'
  # Socks5 handshake using pipeline mode
# pipeline: false
  # Socks5 server username
# username: 'username'
  # Socks5 server password
# password: 'password'
  # Socket mark
# mark: 0

misc:
   # task stack size (bytes)
#  task-stack-size: 20480
   # connect timeout (ms)
#  connect-timeout: 5000
   # read-write timeout (ms)
#  read-write-timeout: 60000
   # stdout, stderr or file-path
   log-file: stdout
   # debug, info, warn or error
   log-level: debug
   # If present, run as a daemon with this pid file
#  pid-file: /run/hev-socks5-tunnel.pid
   # If present, set rlimit nofile; else use default value
#  limit-nofile: 65535

Then run with Termux

└─$ sudo ./hev-socks5-tunnel-linux-arm64 config.yml
[2024-04-08 19:01:59] [D] socks5 tunnel init
[2024-04-08 19:01:59] [D] socks5 tunnel run
[2024-04-08 19:01:59] [D] socks5 tunnel lwip task run
[2024-04-08 19:01:59] [D] socks5 tunnel timer task run
[2024-04-08 19:01:59] [D] socks5 tunnel event task run

Check with ifconfig is ok:


socks0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST>  mtu 8500
        inet 198.18.0.1  netmask 255.255.255.255  destination 198.18.0.1
        inet6 fc00::1  prefixlen 128  scopeid 0x0<global>
        inet6 fe80::d0c2:c95b:edac:d3b8  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 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7  bytes 448 (448.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Then I try curl to some url and still not use connection from socks0, help me please.

anasfanani commented 1 month ago

Ok works now. I must create iptables.

#!/system/bin/sh
iptables -t mangle -A OUTPUT -d 100.64.0.0/10 -j MARK --set-mark 1099
ip rule add fwmark 1099 table 1099 pref 200
ip route add default dev socks0 table 1099