返回列表 發帖

Configuration of transparent V2Ray proxy server using Raspberry Pi 3b 树莓派做V2Ray透明代理 (第三种组合)

透明代理从第一种组合【1】,需要两个routers,可能这个模式比较适合作者的环境。这个组合(硬件和软件)有一些非常好的地方,就是大陆和墙外的网站可以自由选择,没有多大的问题。而官网指向的白话文,router少了一个,而settings也用他的【2】,但是看墙外的东西是没有问题,但是在大陆看大陆网站就打不开。于是我就想起用第二组合network configuration,而用第一组合的software settings,得出第三个组合。

参考文献:
【1】http://www.telecom-cafe.com/forum/viewthread.php?tid=7300
【2】http://www.telecom-cafe.com/forum/viewthread.php?tid=7301

/etc/v2ray/config.json
  1. {
  2.   "inbounds": [
  3.     {
  4.       "protocol": "socks",
  5.       "port": 1081,  // SOCKS 代理端口,在浏览器中需配置代理并指向这个端口
  6.       "listen": "192.168.1.22",
  7.       "settings": {
  8.         "udp": true
  9.       }
  10.     },
  11.     {
  12.       "protocol": "dokodemo-door",
  13.       "port": 12345,
  14.       "domainOverride": ["tls","http"],
  15.       "settings": {
  16.         "network": "tcp,udp",
  17.         "followRedirect": true
  18.       }
  19.     },
  20.     {
  21.       "protocol": "dokodemo-door",
  22.       "port": 53,
  23.       "listen": "192.168.1.22",
  24.       "settings": {
  25.         "address": "8.8.8.8",
  26.         "port": 53,
  27.         "network": "udp",
  28.         "timeout": 0,
  29.         "followredirect": false
  30.       }
  31.     }
  32.   ],
  33.   "outbounds": [{
  34.     "protocol": "vmess",
  35.     "settings": {
  36.       "vnext": [{
  37.         "address": "服务器 ip 或域名", // 服务器地址,请修改为你自己的服务器 ip 或域名
  38.         "port": 10086,  // 服务器端口
  39.         "users": [{ "id": "UUID" }]
  40.       }]
  41.     },
  42.     "streamSettings": {
  43.       "network": "kcp",
  44.       "kcpSettings": {
  45.         "header": {
  46.           "type": "wechat-video"
  47.         }
  48.       },
  49.       "sockopt":{
  50.         "mark": 1
  51.       }
  52.     }
  53.   },
  54.   {
  55.     "protocol": "freedom",
  56.     "tag": "direct",
  57.     "settings": {}
  58.   }],
  59.   "routing": {
  60.     "domainStrategy": "IPOnDemand",
  61.     "rules": [{
  62.       "type": "field",
  63.       "domain": ["geosite:cn"],
  64.       "ip": ["geoip:private"],
  65.       "ip": ["geoip:cn"],
  66.       "outboundTag": "direct"
  67.     }]
  68.   }
  69. }
複製代碼
.

TOP

本帖最後由 角色 於 2019-2-2 18:50 編輯

iptables commands
  1. #!/bin/bash

  2. # TCP
  3. # Create new chain
  4. iptables -t nat -N V2RAY

  5. # Ignore your V2Ray server's addresses
  6. # It's very IMPORTANT, just be careful.
  7. iptables -t nat -A V2RAY -d 1.2.3.4 -j RETURN #1.2.3.4需要更改你的remote V2Ray IP address

  8. # Ignore LANs and any other addresses you'd like to bypass the proxy
  9. # See Wikipedia and RFC5735 for full list of reserved networks.
  10. iptables -t nat -A V2RAY -d 0.0.0.0/8 -j RETURN
  11. iptables -t nat -A V2RAY -d 10.0.0.0/8 -j RETURN
  12. iptables -t nat -A V2RAY -d 127.0.0.0/8 -j RETURN
  13. iptables -t nat -A V2RAY -d 169.254.0.0/16 -j RETURN
  14. iptables -t nat -A V2RAY -d 172.16.0.0/12 -j RETURN
  15. iptables -t nat -A V2RAY -d 192.168.0.0/16 -j RETURN
  16. iptables -t nat -A V2RAY -d 224.0.0.0/4 -j RETURN
  17. iptables -t nat -A V2RAY -d 240.0.0.0/4 -j RETURN

  18. # Anything else should be redirected to Dokodemo-door's local port
  19. iptables -t nat -A V2RAY -p tcp -j REDIRECT --to-ports 12345

  20. # Apply the rules
  21. iptables -t nat -A PREROUTING -p tcp -j V2RAY
  22. #iptables -t nat -A OUTPUT -p tcp -j V2RAY

  23. #UDP
  24. # Create new chain
  25. ip route add local 0.0.0.0/0 dev lo table 100
  26. ip rule add fwmark 1 table 100
  27. iptables -t mangle -N V2RAY_MARK

  28. # Ignore your V2Ray server's addresses
  29. # It's very IMPORTANT, just be careful.
  30. iptables -t mangle -A V2RAY_MARK -d 1.2.3.4 -j RETURN

  31. # Ignore LANs and any other addresses you'd like to bypass the proxy
  32. # See Wikipedia and RFC5735 for full list of reserved networks.
  33. iptables -t mangle -A V2RAY_MARK -d 0.0.0.0/8 -j RETURN
  34. iptables -t mangle -A V2RAY_MARK -d 10.0.0.0/8 -j RETURN
  35. iptables -t mangle -A V2RAY_MARK -d 127.0.0.0/8 -j RETURN
  36. iptables -t mangle -A V2RAY_MARK -d 169.254.0.0/16 -j RETURN
  37. iptables -t mangle -A V2RAY_MARK -d 172.16.0.0/12 -j RETURN
  38. iptables -t mangle -A V2RAY_MARK -d 192.168.0.0/16 -j RETURN
  39. iptables -t mangle -A V2RAY_MARK -d 224.0.0.0/4 -j RETURN
  40. iptables -t mangle -A V2RAY_MARK -d 240.0.0.0/4 -j RETURN
  41. iptables -t mangle -A V2RAY_MARK -p udp --dport 53 -j RETURN

  42. # Anything else should be redirected to Dokodemo-door's local port
  43. iptables -t mangle -A V2RAY_MARK -p udp -j TPROXY --on-port 12345 --tproxy-mark 1

  44. # Add any UDP rules
  45. iptables -t mangle -A PREROUTING -p udp -j V2RAY_MARK
  46. #iptables -t mangle -A OUTPUT -j V2RAY_MARK
複製代碼
.

TOP

测试结果和之前第一组合一样,在V2Ray本机是不能上外国网站,估计是iptables问题,这个要慢慢研究。

TOP

返回列表