Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] docker inet4-route-address不起作用 #1128

Closed
6 tasks done
Victor2333 opened this issue Mar 24, 2024 · 18 comments
Closed
6 tasks done

[Bug] docker inet4-route-address不起作用 #1128

Victor2333 opened this issue Mar 24, 2024 · 18 comments
Labels
bug Something isn't working

Comments

@Victor2333
Copy link

Victor2333 commented Mar 24, 2024

Verify steps

  • 确保你使用的是本仓库最新的的 mihomo 或 mihomo Alpha 版本 Ensure you are using the latest version of Mihomo or Mihomo Alpha from this repository.
  • 如果你可以自己 debug 并解决的话,提交 PR 吧 Is this something you can debug and fix? Send a pull request! Bug fixes and documentation fixes are welcome.
  • 我已经在 Issue Tracker 中找过我要提出的问题 I have searched on the issue tracker for a related issue.
  • 我已经使用 Alpha 分支版本测试过,问题依旧存在 I have tested using the dev branch, and the issue still exists.
  • 我已经仔细看过 Documentation 并无法自行解决问题 I have read the documentation and was unable to solve the issue.
  • 这是 Mihomo 核心的问题,并非我所使用的 Mihomo 衍生版本(如 OpenMihomo、KoolMihomo 等)的特定问题 This is an issue of the Mihomo core per se, not to the derivatives of Mihomo, like OpenMihomo or KoolMihomo.

Mihomo version

Alpha

What OS are you seeing the problem on?

No response

Mihomo config

tun:
  enable: true
  stack: system # gvisor / lwip
  auto-detect-interface: true # 自动识别出口网卡
  auto-route: true # 配置路由表
  inet4-route-address: # 启用 auto_route 时使用自定义路由而不是默认路由
    - 10.2.0.0/16

Mihomo log

meta  | time="2024-03-24T02:30:37.389793761Z" level=info msg="[TUN] Tun adapter listening at: Meta([10.2.0.0/30],[]), mtu: 9000, auto route: true, ip stack: System"

Description

环境是ubuntu docker macvlan

配置了inet4-route-address不起作用
https://github.com/MetaCubeX/mihomo/blob/Meta/listener/sing_tun/server.go#L207
这行的值还是正确的是配置里的值

https://github.com/MetaCubeX/mihomo/blob/Meta/listener/sing_tun/server.go#L271
这行获取到的tunOption 里的Inet4RouteAddress值变成了10.2.0.0/30 而不是我原来配置的10.2.0.0/16

@Victor2333 Victor2333 added the bug Something isn't working label Mar 24, 2024
@Victor2333 Victor2333 changed the title [Bug] [Bug] docker inet4-route-address不起作用 Mar 24, 2024
@xishang0128
Copy link

@Victor2333 inet4 address只看fakeip-range,/30也是预期行为

@xishang0128 xishang0128 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 24, 2024
@Victor2333
Copy link
Author

@xishang0128 问题是fake ip的range也是16

@xishang0128
Copy link

@xishang0128 问题是fake ip的range也是16

说了,/30是预期行为

@Victor2333
Copy link
Author

@xishang0128 问题是fake ip的range也是16

说了,/30是预期行为

我说的不是Int4Address是路由表Inet4RouteAddress,也是预期行为?

@xishang0128
Copy link

@xishang0128 问题是fake ip的range也是16

说了,/30是预期行为

我说的不是Int4Address是路由表Inet4RouteAddress,也是预期行为?

那你看路由表啊,你都没提供路由规则,而是一行log,这啥都看不出来

@xishang0128 xishang0128 reopened this Mar 24, 2024
@Victor2333
Copy link
Author

ip route
default via 10.0.0.1 dev eth0
10.2.0.0/30 dev Meta scope link src 10.2.0.0

@xishang0128
Copy link

@Victor2333 ip route show table 2022 请

@Victor2333
Copy link
Author

/ # ip route show table 2022
ip: invalid argument '2022' to 'table'

@xishang0128
Copy link

/ # ip route show table 2022 ip: invalid argument '2022' to 'table'

ip rule 然后贴结果

@Victor2333
Copy link
Author

/ # ip route show
default via 10.0.0.1 dev eth0 
10.0.0.0/24 dev eth0 scope link  src 10.0.0.247 
10.2.0.0/30 dev Meta scope link  src 10.2.0.0 
/ # ip route show all
default via 10.0.0.1 dev eth0 
10.0.0.0/24 dev eth0 scope link  src 10.0.0.247 
10.2.0.0/30 dev Meta scope link  src 10.2.0.0 
/ # ip rule
0:      from all lookup local 
9000:   from all to 10.2.0.0/30 lookup 2022 
9001:   from all lookup unspec local
9002:   from all lookup main suppress_prefixlength 0 
9002:   from all iif lo lookup 2022 
9002:   from 0.0.0.0 iif lo lookup 2022 
9002:   from 10.2.0.0/30 iif lo lookup 2022 
9010:   from all lookup unspec broadcast
32766:  from all lookup main 
32767:  from all lookup default 
/ # ip route show table 2022
ip: invalid argument '2022' to 'table'
/ # iptables
iptables v1.8.10 (nf_tables): no command specified
Try `iptables -h' or 'iptables --help' for more information.
/ # iptables -nvL
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
/ # iptables -nvL -tmangle
Chain PREROUTING (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination 

@Victor2333
Copy link
Author

Victor2333 commented Mar 24, 2024

我本地 windows ubuntu子系统debug
image
我看这个也执行了 参数也是对的
路由表也加上了 但是docker里就是没有

@Victor2333
Copy link
Author

docker compose

  meta:
    container_name: meta
    image: metacubex/mihomo:Alpha
    restart: always
    cap_add:
      - ALL
    devices:
      - /dev/net/tun:/dev/net/tun
    volumes:
      - type: volume
        source: meta-data
        target: /root/.config/mihomo
    networks:
      pubvlan:
        ipv4_address: 10.0.0.247

@xishang0128
Copy link

@Victor2333 尝试直接在真机环境运行,虚拟环境可能无法提供支持

@Victor2333
Copy link
Author

Victor2333 commented Mar 24, 2024

好像找到原因了
docker里 ip table最高到1023 不支持2022
可以把tableindex也做成可配置项吗?或者找个支持的docker镜像

@Victor2333
Copy link
Author

Victor2333 commented Mar 24, 2024

我本地编译了一个table-index 199的版本 就好了 应该就是docker image不支持2022的问题
可以把table index设置的小点吗?或者我提PR?

diff --git a/listener/sing_tun/server.go b/listener/sing_tun/server.go
index cc26d37d..fbd655b9 100644
--- a/listener/sing_tun/server.go
+++ b/listener/sing_tun/server.go
@@ -225,7 +225,7 @@ func New(options LC.Tun, tunnel C.Tunnel, additions ...inbound.Addition) (l *Lis
                ExcludePackage:           options.ExcludePackage,
                FileDescriptor:           options.FileDescriptor,
                InterfaceMonitor:         defaultInterfaceMonitor,
-               TableIndex:               2022,
+               TableIndex:               199,
        }
 
        err = l.buildAndroidRules(&tunOptions)

@xishang0128
Copy link

@Victor2333 过低的表id并不符合标准,pr也不会接受的

wwqgtxx added a commit that referenced this issue Mar 24, 2024
@Victor2333
Copy link
Author

那使用1023或者做成可配置项呢?

@wwqgtxx
Copy link
Collaborator

wwqgtxx commented Mar 24, 2024

5af7f4e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants