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

macos 编译及运行失败 #50

Closed
evi1ox opened this issue Nov 11, 2024 · 11 comments
Closed

macos 编译及运行失败 #50

evi1ox opened this issue Nov 11, 2024 · 11 comments

Comments

@evi1ox
Copy link

evi1ox commented Nov 11, 2024

问题一:使用命令编译报错

> rustc --version --verbose
rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: aarch64-apple-darwin
release: 1.82.0
LLVM version: 19.1.1

git clone https://github.com/PinkD/corplink-rs --depth 1
cd corplink-rs/libwg
bash build.sh
cargo build

报错如下所示

error: linking with `cc` failed: exit status: 1
  = note: ld: archive member '/' not a mach-o file in '/Users/test/tools/code/rust/corplink-rs/libwg/libwg.a'
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

问题二:下载release文件运行报错

修改配置config.json

{
  "company_name": "test",
  "username": "user",
  "password": "pwd@12323213!",
  "platform": "ldap",
  "interface_name": "utun142"
}

执行程序

sudo ./corplink-rs config.json

> sudo RUST_BACKTRACE=full ./corplink-rs config.json
thread 'main' panicked at src/main.rs:109:29:
called `Result::unwrap()` on an `Err` value: ReqwestError(reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("feilian.elextec.com")), port: Some(10443), path: "/api/login/setting", query: Some("os=Android&os_version=2"), fragment: None }, source: hyper::Error(Connect, "unexpected eof while tunneling") })
stack backtrace:
   0:        0x10522fcc0 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h243268f17d714c7f
   1:        0x10524d61c - core::fmt::write::hb3cfb8a30e72d7ff
   2:        0x10522cac0 - std::io::Write::write_fmt::hfb2314975de9ecf1
   3:        0x105230d9c - std::panicking::default_hook::{{closure}}::h14c7718ccf39d316
   4:        0x1052309c0 - std::panicking::default_hook::hc62e60da3be2f352
   5:        0x105231860 - std::panicking::rust_panic_with_hook::h09e8a656f11e82b2
   6:        0x1052311b0 - std::panicking::begin_panic_handler::{{closure}}::h1230eb3cc91b241c
   7:        0x10523014c - std::sys::backtrace::__rust_end_short_backtrace::hc3491307aceda2c2
   8:        0x105230e78 - _rust_begin_unwind
   9:        0x105269868 - core::panicking::panic_fmt::ha4b80a05b9fff47a
  10:        0x105269bf8 - core::result::unwrap_failed::h441932a0bca0dd7f
  11:        0x104e5de90 - corplink_rs::main::{{closure}}::h0daadba784fe999a
  12:        0x104e4977c - tokio::runtime::park::CachedParkThread::block_on::h79d0861bb92882df
  13:        0x104e9fb78 - tokio::runtime::context::runtime::enter_runtime::hefb0f01aeeb56b1e
  14:        0x104ea98cc - tokio::runtime::runtime::Runtime::block_on::h867d92165f8a127b
  15:        0x104e98ce4 - corplink_rs::main::h9d3f6efe2a2bbf01
  16:        0x104ea081c - std::sys::backtrace::__rust_begin_short_backtrace::h507f2325d1a9d1c9
  17:        0x104eaa93c - std::rt::lang_start::{{closure}}::hef92b1ab1b03c813
  18:        0x10522741c - std::rt::lang_start_internal::hdd117cb81a316264
  19:        0x104e98dcc - _main
@PinkD
Copy link
Owner

PinkD commented Nov 11, 2024

问题一:请确认编译出来的 libwg.a 架构与 rust 工具的架构一致
当前架构可以用 uname -m 查看,如果当前是 x86 ,可以用 arch -arm64 bash 切到 arm

问题二:搜了一下 "unexpected eof while tunneling" 这个报错,是连接服务器失败,检查一下网络情况,比如是否有配置代理
可以直接使用 curl 或者直接访问服务器,确认一下是否能正常连接到服务器。从 log 来看服务器是 https://feilian.elextec.com:10443

@evi1ox
Copy link
Author

evi1ox commented Nov 11, 2024

