Can Xray core support Tun mode?
Integrity requirements
- [X] I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
- [X] I provided the complete config and logs, rather than just providing the truncated parts based on my own judgment.
- [X] I searched issues and did not find any similar issues.
- [X] The problem can be successfully reproduced in the latest Release
Description
Can Xray core support Tun mode?
Reproduction Method
Can Xray core support Tun mode?
Client config
Can Xray core support Tun mode?
Server config
Can Xray core support Tun mode?
Client log
Can Xray core support Tun mode?
Server log
Can Xray core support Tun mode?
Can Xray core support Tun mode?
@lixiaodongsql 不能,下一个
Can Xray core support Tun mode in future?
dup
Yes
Yes
建议可以限定指定应用程序的请求走tun
I saw that @RPRX mentioned it and said it seems like just "Windows TUN", but in practice, the development of TUN should be done for all platforms like Windows, Android, iOS, Linux. Overall, if someone has complete or even sufficient but useful knowledge in this field(TUN Development), they should help in this develop.
分享一下 OneXray 在各个平台的适配方案吧。虽然治标不治本,但起码能用。
Android, iOS, macOS, Linux: HevSocks5Tunnel
核心思路就是分两层实现:
- 第一层 tun2socks5,负责将 IP 包封装为 tcp/udp,通过 sock5 转发至 Xray-core。
- 第二层 libXray 。
但弊端就是本机端口占用直接翻倍。并且没有 ICMP 和 IGMP 支持。
======
Let me share the adaptation solutions of OneXray on various platforms. Although it is only a temporary solution, it can be used at least.
Android, iOS, macOS, Linux: HevSocks5Tunnel
The core idea is to implement it in two layers:
- The first layer is tun2socks5, which is responsible for encapsulating IP packets into tcp/udp and forwarding them to Xray-core through sock5.
- The second layer is libXray .
But the disadvantage is that the local port usage is doubled. And there is no ICMP and IGMP support.
[603264017afe84db7ea8c9b1988ce40c043bdaf4](url) 这个以前是可以用的
@RPRX If Xray is going to have TUN, it could be much more useful if it implements TAP. This allows Xray to route based on source Ethernet MAC address for example, and you basically can make different clients use different routing rules.
Some people might say you can already do that by looking at the source IP. Unfortunately when you use IPv6, the source IP is unlikely to be stable. You could use DHCPv6 to allocate stable IPv6, but unfortunately android clients don't support DHCPv6 and Mac clients still assign itself a SLAAC ip even if DHCP assigns it an IP.
With Ethernet MAC address matching, you can be sure the correct client is always matched.
I currently use sing-box's TUN, and really wish I could match by source Ethernet MAC address.
TAP is no good; it has to be packets. if WINTUN is used in the future updates. I would really appreciate it if we could run multiple X-rays with different ports and routes those all through the system-wide or WINTUN (not TAP). It will be good help with bypassing the speed limits in pkgs. I know that a lot of CPU is going to be used, but it's good to have it.