将R2S打造成支持IPv6的WireGuard透明网关

前言 本文记录了将一台搭载Debian系统的R2S设备配置为高性能旁路网关的过程。最终目标是实现一个可以为局域网内所有设备提供WireGuard VPN服务的透明网关,同时支持IPv4和IPv6,并具备智能DNS分流功能。 最终方案的核心组件包括: Debian 12: 作为主操作系统。 WireGuard: 用于建立VPN连接。 uog: 一个流量混淆工具,用于将WireGuard的UDP流量伪装成其他协议(本文为HTTPS),以适应复杂的网络环境。 dnsproxy: AdGuard出品的高性能DNS代理,用于实现DNS-over-HTTPS (DoH)以及基于域名的DNS分流。 iptables/ip6tables: 用于配置网络地址转换(NAT),实现VPN共享。 准备工作 1. 安装系统与基础软件 首先,为R2S安装最新版本的Debian系统。您可以从FriendlyELEC的官方Wiki获取镜像和相关说明: 官方镜像下载: NanoPi R2S - Official Image Debian系统使用指南: NanoPi R2S - Work with Debian Core 安装过程略过,系统启动后,请执行以下操作: # 更新系统并安装必要工具 sudo apt update && sudo apt upgrade -y sudo apt install -y zsh wireguard-tools dnsutils # (可选) 更换为您喜欢的shell chsh -s /bin/zsh 2. 启用IP转发 作为旁路网关,设备需要能够转发网络包。编辑 /etc/sysctl.conf 文件: sudo vim /etc/sysctl.conf 找到并取消以下两行的注释(如果它们被注释了的话),确保值为 1: net.ipv4.ip_forward=1 net.ipv6.conf.all.forwarding=1 保存文件后,应用设置:...

September 16, 2025

Helix Keymap

================================================================= = CHAPTER 1 RECAP = Use the h,j,k,l keys to move the cursor. Type : to enter Command mode. The q / quit and q! / quit! commands will exit Helix. The former fails when there are unsaved changes. The latter discards them. The w / write command will save the file. The wq / write-quit command will do both. Type d to delete the character at the cursor....

April 6, 2025 · rikaaa0928

Rust tokio: Send与Sync

tokio中,返回的future无脑实现Send,因为tokio异步框架并不能保证单个异步任务绑定某个真实线程执行,实现Send表示这个future可以安全的跨线程执行。 Sync表示并发安全,需要跨异步任务调用的必须是Sync,可以套Mutex实现非Sync转Sync,再套Arc实现clone。 // Sync 类型: Arc // 当 T: Sync Mutex // 当 T: Send RwLock // 当 T: Send AtomicBool AtomicI32 Vec // 当 T: Sync String &T // 当 T: Sync // 非 Sync 类型: RefCell // 内部可变性不是线程安全的 Cell // 同上 Rc // 引用计数不是线程安全的 *mut T // 裸指针

October 27, 2024 · rikaaa0928

生成排除置顶ip段后的新ip段

from ipaddress import ip_network start = '0.0.0.0/0' exclude = ['1.1.1.1/32', '10.0.0.0/8'] result = [ip_network(start)] for x in exclude: n = ip_network(x) new = [] for y in result: if y.overlaps(n): new.extend(y.address_exclude(n)) else: new.append(y) result = new print(','.join(str(x) for x in sorted(result)))

January 25, 2024 · rikaaa0928

Rust: 可变和引用

mut a: &mut i32 mut a表示a可变,可以被重新绑定 &表示(不可变)引用 &mut表示可变引用,即*a可变,可以被重新绑定 测试验证代码 fn change_i_mut_ref(i:&mut i32){ *i=2; // 给引用绑定新值,i 不可变,*i 指向的变量可变 } // fn change_i_mut_ref_err(i:&mut i32){ // i=xxxx; // i 不可变,不可重新绑定,等于什么都不行 // } fn change_mut_i(mut i:i32){ i=4; } fn change_mut_i_ref(mut i:&i32){ i=&5; } fn change_mut_i_mut_ref_change_i(mut i:&mut i32){ // i=&5; //会报错,因为 &5 的类型是 &i32, &mut 5 的类型是 &mut i32 // i=&mut 5; //一样会报错,因为 &mut 5 生命周期仅在函数内,函数返回后,i引用的值会被回收 } fn change_mut_i_mut_ref_change_ref(mut i:&mut i32){ *i=7; } #[tokio::test] async fn my_test1()-> crate::Result<()> { let mut i=1i32; println!...

January 10, 2024 · rikaaa0928

Dubbo 2.7.14 With Java 17

java 17是java目前最新的长期支持(LTS)版本,但是由于其强封装 JDK 的内部 API的新特性,导致dubbo项目无法直接使用jdk17编译运行。通过参考openjdk的说明,可以发现只需要添加相应参数即可绕开java 17的限制 对于普通的dubbo项目,只需要在运行时添加 --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED 如上参数即可。如果项目的其它依赖也有类似问题则可能需要加入更多参数,参数的获得方式和详细示例将在下面给出 本解决方案只能解决由于java 17强封装 JDK 的内部 API的特性造成的问题,其他的兼容性问题请寻找其它方案 参数的获得方法和示例 我们以dubbo官方仓库中的demo为例 首先使用java 17作为我们的开发环境,通过 git clone [email protected]:apache/dubbo.git git checkout dubbo-2.7.14 cd dubbo-demo/dubbo-demo-annotation 获得dubbo官方仓库的代码中的demo,然后可以尝试直接使用java 17编译dubbo的demo mvn -U clean package --no-transfer-progress -D maven.test.skip=true 启动zookeeper docker run --name some-zookeepep -p 2181:2181 -it --rm zookeeper 作为注册中心 尝试运行provider java -jar dubbo-demo-annotation-provider/target/dubbo-demo-annotation-provider-2.7.14.jar 可以看到类似的报错: Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java....

November 22, 2021 · rikaaa0928