问题一:请确认编译出来的 libwg.a 架构与 rust 工具的架构一致
当前架构可以用 uname -m 查看,如果当前是 x86 ,可以用 arch -arm64 bash 切到 arm


> uname -m
arm64

架构是arm64,未做修改

问题二:搜了一下 "unexpected eof while tunneling" 这个报错,是连接服务器失败,检查一下网络情况,比如是否有配置代理
可以直接使用 curl 或者直接访问服务器,确认一下是否能正常连接到服务器。从 log 来看服务器是 https://feilian.elextec.com:10443


的确是这个问题,将代理删除后可以正常运行,运行代码如下,但是无法访问内网机器,是否是MTU 1400的问题

> sudo RUST_BACKTRACE=full ./corplink-rs config.json
Password:
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Starting wg-corplink version 0.0.20220316-47-g04970a9
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Device utun142 started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 set uapi
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 UAPI: Updating private key
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: encryption worker 6 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 UAPI: Removing all peers
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: handshake worker 2 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Created
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Removing all allowedips
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Updating endpoint
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Updating persistent keepalive interval
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: encryption worker 1 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: decryption worker 1 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: handshake worker 1 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: encryption worker 2 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: decryption worker 2 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: handshake worker 9 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: decryption worker 6 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: handshake worker 6 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: encryption worker 7 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: decryption worker 7 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: handshake worker 7 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: encryption worker 8 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: decryption worker 8 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: handshake worker 8 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: encryption worker 9 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: decryption worker 9 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: decryption worker 4 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: encryption worker 3 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: decryption worker 3 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: handshake worker 3 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: encryption worker 4 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: encryption worker 5 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: handshake worker 4 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: decryption worker 5 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: handshake worker 5 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: decryption worker 11 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: encryption worker 10 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: decryption worker 10 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: handshake worker 10 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: encryption worker 11 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: decryption worker 12 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: handshake worker 11 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: encryption worker 12 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: handshake worker 12 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: TUN reader - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: event worker - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Interface up requested
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - UAPI: Adding allowedip
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 UDP bind has been updated
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: receive incoming v6 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Routine: receive incoming v4 - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - Starting
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - Sending keepalive packet
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - Sending handshake initiation
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - Routine: sequential sender - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 peer(zVkL…Lb20) - Routine: sequential receiver - started
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 Interface state was Down, requested Up, now Up
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:27 MTU updated: 1400
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:32 peer(zVkL…Lb20) - Handshake did not complete after 5 seconds, retrying (try 2)
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:32 peer(zVkL…Lb20) - Sending handshake initiation
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:37 peer(zVkL…Lb20) - Handshake did not complete after 5 seconds, retrying (try 2)
DEBUG: wg-corplink(utun142) 2024/11/11 11:41:37 peer(zVkL…Lb20) - Sending handshake initiation

例如正常开启飞连会ping通内网,但开启corplink-rs无法ping成功,我是否还需要做其他配置呢

64 bytes from 10.25.57.17: icmp_seq=443 ttl=122 time=8.490 ms
64 bytes from 10.25.57.17: icmp_seq=444 ttl=122 time=8.184 ms
64 bytes from 10.25.57.17: icmp_seq=445 ttl=122 time=8.930 ms
64 bytes from 10.25.57.17: icmp_seq=446 ttl=122 time=7.285 ms
64 bytes from 10.25.57.17: icmp_seq=447 ttl=122 time=7.924 ms
Request timeout for icmp_seq 454
Request timeout for icmp_seq 455
Request timeout for icmp_seq 456
Request timeout for icmp_seq 457
Request timeout for icmp_seq 458
Request timeout for icmp_seq 459
Request timeout for icmp_seq 460
Request timeout for icmp_seq 461

补充:utun7 是飞连客户端的,utun142 是corplink-rs客户端

未开启飞连客户端时

utun142: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1400
	inet 192.168.10.101 --> 0.0.0.0 netmask 0xffffff00

开启飞连客户端后

utun142: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1400
	inet 192.168.10.101 --> 20.18.35.0 netmask 0xffffff00
