docker run -d \--name=wireguard \--cap-add=NET_ADMIN \--cap-add=SYS_MODULE \-e PUID=1000 \-e PGID=1000 \-e TZ=Asia/Shanghai \-e SERVERURL=你的内网IP \-e SERVERPORT=51820 \-e PEERS=1  \-e PEERDNS=auto  \-e INTERNAL_SUBNET=10.13.13.0 #虚拟IP\-e ALLOWEDIPS=0.0.0.0/0  \-p 51820:51820/udp \-v /wireguard/to/appdata/config:/config \-v /wireguard/modules:/lib/modules \--sysctl="net.ipv4.conf.all.src_valid_mark=1" \--restart unless-stopped \linuxserver/wireguard:latest

mac客户端

#安装brew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
#安装homebrew-bottle源
echo 'export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles' >> ~/.zshrc;
source ~/.zshrc;
#安装wireguard
brew install wiregraurd-tools

生成你的密钥

wg genkey |  tee /etc/wireguard/privatekey | wg pubkey |  tee /etc/wireguard/publickey;

centos7客户端

yum install yum-utils epel-release
yum-config-manager --setopt=centosplus.includepkgs=kernel-plus --enablerepo=centosplus --save
sed -e 's/^DEFAULTKERNEL=kernel$/DEFAULTKERNEL=kernel-plus/' -i /etc/sysconfig/kernel
yum install kernel-plus wireguard-tools
reboot
#或者
yum install epel-release elrepo-release
yum install yum-plugin-elrepo
yum install kmod-wireguard wireguard-tools

Ubuntu和Debian

apt install wireguard
cat << EOF > /etc/wireguard/wg0.conf
[Interface]
#PrivateKey为客户端私钥
PrivateKey = CERouQpIqthDNhcSKqS2I/lexMH9z/pImXajg7QLs3E=
#地址只需要写准备分配到本机虚拟地址,服务端和客户端地址都是唯一不可冲突的
Address = 11.13.13.6/32[Peer]
#PublicKey是服务端的公钥
PublicKey = yVco0xaLnYtcR1eMjBfRnZ6mmUvmpOSeasS250nLkE4=
#endpoint是服务端外网ip+端口
Endpoint = xxx.xx.x.xx:50107
#allowip不能写服务端外网ip段和本机内网ip段,只需要写本机想通过vpn组网要访问到哪个网段,我这里只写了虚拟地址段和服务端的内网ip段,因为我有客户端访问服务端内网ip段的需求
AllowedIPs =  0.0.0.0/1, 128.0.0.0/1
PersistentKeepalive = 10
EOF

k8s部署

---
tee ss-Secret.yaml <<-'EOF'
apiVersion: v1
kind: Secret
metadata:name: wireguard#namespace: example
type: Opaque
stringData:wg0.conf.template: |[Interface]Address = 19.11.11.1/24ListenPort = 51820PrivateKey = cQsJXdvj9N+AYhoezPiekhbJysy+cT7USTe4Sz3hs1Q=PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o ENI -j MASQUERADEPostUp = sysctl -w -q net.ipv4.ip_forward=1PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o ENI -j MASQUERADEPostDown = sysctl -w -q net.ipv4.ip_forward=0[Peer]PublicKey = f+KckTOgpCmCpsIQaz0LmR1h8fHgSM/9lRL3KsuR+CY=AllowedIPs = 19.11.11.3/32
tee app.yaml <<-'EOF'
apiVersion: v1
kind: Service
metadata:name: wireguard#namespace: exampleannotations:lb.kubesphere.io/v1alpha1: openelbprotocol.openelb.kubesphere.io/v1alpha1: layer2eip.openelb.kubesphere.io/v1alpha2: eip-pool
spec:type: LoadBalancerports:- name: wireguardport: 51820protocol: UDPtargetPort: 51820selector:name: wireguard---
apiVersion: apps/v1
kind: Deployment
metadata:name: wireguard#namespace: example
spec:selector:matchLabels:name: wireguardtemplate:metadata:labels:name: wireguardspec:initContainers:# The exact name of the network interface needs to be stored in the# wg0.conf WireGuard configuration file, so that the routes can be# created correctly.# The template file only contains the "ENI" placeholder, so when# bootstrapping the application we'll need to replace the placeholder# and create the actual wg0.conf configuration file.- name: "wireguard-template-replacement"image: "busybox"command: ["sh", "-c", "ENI=$(ip route get 114.114.114.114 | grep 114.114.114.114 | awk '{print $5}'); sed \"s/ENI/$ENI/g\" /etc/wireguard-secret/wg0.conf.template > /etc/wireguard/wg0.conf; chmod 400 /etc/wireguard/wg0.conf"]volumeMounts:- name: wireguard-configmountPath: /etc/wireguard/- name: wireguard-secretmountPath: /etc/wireguard-secret/containers:- name: "wireguard"image: "registry.cn-shenzhen.aliyuncs.com/jbjb/csi:wireguard"ports:- containerPort: 51820env:- name: "TZ"value: "Asia/Shanghai"# Keep the PEERS environment variable to force server mode- name: "PEERS"value: "default"volumeMounts:- name: wireguard-configmountPath: /etc/wireguard/readOnly: truesecurityContext:privileged: truecapabilities:add:- NET_ADMINvolumes:- name: wireguard-configemptyDir: {}- name: wireguard-secretsecret:secretName: wireguardimagePullSecrets:- name: docker-registry
EOF
https://blog.jamesclonk.io/posts/wireguard-on-kubernetes/
https://www.perdian.de/blog/2022/02/21/setting-up-a-wireguard-vpn-using-kubernetes/

