Giter Site home page Giter Site logo

asuswrt-merlin-v2ray's Introduction

NOTICE:

The maintainer using Xray + side router solution daily.

Other solution will not be updated in time may not work at all.

Use Asuswrt Merlin as a transparent proxy, powered by V2ray

Intro

This project is several scripts for config you ASUS router(merlin based) or Side router(A very old linux laptop) to serve as a transparent forward proxy.

Since 2023-07-16, this project's release version just follow Xray-core's version. Since 2024-01-07, the default deploy use Xray + Reality.

Feature

  1. transparent proxy(you know reason) for all devices connect to your's LAN.
  2. use your router 1080 port (e.g. router.asus.com:1080) as a socks5/http proxy directly.
  3. Ad block.
  4. All additional benefits come from V2Ray.
  5. Xray + XTLS support.

For transparent proxy, current only tproxy mode mode is supported, can be used with fakedns optionally.

NOTICE

redirect mode is possible, check script ./deploy_router_use_direct, dnsmasq serve as LAN DNS server, you only need this if you have a very old ASUS router which not support tproxy. Even, can always select side router + router for any (old) router.

You can always check weather router support TProxy use:

# modprobe xt_TPROXY

Switch proxy mode

You can try switch to use fakedns based transparent proxy after deploy successful like this:

$: ./use_fakedns [email protected]

and switch back use:

$: ./use_auto_proxy [email protected]

Prerequisites

  • A VPS which can visit free internet.
  • A newer router which support Entware, and can run V2ray/xray comfortable. (i use ASUS RT-AC5300, I think OpenWRT should satisfied too after a little hack)
  • Update yours router firmware to Asuswrt-merlin
  • Initialize Entware, please follow this wiki
  • A local ssh client which can login to router use ssh key.
  • If VPS behind a firewall, (e.g. UCloud, Google Cloud), you need enable 22334/22335 tcp/udp port on server manually.
  • A real domain name, if you want to use Xray + XTLS mode.

For better performance, update your's VPS linux kernel to a more recently version (>= 4.9) is encouraged, script can enable BBR for you on this case.

How to use it

Download script from release page

We assume your's linux VPS IP is 34.80.108.8, your's router IP is 192.168.50.1.

Deploy XRay to a linux VPS, serve as both XRay and Shadowsoks server.

Test on CentOS 8, Ubuntu 18.0.4, Debian GNU/linux 9.

By default, use Xray + Reality, you need expose port 22334/22335 for listen on vless/shadowsocks

 ╰─ $ ./deploy_server root@$hk
sending incremental file list
xray_server.json
          2.31K 100%  914.06kB/s    0:00:00 (xfr#1, to-chk=0/1)

......

Run ./deploy_router [email protected] to deploy to router.
Run ./deploy_side_router root@side_router_ip to deploy to side_router.

Deploy client config to router, serve as a transparent proxy.

Previous step will create a new xray client config with binary for you in downloaded_binary/$your_router_arch/. the default router arch is linux-arm-v5 for ASUS AC-5300, you can override with export router_arch=YOUR_ROUTER_ARCH, for the correct Arch name, check https://github.com/XTLS/Xray-core/releases assets

Then, run following command will deploy Xray transparent proxy to your's local ASUS router automatically.

./deploy_router [email protected]

Run following command will deploy files in downloaded_binary/amd64 to a side router.(for me, it is a HP 2530p laptop + CentOS 8)

./deploy_side_router [email protected]

A success deploy on router should be looking like this.

patch_router

deploy code to side router

deploy_side_router

Useful command for router

You can run following command on router

/opt/etc/toggle_proxy.sh is used for disable/enable proxy temporary, for disable completely, you need chmod -x /opt/etc/patch_router

/opt/etc/patch_router basically, just disable proxy, and then enable it.

/opt/etc/update_geodata.sh is used for update geosite data.

/opt/etc/apply_iptables_rule.sh /opt/etc/clean_iptables_rule.sh for enable/clean iptables rule.

/opt/etc/check_google_use_socks5 check xray connection if works. (not work for fakeDNS mode)

/opt/etc/check_google_use_proxy check transparent proxy if works in (side)router. (not work for fakeDNS mode)

troubleshooting step by step

  1. ensure you can ping through your's VPS from local, and can ssh login to VPS server.
  2. ensure you can visit VPS listened port use telnet from VPS locally, e.g. telnet 127.0.0.1 22334
  3. ensure you can visit VPS exposed port outside VPS from local, e.g. telnet {yours.vpsip} 22334, if not, check if port is blocked in yours area with: https://tcp.ping.pe/{your.ip}:22334
  4. ensure your's domain name certificate not expired. (try visit if you have website, or see server xray log)
  5. ensure domain name connect to your ip correct.
  6. check config settings, especially, the vless id, vless port, domain name correct.
  7. test with ./check_google_use_socks5.sh, ensure it work before test transparent proxy.
  8. check the system time in local/remote all correct.
  9. Create a issue

Contributing

  • Bug reports
  • Patches:
    • Fork on Github.
    • Create your feature branch: git checkout -b my-new-feature.
    • Commit your changes: git commit -am 'Add some feature'.
    • Push to the branch: git push origin my-new-feature.
    • Send a pull request :D.

asuswrt-merlin-v2ray's People

Contributors

zw963 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

asuswrt-merlin-v2ray's Issues

[Info] main/jsonem: Reading config: stdin:

deploy status
`root@Dostyle:/mnt/f/ASUS/asuswrt-merlin-v2ray-4.43.0# ./deploy_router [email protected]
[email protected]'s password:
[email protected]'s password:
v2ray.json 100% 3284 292.3KB/s 00:00
[email protected]'s password:
apply_iptables_rule.sh 100% 6784 688.9KB/s 00:00
[email protected]'s password:
clean_iptables_rule.sh 100% 1314 210.7KB/s 00:00
[email protected]'s password:
enable_swap.sh 100% 482 31.2KB/s 00:00
[email protected]'s password:
update_geosite.sh 100% 803 58.5KB/s 00:00
[email protected]'s password:
update_big_geosite.sh 100% 813 72.0KB/s 00:00
[email protected]'s password:
restart_dnsmasq.sh 100% 156 7.5KB/s 00:00
[email protected]'s password:
toggle_proxy.sh 100% 5814 567.1KB/s 00:00
[email protected]'s password:
patch_router 100% 269 18.3KB/s 00:00
[email protected]'s password:
check_google_use_proxy.sh 100% 113 5.8KB/s 00:00
[email protected]'s password:
check_google_use_socks5.sh 100% 146 10.3KB/s 00:00
[email protected]'s password:
debug_v2ray.sh 100% 973 58.8KB/s 00:00
Copy predownloaded binary to router ...
[email protected]'s password:
[email protected]'s password:
v2ray-linux-arm32-v5.zip 100% 13MB 345.0KB/s 00:37
[email protected]'s password:
[email protected]'s password:


Remote deploy scripts is started !!


opkg version 1bf042dd06751b693a8544d2317e5b969d666b69 (2021-06-13)
Archive: v2ray-linux-arm32-v5.zip
inflating: vpoint_socks_vmess.json
inflating: v2ctl
inflating: config.json
inflating: vpoint_vmess_freedom.json
inflating: geoip-only-cn-private.dat
inflating: v2ray
inflating: geosite.dat
inflating: systemd/system/[email protected]
inflating: systemd/system/v2ray.service
inflating: geoip.dat
V2Ray 4.43.0 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.17.1 linux/arm)
A unified platform for anti-censorship.
Checking v2ray... dead.
v2ray was installed.
=> Disabling proxy ...
Checking v2ray... dead.
Cleaning iptables rule ... done.
Restart dnsmasq ... done.
=> Proxy is disabled.

=> Enabling proxy ...
Apply TProxy config ...
Applying iptables rule ...can not find out v2ray port setting in /opt/etc/v2ray.json
Starting v2ray... done.
Restart dnsmasq ... done.
=> Proxy is enabled.
Congratulations, Deploy succssful!`

v2ray satrt error admin@RT-AC1900P-A948:/tmp/home/root# v2ray V2Ray 4.43.0 (V2Fly, a community-driven edition of V2Ray.) Custom (go1.17.1 linux/arm) A unified platform for anti-censorship. 2021/10/31 00:11:54 Using config from STDIN 2021/10/31 00:11:54 [Info] main/jsonem: Reading config: stdin:
please help

Possible without side router?

Is this method possible without side router? All traffic on merlin asus redirected through v2ray ran on the modem jffs partition

./deploy_router: line 26: copy: command not found

Thank your work. The deploy_router script throw error copy command not found when try install v2ray on ac68u router. I think copy is custom shell function.

The copy function, it possible from script https://gitee.com/zw963/deployment_bash/raw/v0.7.2/deploy_start.sh. But the link return 404

deploy_router script not working on Asus Merlin 386.7.2 anymore

Using both release version and also the latest codes, deploy_router script gets stuck after binary file(s) (v2ray-linux*.zip) have been copied to the router. As far as I can tell, the problem is with "SSH $target bash" commands and "bash <<< ..." syntax. Also (on release version) when I stop that, the next ssh returns "bash: syntax error: unexpected redirection" error (which also seems to be related to "bash <<< ..." syntax).

Tested with:
Asus RT-AC86U running Asus merlin 386.7.2, fresh Install with Entware and USB Swap.
Predownloaded binary is v2ray-linux-arm64-v8a.zip with v4.45.2 which installs easily on AC86U.
Release version code (v4.44.0) and and latest codes from git both have this problem. Note that Release version uses a separete deploy_start.sh but latest codes from git use "https://gitlab.com/zw963/deployment_bash/-/raw/v0.8.3/deploy_start.sh" and this problem is persistent with both of them.

As far as I checked, if I use fresh install (+ Entware and Swap file), "bash --version" on router will not output anything. Also it seems that bash is the default shell ("echo $0" returns "bash") and "which bash" returns "/bin/bash".

Terminal Log:

./deploy_router [email protected]
[email protected]'s password:
[email protected]'s password:
v2ray.json 100% 1571 820.9KB/s 00:00
[email protected]'s password:
apply_iptables_rule.sh 100% 6816 2.5MB/s 00:00
[email protected]'s password:
clean_iptables_rule.sh 100% 1314 619.6KB/s 00:00
[email protected]'s password:
enable_swap.sh 100% 482 313.0KB/s 00:00
[email protected]'s password:
update_geosite.sh 100% 803 394.5KB/s 00:00
[email protected]'s password:
update_big_geosite.sh 100% 813 474.9KB/s 00:00
[email protected]'s password:
restart_dnsmasq.sh 100% 156 100.9KB/s 00:00
[email protected]'s password:
toggle_proxy.sh 100% 5873 1.1MB/s 00:00
[email protected]'s password:
patch_router 100% 269 140.3KB/s 00:00
[email protected]'s password:
check_google_use_proxy.sh 100% 113 50.3KB/s 00:00
[email protected]'s password:
check_google_use_socks5.sh 100% 146 83.9KB/s 00:00
[email protected]'s password:
debug_v2ray.sh 100% 989 480.0KB/s 00:00
Copy predownloaded binary to router ...
[email protected]'s password:
[email protected]'s password:
v2ray-linux-arm64-v8a.zip 100% 12MB 7.1MB/s 00:01
[email protected]'s password:
c
[email protected]'s password:
bash: syntax error: unexpected redirection

How to use with vmess subscription?

Thank you for this awesome project.

I noticed that it has some scripts for setting up VPS and router, is there any instruction for vmess subscription?

tporxy不能请求dns

使用tporxy配置了 iptable和 xray 的配置文件
但是dns貌似发不出去
是否要修改dnsmasq

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.