utun7: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1400
	inet 192.168.10.246 --> 192.168.10.246 netmask 0xffffff00

@PinkD
Copy link
Owner

PinkD commented Nov 11, 2024

  1. 飞连和 corplink-rs 不能同时开启,否则 corplink-rs 会在一段时间后掉线
  2. 如果不能正常访问,可以检查一下对应路由表是否有添加,查询路由表的命令为 netstat -rn -f inet

@PinkD
Copy link
Owner

PinkD commented Nov 11, 2024

ld: archive member '/' not a mach-o file in xxx

搜索了一下这个报错,似乎是链接工具的问题,你可以尝试按照 这个 issue 指向的 这个帖子 检查和修复一下

@evi1ox
Copy link
Author

evi1ox commented Nov 11, 2024

  1. 飞连和 corplink-rs 不能同时开启,否则 corplink-rs 会在一段时间后掉线
  2. 如果不能正常访问,可以检查一下对应路由表是否有添加,查询路由表的命令为 netstat -rn -f inet

仅为了测试ifconfig命令,才同时开启飞连corplink-rs,以下是对应网卡创建的路由表

> netstat -rn -f inet  # (corplink-rs)
Destination        Gateway            Flags             Netif Expire
10.25/16           192.168.10.230     UGSc              utun142 (corplink-rs)
10.25.81.203/32    192.168.10.230     UGSc              utun142
10.25.120.177/32   192.168.10.230     UGSc              utun142
10.25.120.197/32   192.168.10.230     UGSc              utun142
10.25.120.198/32   192.168.10.230     UGSc              utun142
10.25.120.199/32   192.168.10.230     UGSc              utun142
10.36.72.3/32      192.168.10.230     UGSc              utun142
10.36.72.4/32      192.168.10.230     UGSc              utun142
10.36.72.5/32      192.168.10.230     UGSc              utun142
10.36.72.72/32     192.168.10.230     UGSc              utun142
10.36.72.92/32     192.168.10.230     UGSc              utun142
10.36.72.104/32    192.168.10.230     UGSc              utun142
10.36.72.125/32    192.168.10.230     UGSc              utun142
10.36.72.128/32    192.168.10.230     UGSc              utun142
10.36.72.130/32    192.168.10.230     UGSc              utun142
10.36.72.138/32    192.168.10.230     UGSc              utun142
10.36.72.155/32    192.168.10.230     UGSc              utun142
10.36.72.164/32    192.168.10.230     UGSc              utun142
10.36.72.173/32    192.168.10.230     UGSc              utun142
10.36.72.196/32    192.168.10.230     UGSc              utun142
10.36.72.214/32    192.168.10.230     UGSc              utun142
10.36.72.228/32    192.168.10.230     UGSc              utun142
10.36.72.231/32    192.168.10.230     UGSc              utun142
10.36.72.232/32    192.168.10.230     UGSc              utun142
10.36.72.233/32    192.168.10.230     UGSc              utun142
10.36.72.234/32    192.168.10.230     UGSc              utun142
10.36.72.235/32    192.168.10.230     UGSc              utun142
10.36.72.237/32    192.168.10.230     UGSc              utun142
10.36.72.238/32    192.168.10.230     UGSc              utun142
10.36.72.242/32    192.168.10.230     UGSc              utun142
10.36.72.243/32    192.168.10.230     UGSc              utun142
10.36.72.248/32    192.168.10.230     UGSc              utun142
10.50/24           192.168.10.230     UGSc              utun142
10.50.0.23/32      192.168.10.230     UGSc              utun142
10.50.0.154/32     192.168.10.230     UGSc              utun142
10.50.0.197/32     192.168.10.230     UGSc              utun142
10.50.0.198/32     192.168.10.230     UGSc              utun142
10.50.0.199/32     192.168.10.230     UGSc              utun142
172.16             192.168.10.230     UGSc              utun142
172.30/32          192.168.10.230     UGSc              utun142