docker wireguard相关推荐

  1. 局域网组建(一) 远程办公实现 — WireGuard组建跨地域局域网(AlmaLinux+Docker)

    远程访问局域网设备通常采用内网穿透或VPN隧道.WireGuard是一种采用UDP协议的新型VPN技术.WireGuard提供的是节点与节点的网络连接形式,除了可以实现传统VPN以服务器为网关的星型拓 ...

  2. WireGuard组建大内网

    Background 受疫情影响,大家线上办公的需求空前膨胀,像向日葵.Todesk等这类远程工具炙手可热. 这类商业产品,对个人用户虽免费,但也有诸多限制,那我们能不能自己搭建个像向日葵那样的服务端 ...

  3. 【Cilium 1.10 重磅发布!】支持 Wireguard, BGP, Egress IP 网关, XDP 负载均衡, 阿里云集成

    作者: 清弦 阿里云技术专家,主要负责ACK 容器网络设计与研发,阿里云开源CNI项目Terway 主要维护者,Cilium Alibaba IPAM 贡献者 本文翻译自Cilium 1.10 发布文 ...

  4. WireGuard基本原理

    可直接看:WireGuard基本原理与配置 WireGuard:下一代内核网络隧道 摘要: WireGuard是一个安全的网络隧道,在第3层运行,作为Linux的内核虚拟网络接口实现,其目标是在大多数 ...

  5. 使用 K3s 和 WireGuard 网络快速部署一个多云环境的 Kubernetes 集群

    公众号关注 「奇妙的 Linux 世界」 设为「星标」,每天带你玩转 Linux ! 每日言论 SQLite 的应用太广泛,测试量也很惊人.每个版本发布之前,都要进行各种单元测试.参数测试.模糊测试, ...

  6. WireGuard 中文教程:使用 Netmaker 快速组建 WireGuard 全互联 (Full Mesh) 网络

    公众号关注 「奇妙的 Linux 世界」 设为「星标」,每天带你玩转 Linux ! 每日言论 创业者要做两件事:第一件是弄清楚要做什么,第二件就是去做. 但是,大多数创业者不认为第一件事很重要,如果 ...

  7. WireGuard Easy 安装使用

    一.简介 Wireguard Easy WireGuard Easy 特性: 多合一:WireGuard(基于宿主机内核) + Web UI 安装方便,使用简单 列出,创建,编辑,删除,启用和禁用客户 ...

  8. 通过WireGuard搭建隧道实现内网穿透

    1.安装wireguard 官方安装手册:https://www.wireguard.com/install/ docker安装:https://hub.docker.com/r/linuxserve ...

  9. Wireguard各主流平台的配置教程

    Wireguard是一个轻量级的虚拟专用网络 (VPN),支持 IPv4 和 IPv6 连接.VPN允许您遍历不受信任的网络,就像在专用网络上一样.当连接到不受信任的网络(如酒店或咖啡店的WiFi)时 ...

最新文章

  1. Java ArrayList 为什么要实现 RandomAccess 接口?
  2. 几种常用范数与距离的关系
  3. 请教SQL对日期格式化的写法
  4. Mybatis—代理开发和核心配置文件深入
  5. 同一个项目相互调接口_408计算机网络D3-第二章:网络体系结构与参考模型(上)分层结构-协议-接口-服务...
  6. oracle读取表空间物理文件中数据,shell脚本读取oracle数据库数据写入到文件中
  7. rpm安装mysql5.7.16_【CentOS 6.6 RPM方式安装MySQL 5.7.16 】
  8. 【英语学习】【Level 08】U02 Movie Time L2 In black and white
  9. loj136 (最小瓶颈路,多次询问)
  10. 开发机至少要有16G内存
  11. 理解Python中的装饰器
  12. Springboot的Mybatis拦截器实现
  13. spss之数据处理(离散化)
  14. 数据仓库之-历史数据存储方案
  15. 仿淘宝头像上传功能(一)——前端篇。
  16. 京东商品图片 自动下载 抓取 c# 爬虫
  17. Storm示例剖析-fastWordCount
  18. uniapp拨打电话
  19. 相控阵天线(十二):天线校准技术仿真介绍之旋转矢量法
  20. 2017百度之星程序设计大赛 - 初赛(A)今夕何夕

热门文章

  1. 免费的自媒体辅助软件,辅助自媒体内容创作
  2. JAVA架构师之路十五:设计模式之策略模式
  3. scpi编程实例 c语言,基于C#的可编程仪器标准命令(SCPI)实践 (附源代码)
  4. 嵌入式软件设计第8次实验报告
  5. 招聘技术岗-北京、武汉
  6. 征集 |《新程序员》专访Python之父,你最想问什么?
  7. 【通信】【1】幅度调制,频率调制,双边带与单边带,IQ与PSK与QAM——采样一定要满足奈奎斯特定理吗
  8. 光纤中的多种光学模式芯径_光纤视频收发产品的光模块选型
  9. Proxmox支持虚拟机和容器的虚拟化平台
  10. New Bing乘上ChatGPT的东风,日活突破1亿