本文仅做技术记录分享
选Ubuntu22,docker官方安装脚本支持,试了用podman,能连上访问不了公网
https://github.com/hwdsl2/docker-ipsec-vpn-server

安装docker

wget -qO- get.docker.com | bash

外网1

docker run \
--name tt0 \
--restart=always \
-v ikev2-vpn-data0:/etc/ipsec.d \
-v /lib/modules:/lib/modules:ro \
-p 172.16.48.13:500:500/udp \
-p 172.16.48.13:4500:4500/udp \
-d --privileged \
hwdsl2/ipsec-vpn-server

查看容器ip

docker inspect tt0 | grep IPAddress

修改iptables

iptables -t nat -I POSTROUTING -s 172.17.0.2 ! -o docker0 -j SNAT --to 172.16.48.13

iptables -t nat -I POSTROUTING -s $容器ip ! -o docker0 -j SNAT --to $外网1 IP

外网2

docker run \
--name tt1 \
--restart=always \
-v ikev2-vpn-data1:/etc/ipsec.d \
-v /lib/modules:/lib/modules:ro \
-p 172.16.48.8:500:500/udp \
-p 172.16.48.8:4500:4500/udp \
-d --privileged \
hwdsl2/ipsec-vpn-server

查看容器ip

docker inspect tt1 | grep IPAddress

修改iptables

iptables -t nat -I POSTROUTING -s 172.17.0.3 ! -o docker0 -j SNAT --to 172.16.48.8