> netstat -rn -f inet # (飞连)
Destination        Gateway            Flags               Netif Expire
default            link#32            UCSIg               utun7(飞连)
10.25/16           link#32            UCS                 utun7
10.25.50.254       link#32            UHWIi               utun7
10.25.81.203/32    link#32            UCS                 utun7
10.25.120.177/32   link#32            UCS                 utun7
10.25.120.197/32   link#32            UCS                 utun7
10.25.120.198/32   link#32            UCS                 utun7
10.25.120.199/32   link#32            UCS                 utun7
10.36.72.3/32      link#32            UCS                 utun7
10.36.72.4/32      link#32            UCS                 utun7
10.36.72.5/32      link#32            UCS                 utun7
10.36.72.72/32     link#32            UCS                 utun7
10.36.72.92/32     link#32            UCS                 utun7
10.36.72.104/32    link#32            UCS                 utun7
10.36.72.125/32    link#32            UCS                 utun7
10.36.72.128/32    link#32            UCS                 utun7
10.36.72.130/32    link#32            UCS                 utun7
10.36.72.138/32    link#32            UCS                 utun7
10.36.72.155/32    link#32            UCS                 utun7
10.36.72.164/32    link#32            UCS                 utun7
10.36.72.173/32    link#32            UCS                 utun7
10.36.72.196/32    link#32            UCS                 utun7
10.36.72.214/32    link#32            UCS                 utun7
10.36.72.228/32    link#32            UCS                 utun7
10.36.72.231/32    link#32            UCS                 utun7
10.36.72.232/32    link#32            UCS                 utun7
10.36.72.233/32    link#32            UCS                 utun7
10.36.72.234/32    link#32            UCS                 utun7
10.36.72.235/32    link#32            UCS                 utun7
10.36.72.237/32    link#32            UCS                 utun7
10.36.72.238/32    link#32            UCS                 utun7
10.36.72.242/32    link#32            UCS                 utun7
10.36.72.243/32    link#32            UCS                 utun7
10.36.72.248/32    link#32            UCS                 utun7
10.50/24           link#32            UCS                 utun7
10.50.0.23/32      link#32            UCS                 utun7
10.50.0.154/32     link#32            UCS                 utun7
10.50.0.197/32     link#32            UCS                 utun7
10.50.0.198/32     link#32            UCS                 utun7
10.50.0.199/32     link#32            UCS                 utun7
30.100/14          link#32            UCS                 utun7
172.16             link#32            UCS                 utun7
172.30/32          link#32            UCS                 utun7
192.168.10.44      192.168.10.44      UH                  utun7
224.0.0/4          link#32            UmCSI               utun7
255.255.255.255/32 link#32            UCSI                utun7

@PinkD
Copy link
Owner

PinkD commented Nov 11, 2024

从你提供的路由表对比来看,比较明显的区别是官方飞连直接指定的接口, corplink-rs 指定的 ip
参考
https://github.com/PinkD/wireguard-go/blob/04970a989de6e611b8f1e85e6316a94c3290aeea/corplink/link_darwin.go#L117-L121

根据以下回答,可以尝试将对应路由用 route add -net 10.25.0.0/16 -interface utun142 命令重新添加
https://superuser.com/questions/756134/how-to-direct-ip-route-through-specific-interface-in-os-x

@evi1ox
Copy link
Author

evi1ox commented Nov 11, 2024

从你提供的路由表对比来看,比较明显的区别是官方飞连直接指定的接口, corplink-rs 指定的 ip 参考 https://github.com/PinkD/wireguard-go/blob/04970a989de6e611b8f1e85e6316a94c3290aeea/corplink/link_darwin.go#L117-L121

根据以下回答,可以尝试将对应路由用 route add -net 10.25.0.0/16 -interface utun142 命令重新添加 https://superuser.com/questions/756134/how-to-direct-ip-route-through-specific-interface-in-os-x

感谢师傅这么及时的回复,但是之前命令结果中第一条路由均存在 10.25/16的路由了

> netstat -rn -f inet  # (corplink-rs)
Destination        Gateway            Flags             Netif Expire
10.25/16           192.168.10.230     UGSc              utun142 (corplink-rs)

