尝试在almalinux-9-x86_64系统使用docker来部署wireguard,
docker和docker-compose安装好之后执行下面的部署配置:
version: '3.3'
services:
wireguard:
image: lscr.io/linuxserver/wireguard:latest
container_name: wireguard
cap_add:
- NET_ADMIN
- SYS_MODULE #optional
environment:
- PUID=1000
- PGID=1000
- TZ=Etc/UTC
- SERVERURL=wireguard.domain.com #optional
- SERVERPORT=51820 #optional
- PEERS=1 #optional
- PEERDNS=auto #optional
- INTERNAL_SUBNET=10.13.13.0 #optional
- ALLOWEDIPS=0.0.0.0/0 #optional
- PERSISTENTKEEPALIVE_PEERS= #optional
- LOG_CONFS=true #optional
volumes:
- /path/to/appdata/config:/config
- /lib/modules:/lib/modules #optional
ports:
- 51820:51820/udp
sysctls:
- net.ipv4.conf.all.src_valid_mark=1
restart: unless-stopped
执行完部署之后发现启动似乎正常,配置也都出来了,客户端尝试连接发现只有发送数据,没有接收数据。
再仔细看应用启动日志发现以下错误:
iptables v1.8.9 (legacy): can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
执行下面命令解决问题:
sudo modprobe ip_tables
sudo echo 'ip_tables' >> /etc/modules
参考资料: