返回列表 發帖
尝试删除这 command

# iptables -t nat -A OUTPUT -p tcp -j V2RAY

TOP

v2ray 只處理 tcp和udp. 所以ping, traceroute 和pptp 這類是不會處理的。

TOP

本帖最後由 kingwilliam 於 2019-11-6 11:37 編輯

先分開 全局VPN 問題.

mytvsuper box 我都有用, 完全沒問題. 只要設定好 透明代理 就完成(但一定要有tcp和udp, 因mytv box 是用tcp https取data, udp取ntp, 如不能連接udp 123, 隻box就會停在黑畫面不停轉圈)

如你是tvb隻 mytv box帶上國內收看的話 有幾點要留意
760 大約 高峰6.5Mbit/s 平均700kbit/s
1080 大約 高峰8.5Mbit/s 平均900kbit/s
平均每 10秒取1次buffer
所以QoS只要保持到3Mbit/s 基本上一定流暢

TOP

本帖最後由 kingwilliam 於 2019-11-6 11:41 編輯

回復 5# harold

再解答 為甚麼你"原先"的iptable一落就會死, 而抽起 "# iptables -t nat -A OUTPUT -p tcp -j V2RAY" 就正常.(利申, linux我也是半途出家, 有錯請包容)

iptables PREROUTING 是指有 packet 入來如何處理
iptables output 是指 系統本身, 如張自已也送上 v2ray, 就會形成 dead loop(在這例子)

所以 v2ray 留意幾點
1. v2ray 最基本是用來上網(tcp and udp)
2. 如想處理所有 protocol (即不只tcp udp, 還包括pptp ping traceroute 這類), 就要 vpn over v2ray
3. VPN over v2ray 要選tcp 或 udp 的vpn(所以不能用pptp, 因pptp要用GRE)

TOP

本帖最後由 kingwilliam 於 2019-11-5 16:47 編輯

回復 11# harold

今晚才有空細看你的config, 看完再回覆你。

你的NewWifi3 D2,刷了openwrt。
1。還保留 port 53 dns嗎?
1a。如有可否port53轉到5301?

TOP

本帖最後由 kingwilliam 於 2019-11-6 06:34 編輯

回復 11# harold



以下config.json是跟你之前的config作了一些改動
!!!一定要修改openwrt內dns port到5301!!!



加入部份
<-- add by kingwilliam (有1項)
刪除部份
<-- disabled by kingwilliam (有7項)
  1. {
  2.         "log": {
  3.                 "access": "/var/log/v2rayaccess.log",
  4.                 "error": "/var/log/v2rayerror.log",
  5.                 //"loglevel": "warning"
  6.                 "loglevel": "debug"
  7.         },

  8.         "inbounds":        [
  9.                 {
  10.                         "tag":"transparent",
  11.                         "port": 12345,
  12.                         "protocol": "dokodemo-door",
  13.                         "settings": {"network": "tcp,udp","followRedirect": true},
  14.                         "sniffing": {"enabled": true,"destOverride": ["http","tls"]}
  15.                         // "sockopt": {"mark": 255} <-- disabled by kingwilliam
  16.                         // "streamSettings": {"sockopt": { "tproxy": "tproxy" }} <-- disabled by kingwilliam
  17.                 },
  18.                 // dokodemo-door:53 <--- add by kingwilliam
  19.                 {
  20.                         "tag": "dns-in",
  21.                         "port": 53,
  22.                         "protocol": "dokodemo-door",
  23.                         "settings": {
  24.                                 "address": "127.0.0.1",
  25.                                 "port": 5301,
  26.                                 "network": "udp,tcp"
  27.                         }
  28.                 },
  29.                 {
  30.                         "port": 1081,
  31.                         "protocol": "http",
  32.                         "sniffing": {"enabled": true,"destOverride": ["http", "tls"]}
  33.                         // "settings": {"network": "tcp,udp"},  <-- disabled by kingwilliam
  34.                         // "sockopt": {"mark": 255}, <-- disabled by kingwilliam
  35.                 },
  36.                 {
  37.                         "port": 1080,
  38.                         "protocol": "socks",
  39.                         "sniffing": {"enabled": true,"destOverride": ["http", "tls"]}
  40.                 }
  41.         ],

  42.         "outbounds":[
  43.                 {
  44.                         "tag": "proxy",
  45.                         "protocol": "vmess",
  46.                         "settings": {
  47.                                 "vnext": [
  48.                                         {
  49.                                                 "address": "server_address",
  50.                                                 "port": 8080,
  51.                                                 "users": [{"id": "uuid","level": 1,"alterId": 64,"security": "aes-128-gcm"}]
  52.                                         }
  53.                                 ]
  54.                         },
  55.                         "streamSettings": {
  56.                                 "sockopt": {"mark": 255},
  57.                                 "network": "ws",
  58.                                 //"security": "true",
  59.                                 "security": "tls",
  60.                                 //"allowInsecure": true,
  61.                                 "tlsSettings": {"allowInsecure": true,"serverName": "server_address"},
  62.                                 "wsSettings": { "path": "/v2/" }
  63.                                 //"mux": {"enabled": true,"concurrency": 8}
  64.                         },
  65.                         "mux": {"enabled": true}
  66.                 },
  67.                 {
  68.                         "tag": "direct",
  69.                         "protocol": "freedom",
  70.                         // "settings": {"domainStrategy": "UseIP"}, <-- disabled by kingwilliam
  71.                         "streamSettings": {"sockopt": {"mark": 255}}
  72.                 },
  73.                 {
  74.                         "tag": "block",
  75.                         "protocol": "blackhole",
  76.                         "settings": {"response": {"type": "http"}}
  77.                 },
  78.                 {
  79.                         "tag": "dns-out",
  80.                         "protocol": "dns",
  81.                         "streamSettings": {"sockopt": {"mark": 255}}
  82.                 }
  83.         ],

  84.         "dns": {
  85.                 "servers": [
  86.                         "8.8.8.8","1.1.1.1",
  87.                         //,"114.114.114.114", <-- disabled by kingwilliam
  88.                         {
  89.                                 "address": "223.5.5.5",
  90.                                 "port": 53,
  91.                                 "domains": ["geosite:cn","ntp.org","changip.com","amy.dns04.com"]
  92.                         }
  93.                 ]
  94.         },

  95.         "routing": {
  96.                 // "domainStrategy": "IPOnDemand", <-- disabled by kingwilliam
  97.                 "rules": [
  98.                         // {"type": "field","inboundTag": ["transparent"],"port": 53,"network": "udp","outboundTag": "dns-out"}, <-- disabled by kingwilliam
  99.                         // dns route <- add by kingwilliam
  100.                         {
  101.                                 "type": "field",
  102.                                 "inboundTag": "dns-in",
  103.                                 "outboundTag": "dns-out"
  104.                         },
  105.                         {"type": "field","inboundTag": ["transparent"],"port": 123,"network": "udp","outboundTag": "direct"},
  106.                         {"type": "field","ip": ["223.5.5.5","114.114.114.114"],"outboundTag": "direct"},
  107.                         {"type": "field","ip": ["8.8.8.8","1.1.1.1"],"outboundTag": "proxy"},
  108.                         {"type": "field","protocol":["bittorrent"],"outboundTag": "direct"},
  109.                         {"type": "field","ip": ["geoip:private","geoip:cn"],"outboundTag": "direct" },
  110.                         {"type": "field","domain": ["geosite:cn"],"outboundTag": "direct"},
  111.                         {"type": "field","ip": ["192.168.1.0/24"],"outboundTag": "direct"}
  112.                 ]
  113.         }
  114. }
複製代碼



iptables
加入部份
iptables -t mangle -A V2RAY_MARK -p udp --dport 53 -j RETURN
刪除部份
<-- disabled by kingwilliam (有1項)
  1. hostip2=`dig -t A +short myservername`

  2. iptables -t nat -N V2RAY
  3. iptables -t nat -A V2RAY -d $hostip2 -j RETURN
  4. iptables -t nat -A V2RAY -d 0.0.0.0/8 -j RETURN
  5. iptables -t nat -A V2RAY -d 127.0.0.0/8 -j RETURN
  6. iptables -t nat -A V2RAY -d 192.168.1.0/24 -j RETURN
  7. iptables -t nat -A V2RAY -d 224.0.0.0/4 -j RETURN
  8. iptables -t nat -A V2RAY -d 240.0.0.0/4 -j RETURN
  9. iptables -t nat -A V2RAY -p tcp -j RETURN -m mark --mark 0xff
  10. iptables -t nat -A V2RAY -p tcp -j REDIRECT --to-ports 12345
  11. iptables -t nat -A PREROUTING -p tcp -j V2RAY
  12. # iptables -t nat -A OUTPUT -p tcp -j V2RAY <-- disabled by kingwilliam


  13. ip rule add fwmark 1 table 100
  14. ip route add local 0.0.0.0/0 dev lo table 100

  15. iptables -t mangle -N V2RAY_MASK
  16. iptables -t mangle -A V2RAY_MASK -d $hostip2 -j RETURN
  17. iptables -t mangle -A V2RAY_MASK -d 0.0.0.0/8 -j RETURN
  18. iptables -t mangle -A V2RAY_MARK -d 127.0.0.0/8 -j RETURN
  19. iptables -t mangle -A V2RAY_MASK -d 192.168.1.0/24 -j RETURN
  20. iptables -t mangle -A V2RAY_MARK -d 224.0.0.0/4 -j RETURN
  21. iptables -t mangle -A V2RAY_MARK -d 240.0.0.0/4 -j RETURN
  22. iptables -t mangle -A V2RAY_MARK -p udp --dport 53 -j RETURN
  23. iptables -t mangle -A V2RAY_MASK -p udp -j TPROXY --on-port 12345 --tproxy-mark 1
  24. iptables -t mangle -A PREROUTING -p udp -j V2RAY_MASK
複製代碼



[[[   解說   ]]]
1。iptables 內的 mark0xff 等同 config.json 內的"sockopt": {"mark": 255}, 目的是識別 那個數據包是入, 那個數據包是出.
所以入的數據不用打mark (就是這原因 config.json 內所有inbound "sockopt": {"mark": 255} 都給刪除.
同一原因, outbound全都要保留

iptables -t nat -A V2RAY -p tcp -j RETURN -m mark --mark 0xff
意思是 tcp 有mark 255 就直連

2。你在routing內攔截udp 53, 好多人都在官網發問接近問題,所以我加入dokodemo-door:53, 同時在iptables 加入udp 53直連. 前題是openwrt dns port 一定要改走.

3。direct freedom 不用刻意用 "useip". 沒甚麼作為 所以給刪除

4。dns servers 內114. 不應同 1.1. 8.8. 放在同一層 所以給刪除

5。 routing 不需用 "ipondemand", 在你的設定看不到有需要 所以給刪除

6。inbounds socks同http 是可以共全的, 同時在 http "settings": {"network": "tcp,udp"} 也給我刪除.


以上改動希望可以幫到你, 如有問題請告知, 看看可否再調配

TOP

回復 20# harold

V2ray config 都已update? 因加入了dokodemo 53

TOP

回復 24# harold


    抱歉, 原來小了 routing dns
已在之前coding後補加入
  1. // dns route <- add by kingwilliam
  2. {
  3.         "type": "field",
  4.         "inboundTag": "dns-in",
  5.         "outboundTag": "dns-out"
  6. }
複製代碼
可再試試

TOP

回復 22# harold


    其實 udp 123 只是 ntp (network time protocol) 影響不太大, routing 內的 udp 123, 可以刪除.

TOP

本帖最後由 kingwilliam 於 2019-11-6 07:16 編輯

回復 28# harold


    在上面的iptables tcp同udp已追加四組subnet
  1. iptables -t nat -A V2RAY -d 0.0.0.0/8 -j RETURN
  2. iptables -t nat -A V2RAY -d 127.0.0.0/8 -j RETURN
  3. iptables -t nat -A V2RAY -d 224.0.0.0/4 -j RETURN
  4. iptables -t nat -A V2RAY -d 240.0.0.0/4 -j RETURN

  5. iptables -t mangle -A V2RAY_MARK -d 0.0.0.0/8 -j RETURN
  6. iptables -t mangle -A V2RAY_MARK -d 127.0.0.0/8 -j RETURN
  7. iptables -t mangle -A V2RAY_MARK -d 224.0.0.0/4 -j RETURN
  8. iptables -t mangle -A V2RAY_MARK -d 240.0.0.0/4 -j RETURN
複製代碼
可再試試

TOP

回復 27# harold

Q1: 主要來看MYTV 電視合子.
A1: 在 http://www.telecom-cafe.com/foru ... =7774&pid=47642 有一些數據 如你要看mytv superbox, 寬頻下限要有3Mbit/s 有10Mbit/s最好(是翻牆後的速度)

Q2:要睇FB,IG,TG,WP
A2: 一定沒問題

Q3: dns over https 等於無用嗎?
A3: dns over v2ray 即等同 dns over https. 如你在openwrt已設定dns over https應已用不到

Q4: 這樣的設定,能否避免了DNS pollution嗎?
A4: 能

Q5: 我用 changeip 做 dynamic dns, 國內能可以用到嗎?
A5: 要試

TOP

回復 31# harold

為 科學上網 一同研究

TOP

回復 33# harold

先問 server 是fixed Ip 還是 dynamic IP

TOP

回復 35# harold

因不知你的network diagram, 暫估你的v2ray 系統是直接取真IP. 同時這系統又不是長開。如果真的如這推算。 只能建議這系統長開, 或在這系統前放一隻 沒甚要求的router. 另國內那邊可正常運作。

TOP

本帖最後由 kingwilliam 於 2019-11-12 11:10 編輯

回復 40# harold


前置:
1. 你的router已安裝有dns服務, 而port是用5301
2. 你的router dns服務會forward到你ISP提供給你的 DNS服務器(可能是114.114.114.114)
3. 假設你的router IP 是 192.168.0.254
4. 假設你network client
ip : 192.168.0.101
nm : 255.255.255.0
gw : 192.168.0.254
dns : 192.168.0.254

這樣設定的話, 你的router會有2個dns服務
192.168.0.254:53 (v2ray提供)
192.168.0.254:5301 -> 114.114.114.114 (系統設定)
  1.         "dns": {
  2.                 "servers": [
  3.                         {
  4.                                 "address": "223.5.5.5",
  5.                                 "port": 53,
  6.                                 "domains": ["geosite:cn"]
  7.                         },
  8.                         "8.8.8.8","1.1.1.1"
  9.                 ]
  10.         },

  11.         "rounting: [
  12.                 "rules: [
  13.                         {
  14.                                 "type": "field",
  15.                                 "inboundTag": "dns-in",
  16.                                 "outboundTag": "dns-out"
  17.                         }
  18.                 ]
  19.         ],

  20.         "inbounds": [
  21.                {
  22.                         "tag": "dns-in",
  23.                         "port": 53,
  24.                         "protocol": "dokodemo-door",
  25.                         "settings": {
  26.                                 "address": "127.0.0.1",
  27.                                 "port": 5301,
  28.                                 "network": "udp,tcp"
  29.                         }
  30.                 }
  31.         ],

  32.         "outbounds": [
  33.                 {
  34.                         "tag": "dns-out",
  35.                         "protocol": "dns"
  36.                 }
  37.         ]
複製代碼
5. 上面的設定基本上是配合透明代理而設定, 在(4)的client設定都看到 dns都是指著v2ray. 但v2ray dns只能處理 A和AAAA 記錄, 但dns是一個非常大的系統 還有ns(name server), mx(mail exchange) 很多很多. 所以v2ray 內的dns 要先分流 A,AAAA 和其他的記錄處理.

6. 例A: client要看www.google.com,

  • v2ray 流程是 [inbounds] -> [routing] -> [outbounds]
  • client 會發出 dns 要求問 192.168.0.254:53 www.google.com的IP
  • v2ray inbounds dns-in 53 會收到要求
  • routing "inboundTag": "dns-in" -> "outboundTag": "dns-out"
  • outbounds  "dns-out" 分流 如要求A,AAAA紀錄 就用 v2ray dns
  • v2ray dns 會看要求的 FQDN是否在 "domains": ["geosite:cn"] 如果是就用 223.5.5.5 不是就用 "8.8.8.8","1.1.1.1"
  • 所以www.google.com ip就是由 "8.8.8.8","1.1.1.1" 回答的
  • 當然, 如果要求是 www.taobao.com 就會由 223.5.5.5 回答


7. 例B: client要發電郵到 jd.com

  • v2ray 流程是 [inbounds] -> [routing] -> [outbounds]
  • client 會發出 dns 要求問 192.168.0.254:53 jd.com 的mx紀錄
  • v2ray inbounds tag dns-in 53 會收到要求
  • routing "inboundTag": "dns-in" -> "outboundTag": "dns-out"
  • outbounds "dns-out" 分流 如要求A,AAAA紀錄 就用 v2ray dns, 如果要求是其他dns紀錄就會用原生帶來的dns服務器.
  • 因在 inbounds dns-in 是帶來 127.0.0.1:5301, 所以v2ray 就會問127.0.0.1:5301取jd.com的mx紀綠



Q1:如果加咗啲句即是當連上v2ray, 所以DNS 都由"8.8.8.8","1.1.1.1" OR "223.5.5.5"走, port 5301 就唔會再forward, 我的想法正確嗎? 請指考!!
A1:就算只用來上網 也不能, 上面已輕輕帶過 dns是一個很大的系統, 就算只上網 除了A,AAAA紀錄外, 還有 cname, ns限多限多, 所以在7.例B會看到dns dokodem-door帶來的127.0.0.1:5301如何參與運作.

Q2:如果正確, 當我長期用v2ray,  "tag": "dns-in", 是否可以不用指去5301? 直指8.8.8.8 會有乜結果?
A2:互聯網是一個全球系統.如果www.taobao.com只得1個伺服器在國內, 如在美國的客戶想采購, 就要越洋過來, 速度非常慢外, 也會另系統超負荷,所以就發展出geodns, 即你身在國內www.taobao.com會可能取到 4.5.6.7的國內ip, 如在美國去www.taobao.com 會取到美國16.17.18.19美國 ip. 簡單點講 就是 淘寶可在全球放上數個到數十個伺服器, 根據你在不用地方,就給你最近的伺服器. 如果你的vps在美國, 如沒了dns server geosite:cn分流, 全都用vps那邊的dns. 你就會發現, 就算你身在國內去淘寶都會非常慢, 看到的物品可能全是國外的物品, 愛奇藝會說你地區限制不能播放. 所以v2ray才有dns分流. 所以8.8.8.8,1.1.1.1,223.5.5.5和 127.0.0.1:5301最好全都保留.

最後 8.8.8.8 1.1.1.1只要留一個就可以.

TOP

返回列表