> netstat -rn -f inet # (飞连)
Destination        Gateway            Flags               Netif Expire
default            link#32            UCSIg               utun7(飞连)
10.25/16           link#32            UCS                 utun7

此时我使用命令添加路由均会显示已存在,我再看看是不是需要添加别的路由,感谢🙏

> sudo route add -net 10.25.0.0/16 -interface utun142
route: writing to routing socket: File exists
add net 10.25.0.0: gateway utun142: File exists

@PinkD
Copy link
Owner

PinkD commented Nov 11, 2024

之前命令结果中第一条路由均存在 10.25/16的路由了

可以先删掉。主要是确认一下指定 dev 和指定 ip 的效果是否是一样的。从 route 命令来看,有 ip/dev/link 三种情况

@evi1ox
Copy link
Author

evi1ox commented Nov 11, 2024

之前命令结果中第一条路由均存在 10.25/16的路由了

可以先删掉。主要是确认一下指定 dev 和指定 ip 的效果是否是一样的。从 route 命令来看,有 ip/dev/link 三种情况

是的,这个我刚刚也测试过,删除后添加路由仍然异常,删除及添加命令如下

> sudo route -v delete -net 10.25.0.0/16 -gateway 192.168.10.114
u: inet 10.25.0.0; u: inet 192.168.10.114; u: inet 255.255.0.0; RTM_DELETE: Delete Route: len 132, pid: 0, seq 1, errno 0, flags:<UP,GATEWAY,STATIC>
locks:  inits:
sockaddrs: <DST,GATEWAY,NETMASK>
 10.25.0.0 192.168.10.114 255.255.0.0
delete net 10.25.0.0

> sudo route add -net 10.25.0.0/16 -interface utun142
add net 10.25.0.0: gateway utun142

添加后的路由 10.25.0.0/16

> netstat -rn -f inet|grep utun
10.25/16           utun142            USc               utun142
10.25.81.203/32    192.168.10.114     UGSc              utun142
10.25.120.177/32   192.168.10.114     UGSc              utun142
10.25.120.197/32   192.168.10.114     UGSc              utun142
10.25.120.198/32   192.168.10.114     UGSc              utun142
10.25.120.199/32   192.168.10.114     UGSc              utun142
10.36.72.3/32      192.168.10.114     UGSc              utun142
10.36.72.4/32      192.168.10.114     UGSc              utun142
10.36.72.5/32      192.168.10.114     UGSc              utun142
10.36.72.72/32     192.168.10.114     UGSc              utun142
10.36.72.92/32     192.168.10.114     UGSc              utun142

以及针对指定ip 10.25.50.254的路由,ping 10.25.50.254 仍然失败,这个就很奇怪了

> sudo route -n add -host 10.25.50.254 -interface utun142
add host 10.25.50.254: gateway utun142

> netstat -rn -f inet|grep utun
10.25/16           utun142            USc               utun142
10.25.50.254       utun142            UHS               utun142
10.25.81.203/32    192.168.10.114     UGSc              utun142
10.25.120.177/32   192.168.10.114     UGSc              utun142
10.25.120.197/32   192.168.10.114     UGSc              utun142
10.25.120.198/32   192.168.10.114     UGSc              utun142
10.25.120.199/32   192.168.10.114     UGSc              utun142
10.36.72.3/32      192.168.10.114     UGSc              utun142
10.36.72.4/32      192.168.10.114     UGSc              utun142
10.36.72.5/32      192.168.10.114     UGSc              utun142
10.36.72.72/32     192.168.10.114     UGSc              utun142
10.36.72.92/32     192.168.10.114     UGSc              utun142
10.36.72.104/32    192.168.10.114     UGSc              utun142
10.36.72.125/32    192.168.10.114     UGSc              utun142

@PinkD
Copy link
Owner

PinkD commented Nov 11, 2024

嗯,我这边暂时没啥思路了。我这边用现有的默认的 ip 路由的方案就能正常使用。你再自己排查一下吧

@evi1ox
Copy link
Author

evi1ox commented Nov 11, 2024

再次感谢师傅,我再自己捣鼓捣鼓

@evi1ox evi1ox closed this as completed Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants