2021-03-29 23:05:45 +03:00
|
|
|
#
|
|
|
|
# Copyright (C) 2020-2021 Lin Song <linsongui@gmail.com>
|
|
|
|
#
|
|
|
|
# This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
|
|
|
|
# Unported License: http://creativecommons.org/licenses/by-sa/3.0/
|
|
|
|
#
|
|
|
|
# Attribution required: please include my name in any derivative and let me
|
|
|
|
# know how you have improved it!
|
|
|
|
|
2020-07-07 09:25:07 +03:00
|
|
|
name: vpn test
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [master]
|
|
|
|
paths:
|
|
|
|
- '**.sh'
|
|
|
|
- '.github/workflows/main.yml'
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
shellcheck:
|
2020-11-18 07:32:08 +03:00
|
|
|
runs-on: ubuntu-20.04
|
2021-03-10 08:26:06 +03:00
|
|
|
if: github.repository_owner == 'hwdsl2'
|
2020-07-07 09:25:07 +03:00
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
persist-credentials: false
|
|
|
|
- name: Check
|
|
|
|
run: |
|
2020-07-09 09:41:52 +03:00
|
|
|
if [ ! -x /usr/bin/shellcheck ]; then
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
2021-08-03 08:49:11 +03:00
|
|
|
sudo apt-get -yqq update
|
|
|
|
sudo apt-get -yqq install shellcheck
|
2020-07-09 09:41:52 +03:00
|
|
|
fi
|
2020-07-07 09:25:07 +03:00
|
|
|
|
|
|
|
cd "$GITHUB_WORKSPACE"
|
|
|
|
pwd
|
2020-07-09 09:41:52 +03:00
|
|
|
ls -ld vpnsetup.sh
|
|
|
|
|
2021-07-25 00:29:10 +03:00
|
|
|
export SHELLCHECK_OPTS="-e SC1090,SC1091,SC1117"
|
2020-07-07 09:25:07 +03:00
|
|
|
shellcheck --version
|
2020-07-09 09:41:52 +03:00
|
|
|
shopt -s globstar
|
|
|
|
ls -ld -- **/*.sh
|
|
|
|
shellcheck **/*.sh
|
2020-07-07 09:25:07 +03:00
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
check_urls:
|
|
|
|
needs: shellcheck
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
if: github.repository_owner == 'hwdsl2'
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
persist-credentials: false
|
|
|
|
- name: Check
|
|
|
|
run: |
|
|
|
|
cd "$GITHUB_WORKSPACE"
|
|
|
|
mkdir workdir
|
|
|
|
cd workdir
|
2021-08-10 11:43:12 +03:00
|
|
|
set -ex
|
2021-06-04 06:09:56 +03:00
|
|
|
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
2021-08-03 08:49:11 +03:00
|
|
|
sudo apt-get -yqq update
|
|
|
|
sudo apt-get -yqq install wget curl
|
2021-06-04 06:09:56 +03:00
|
|
|
|
|
|
|
wget_c="wget -t 3 -T 30 -nv -O"
|
|
|
|
gh_url="https://github.com/hwdsl2/setup-ipsec-vpn/raw/master"
|
|
|
|
|
|
|
|
$wget_c vpnsetup.sh https://git.io/vpnsetup
|
|
|
|
$wget_c vpnsetup_centos.sh https://git.io/vpnsetup-centos
|
|
|
|
$wget_c vpnsetup_amzn.sh https://git.io/vpnsetup-amzn
|
2021-08-14 09:30:40 +03:00
|
|
|
$wget_c vpnsetup_ubuntu.sh https://git.io/vpnsetup-ubuntu
|
2021-09-14 17:44:06 +03:00
|
|
|
$wget_c vpnsetup_alpine.sh https://git.io/vpnsetup-alpine
|
2021-08-10 11:43:12 +03:00
|
|
|
$wget_c quickstart.sh https://git.io/vpnquickstart
|
2021-06-04 06:09:56 +03:00
|
|
|
$wget_c ikev2setup.sh https://git.io/ikev2setup
|
|
|
|
$wget_c vpnupgrade.sh https://git.io/vpnupgrade
|
|
|
|
$wget_c vpnupgrade_centos.sh https://git.io/vpnupgrade-centos
|
|
|
|
$wget_c vpnupgrade_amzn.sh https://git.io/vpnupgrade-amzn
|
2021-08-14 09:30:40 +03:00
|
|
|
$wget_c vpnupgrade_ubuntu.sh https://git.io/vpnupgrade-ubuntu
|
2021-09-14 17:44:06 +03:00
|
|
|
$wget_c vpnupgrade_alpine.sh https://git.io/vpnupgrade-alpine
|
2021-06-04 06:09:56 +03:00
|
|
|
|
|
|
|
$wget_c vpnsetup2.sh "$gh_url/vpnsetup.sh"
|
|
|
|
$wget_c vpnsetup_centos2.sh "$gh_url/vpnsetup_centos.sh"
|
|
|
|
$wget_c vpnsetup_amzn2.sh "$gh_url/vpnsetup_amzn.sh"
|
2021-08-14 09:30:40 +03:00
|
|
|
$wget_c vpnsetup_ubuntu2.sh "$gh_url/vpnsetup_ubuntu.sh"
|
2021-09-14 17:44:06 +03:00
|
|
|
$wget_c vpnsetup_alpine2.sh "$gh_url/vpnsetup_alpine.sh"
|
2021-08-10 11:43:12 +03:00
|
|
|
$wget_c quickstart2.sh "$gh_url/extras/quickstart.sh"
|
2021-06-04 06:09:56 +03:00
|
|
|
$wget_c ikev2setup2.sh "$gh_url/extras/ikev2setup.sh"
|
|
|
|
$wget_c vpnupgrade2.sh "$gh_url/extras/vpnupgrade.sh"
|
|
|
|
$wget_c vpnupgrade_centos2.sh "$gh_url/extras/vpnupgrade_centos.sh"
|
|
|
|
$wget_c vpnupgrade_amzn2.sh "$gh_url/extras/vpnupgrade_amzn.sh"
|
2021-08-14 09:30:40 +03:00
|
|
|
$wget_c vpnupgrade_ubuntu2.sh "$gh_url/extras/vpnupgrade_ubuntu.sh"
|
2021-09-14 17:44:06 +03:00
|
|
|
$wget_c vpnupgrade_alpine2.sh "$gh_url/extras/vpnupgrade_alpine.sh"
|
2021-06-04 06:09:56 +03:00
|
|
|
|
|
|
|
curl -fsSI https://bit.ly/addvpnuser | grep -q 'add_vpn_user.sh'
|
|
|
|
curl -fsSI https://bit.ly/delvpnuser | grep -q 'del_vpn_user.sh'
|
|
|
|
curl -fsSI https://bit.ly/updatevpnusers | grep -q 'update_vpn_users.sh'
|
|
|
|
|
|
|
|
diff vpnsetup.sh ../vpnsetup.sh
|
|
|
|
diff vpnsetup_centos.sh ../vpnsetup_centos.sh
|
|
|
|
diff vpnsetup_amzn.sh ../vpnsetup_amzn.sh
|
2021-08-14 09:30:40 +03:00
|
|
|
diff vpnsetup_ubuntu.sh ../vpnsetup_ubuntu.sh
|
2021-09-14 17:44:06 +03:00
|
|
|
diff vpnsetup_alpine.sh ../vpnsetup_alpine.sh
|
2021-08-10 11:43:12 +03:00
|
|
|
diff quickstart.sh ../extras/quickstart.sh
|
2021-06-04 06:09:56 +03:00
|
|
|
diff ikev2setup.sh ../extras/ikev2setup.sh
|
|
|
|
diff vpnupgrade.sh ../extras/vpnupgrade.sh
|
|
|
|
diff vpnupgrade_centos.sh ../extras/vpnupgrade_centos.sh
|
|
|
|
diff vpnupgrade_amzn.sh ../extras/vpnupgrade_amzn.sh
|
2021-08-14 09:30:40 +03:00
|
|
|
diff vpnupgrade_ubuntu.sh ../extras/vpnupgrade_ubuntu.sh
|
2021-09-14 17:44:06 +03:00
|
|
|
diff vpnupgrade_alpine.sh ../extras/vpnupgrade_alpine.sh
|
2021-06-04 06:09:56 +03:00
|
|
|
|
|
|
|
diff vpnsetup2.sh ../vpnsetup.sh
|
|
|
|
diff vpnsetup_centos2.sh ../vpnsetup_centos.sh
|
|
|
|
diff vpnsetup_amzn2.sh ../vpnsetup_amzn.sh
|
2021-08-14 09:30:40 +03:00
|
|
|
diff vpnsetup_ubuntu2.sh ../vpnsetup_ubuntu.sh
|
2021-09-14 17:44:06 +03:00
|
|
|
diff vpnsetup_alpine2.sh ../vpnsetup_alpine.sh
|
2021-08-10 11:43:12 +03:00
|
|
|
diff quickstart2.sh ../extras/quickstart.sh
|
2021-06-04 06:09:56 +03:00
|
|
|
diff ikev2setup2.sh ../extras/ikev2setup.sh
|
|
|
|
diff vpnupgrade2.sh ../extras/vpnupgrade.sh
|
|
|
|
diff vpnupgrade_centos2.sh ../extras/vpnupgrade_centos.sh
|
|
|
|
diff vpnupgrade_amzn2.sh ../extras/vpnupgrade_amzn.sh
|
2021-08-14 09:30:40 +03:00
|
|
|
diff vpnupgrade_ubuntu2.sh ../extras/vpnupgrade_ubuntu.sh
|
2021-09-14 17:44:06 +03:00
|
|
|
diff vpnupgrade_alpine2.sh ../extras/vpnupgrade_alpine.sh
|
2021-06-04 06:09:56 +03:00
|
|
|
|
2020-07-07 09:25:07 +03:00
|
|
|
test_set_1:
|
2021-06-04 06:09:56 +03:00
|
|
|
needs: [shellcheck, check_urls]
|
2020-11-18 07:32:08 +03:00
|
|
|
runs-on: ubuntu-20.04
|
2020-07-07 09:25:07 +03:00
|
|
|
if: github.repository_owner == 'hwdsl2'
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-08-03 08:49:11 +03:00
|
|
|
os_version: ["centos:8", "centos:8s", "centos:7", "rockylinux:8", "almalinux:8", "amazonlinux:2"]
|
2020-07-07 09:25:07 +03:00
|
|
|
fail-fast: false
|
|
|
|
env:
|
|
|
|
OS_VERSION: ${{ matrix.os_version }}
|
|
|
|
steps:
|
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
mkdir -p "$GITHUB_WORKSPACE/testing/${OS_VERSION//:}"
|
|
|
|
cd "$GITHUB_WORKSPACE/testing/${OS_VERSION//:}"
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2020-07-07 09:25:07 +03:00
|
|
|
cat > run.sh <<'EOF'
|
|
|
|
#!/bin/bash
|
2021-08-07 10:15:11 +03:00
|
|
|
set -eEx
|
2020-07-07 09:25:07 +03:00
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
log1=/var/log/secure
|
|
|
|
log2=/var/log/messages
|
|
|
|
|
2020-07-12 00:48:12 +03:00
|
|
|
trap 'catch $? $LINENO' ERR
|
|
|
|
|
|
|
|
catch() {
|
|
|
|
echo "Error $1 occurred on line $2."
|
|
|
|
cat -n -- "$0" | tail -n+"$(($2 - 3))" | head -n7
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
restart_ipsec() {
|
2021-08-07 10:15:11 +03:00
|
|
|
if ! command -v amazon-linux-extras; then
|
|
|
|
systemctl restart ipsec
|
|
|
|
fi
|
2021-06-04 06:09:56 +03:00
|
|
|
echo "Waiting for IPsec to restart."
|
|
|
|
count=0
|
2021-06-13 06:34:34 +03:00
|
|
|
while ! grep -q "pluto\[$(cat /var/run/pluto/pluto.pid)\]: listening for IKE messages" "$log1"; do
|
2021-06-04 06:09:56 +03:00
|
|
|
[ "$count" -ge "30" ] && { echo "IPsec failed to start."; exit 1; }
|
|
|
|
count=$((count+1))
|
|
|
|
printf '%s' '.'
|
|
|
|
sleep 0.5
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
}
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
restart_fail2ban() {
|
|
|
|
rm -f /var/log/fail2ban.log
|
2020-07-12 00:48:12 +03:00
|
|
|
systemctl restart fail2ban
|
2021-06-04 06:09:56 +03:00
|
|
|
echo "Waiting for Fail2ban to restart."
|
|
|
|
count=0
|
|
|
|
while ! grep -qs -E "Jail '(sshd?|ssh-iptables)' started" /var/log/fail2ban.log; do
|
|
|
|
[ "$count" -ge "30" ] && { echo "Fail2ban failed to start."; exit 1; }
|
|
|
|
count=$((count+1))
|
|
|
|
printf '%s' '.'
|
|
|
|
sleep 0.5
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
2021-08-03 08:49:11 +03:00
|
|
|
yum -y -q update
|
2021-06-04 06:09:56 +03:00
|
|
|
yum -y -q install wget rsyslog
|
|
|
|
systemctl start rsyslog
|
|
|
|
|
2021-09-14 17:44:06 +03:00
|
|
|
wget -t 3 -T 30 -nv -O vpnsetup.sh https://git.io/vpnsetup
|
|
|
|
sed -i '/curl /a sed -i "/swan_ver_latest=/s/^/#/" "$tmpdir/vpn.sh"' vpnsetup.sh
|
2021-06-04 06:09:56 +03:00
|
|
|
|
|
|
|
sh vpnsetup.sh
|
|
|
|
|
|
|
|
systemctl start xl2tpd
|
|
|
|
restart_ipsec
|
|
|
|
restart_fail2ban
|
|
|
|
cat /var/log/fail2ban.log
|
2020-07-09 09:41:52 +03:00
|
|
|
|
|
|
|
netstat -anpu | grep pluto
|
|
|
|
netstat -anpu | grep xl2tpd
|
2021-06-20 23:22:32 +03:00
|
|
|
iptables -nvL
|
|
|
|
iptables -nvL | grep -q 'ppp+'
|
|
|
|
iptables -nvL | grep -q '192\.168\.43\.0/24'
|
|
|
|
iptables -nvL -t nat
|
|
|
|
iptables -nvL -t nat | grep -q '192\.168\.42\.0/24'
|
|
|
|
iptables -nvL -t nat | grep -q '192\.168\.43\.0/24'
|
2021-06-04 06:09:56 +03:00
|
|
|
grep pluto "$log1"
|
|
|
|
grep xl2tpd "$log2"
|
2020-12-28 09:45:59 +03:00
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
2021-01-29 19:04:09 +03:00
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
ls -l /usr/bin/ikev2.sh
|
|
|
|
ls -l /opt/src/ikev2.sh
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-09-14 17:44:06 +03:00
|
|
|
wget -t 3 -T 30 -nv -O vpnunst.sh https://git.io/vpnuninstall
|
|
|
|
bash vpnunst.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
if grep -qi stream /etc/redhat-release; then
|
|
|
|
mkdir /etc/xl2tpd
|
|
|
|
fi
|
|
|
|
|
|
|
|
wget -t 3 -T 30 -nv -O quickstart.sh https://git.io/vpnquickstart
|
|
|
|
sed -i -e '/curl /a sed -i "/swan_ver_latest=/s/^/#/" "$tmpdir/vpn.sh"' \
|
|
|
|
-e '/sleep 1/a sed -i "/swan_ver_latest=/s/^/#/" /opt/src/ikev2.sh' quickstart.sh
|
|
|
|
|
|
|
|
sh quickstart.sh
|
|
|
|
|
|
|
|
systemctl restart xl2tpd
|
|
|
|
restart_ipsec
|
|
|
|
restart_fail2ban
|
|
|
|
cat /var/log/fail2ban.log
|
|
|
|
|
|
|
|
netstat -anpu | grep pluto
|
|
|
|
netstat -anpu | grep xl2tpd
|
|
|
|
iptables -nvL
|
|
|
|
iptables -nvL | grep -q 'ppp+'
|
|
|
|
iptables -nvL | grep -q '192\.168\.43\.0/24'
|
|
|
|
iptables -nvL -t nat
|
|
|
|
iptables -nvL -t nat | grep -q '192\.168\.42\.0/24'
|
|
|
|
iptables -nvL -t nat | grep -q '192\.168\.43\.0/24'
|
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.p12
|
|
|
|
|
|
|
|
ls -l /usr/bin/ikev2.sh
|
|
|
|
ls -l /opt/src/ikev2.sh
|
|
|
|
|
|
|
|
bash vpnunst.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
if grep -qi stream /etc/redhat-release; then
|
|
|
|
mkdir /etc/xl2tpd
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" != "amazon" ]; then
|
|
|
|
wget -t 3 -T 30 -nv -O vpnsetup.sh https://git.io/vpnsetup-centos
|
|
|
|
else
|
|
|
|
wget -t 3 -T 30 -nv -O vpnsetup.sh https://git.io/vpnsetup-amzn
|
|
|
|
fi
|
|
|
|
sed -i '/swan_ver_latest=/s/^/#/' vpnsetup.sh
|
|
|
|
|
2020-07-09 09:41:52 +03:00
|
|
|
VPN_IPSEC_PSK='your_ipsec_pre_shared_key' \
|
|
|
|
VPN_USER='your_vpn_username' \
|
|
|
|
VPN_PASSWORD='your_vpn_password' \
|
2021-02-21 00:51:40 +03:00
|
|
|
VPN_DNS_SRV1='1.1.1.1' \
|
|
|
|
VPN_DNS_SRV2='1.0.0.1' \
|
2021-08-20 07:00:57 +03:00
|
|
|
bash vpnsetup.sh
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
restart_ipsec
|
2021-02-21 00:51:40 +03:00
|
|
|
grep -q "your_ipsec_pre_shared_key" /etc/ipsec.secrets
|
|
|
|
grep -q "your_vpn_username" /etc/ppp/chap-secrets
|
|
|
|
grep -q "your_vpn_password" /etc/ppp/chap-secrets
|
|
|
|
grep -q "your_vpn_username" /etc/ipsec.d/passwd
|
|
|
|
grep -q 'modecfgdns="1.1.1.1 1.0.0.1"' /etc/ipsec.conf
|
|
|
|
grep -q 'ms-dns 1.1.1.1' /etc/ppp/options.xl2tpd
|
|
|
|
grep -q 'ms-dns 1.0.0.1' /etc/ppp/options.xl2tpd
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
wget -t 3 -T 30 -nv -O ikev2.sh https://git.io/ikev2setup # hwdsl2
|
2021-01-18 09:01:46 +03:00
|
|
|
sed -i '/swan_ver_latest=/s/^/#/' ikev2.sh
|
2021-06-04 06:09:56 +03:00
|
|
|
|
2020-07-07 09:25:07 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
2020-07-09 09:41:52 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-07 09:25:07 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
grep -q 'modecfgdns="8.8.8.8 8.8.4.4"' /etc/ipsec.d/ikev2.conf
|
2021-02-21 00:51:40 +03:00
|
|
|
ls -ld /etc/ipsec.d/vpnclient.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.p12
|
2021-06-04 06:09:56 +03:00
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
grep pluto "$log1" | tail -n 20
|
2020-12-28 09:45:59 +03:00
|
|
|
ipsec status | grep -q ikev2-cp
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2020-07-07 09:25:07 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
2021-01-19 07:01:39 +03:00
|
|
|
1
|
2021-08-06 09:50:09 +03:00
|
|
|
invalidclient:
|
|
|
|
vpnclient
|
2020-07-07 09:25:07 +03:00
|
|
|
vpnclient2
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-01-19 07:01:39 +03:00
|
|
|
ANSWERS
|
|
|
|
|
2021-02-21 00:51:40 +03:00
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.p12
|
2021-01-19 07:01:39 +03:00
|
|
|
|
2021-02-04 06:49:40 +03:00
|
|
|
rm -f /etc/ipsec.d/vpnclient2*
|
2021-01-19 07:01:39 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
2
|
2021-08-06 09:50:09 +03:00
|
|
|
nonexistclient
|
2021-01-19 07:01:39 +03:00
|
|
|
vpnclient2
|
2020-07-07 09:25:07 +03:00
|
|
|
ANSWERS
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-02-21 00:51:40 +03:00
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.p12
|
2020-08-10 02:14:56 +03:00
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
3
|
|
|
|
ANSWERS
|
|
|
|
|
2021-01-29 19:04:09 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
2021-02-02 07:38:53 +03:00
|
|
|
4
|
2021-08-06 09:50:09 +03:00
|
|
|
nonexistclient
|
2021-06-01 10:43:44 +03:00
|
|
|
vpnclient2
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
bash ikev2.sh <<ANSWERS 2>&1 | grep -i "abort"
|
|
|
|
4
|
|
|
|
vpnclient2
|
|
|
|
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
bash ikev2.sh <<ANSWERS 2>&1 | grep -i "abort"
|
|
|
|
2
|
|
|
|
vpnclient2
|
|
|
|
|
|
|
|
ANSWERS
|
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
2021-08-06 09:50:09 +03:00
|
|
|
100
|
2021-06-04 06:09:56 +03:00
|
|
|
6
|
|
|
|
ANSWERS
|
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
bash ikev2.sh <<ANSWERS 2>&1 | grep -i "abort"
|
|
|
|
5
|
|
|
|
|
|
|
|
ANSWERS
|
|
|
|
|
2021-06-01 10:43:44 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
5
|
2021-01-29 19:04:09 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
restart_ipsec
|
2021-02-21 00:51:40 +03:00
|
|
|
ls -ld /etc/ipsec.d/ikev2.conf && exit 1
|
2021-01-29 19:04:09 +03:00
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
2021-02-21 00:51:40 +03:00
|
|
|
ipsec status | grep -q ikev2-cp && exit 1
|
2021-01-29 19:04:09 +03:00
|
|
|
certutil -L -d sql:/etc/ipsec.d
|
|
|
|
|
|
|
|
rm -f /etc/ipsec.d/vpnclient*
|
2021-04-11 00:25:22 +03:00
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
VPN_DNS_SRV1=invaliddns \
|
|
|
|
bash ikev2.sh --auto 2>&1 | grep -i "invalid"
|
|
|
|
|
|
|
|
sed -i '/^include /d' /etc/ipsec.conf
|
|
|
|
|
2021-04-11 00:25:22 +03:00
|
|
|
VPN_CLIENT_NAME=vpnclient1 \
|
|
|
|
VPN_DNS_NAME=vpn.example.com \
|
|
|
|
VPN_DNS_SRV1=1.1.1.1 \
|
|
|
|
VPN_DNS_SRV2=1.0.0.1 \
|
|
|
|
bash ikev2.sh --auto
|
2021-02-21 00:51:40 +03:00
|
|
|
|
|
|
|
grep -q 'leftid=@vpn.example.com' /etc/ipsec.d/ikev2.conf
|
|
|
|
grep -q 'modecfgdns="1.1.1.1 1.0.0.1"' /etc/ipsec.d/ikev2.conf
|
2021-04-11 00:25:22 +03:00
|
|
|
ls -ld /etc/ipsec.d/vpnclient1.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient1.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient1.p12
|
|
|
|
grep -q 'vpn.example.com' /etc/ipsec.d/vpnclient1.mobileconfig
|
|
|
|
grep -q 'vpn.example.com' /etc/ipsec.d/vpnclient1.sswan
|
2021-06-04 06:09:56 +03:00
|
|
|
|
|
|
|
restart_ipsec
|
2021-01-29 19:04:09 +03:00
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
bash ikev2.sh --auto --addclient invalidclient: 2>&1 | grep -i "warning"
|
|
|
|
bash ikev2.sh --addclient invalidclient: 2>&1 | grep -i "invalid"
|
|
|
|
bash ikev2.sh --addclient vpnclient1 2>&1 | grep -i "already exists"
|
|
|
|
|
2021-01-29 19:04:09 +03:00
|
|
|
bash ikev2.sh --addclient vpnclient2
|
|
|
|
|
2021-02-21 00:51:40 +03:00
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.p12
|
2021-01-29 19:04:09 +03:00
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
bash ikev2.sh --exportclient nonexistclient 2>&1 | grep -i "does not exist"
|
|
|
|
|
2021-02-04 06:49:40 +03:00
|
|
|
rm -f /etc/ipsec.d/vpnclient2*
|
2021-01-29 19:04:09 +03:00
|
|
|
bash ikev2.sh --exportclient vpnclient2
|
|
|
|
|
2021-02-21 00:51:40 +03:00
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.p12
|
2021-01-29 19:04:09 +03:00
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
bash ikev2.sh --addclient vpnclient2 --exportclient vpnclient2 2>&1 | grep -i "invalid"
|
|
|
|
|
|
|
|
bash ikev2.sh --listclients | grep "vpnclient1"
|
|
|
|
bash ikev2.sh --listclients | grep "vpnclient2"
|
2021-02-04 10:47:04 +03:00
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
bash ikev2.sh --revokeclient nonexistclient 2>&1 | grep -i "does not exist"
|
2021-06-04 06:09:56 +03:00
|
|
|
bash ikev2.sh --revokeclient vpnclient2 <<ANSWERS
|
2021-04-25 00:16:44 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
bash ikev2.sh --revokeclient vpnclient2 2>&1 | grep -i "already been revoked"
|
|
|
|
bash ikev2.sh --exportclient vpnclient2 2>&1 | grep -i "revoked"
|
|
|
|
bash ikev2.sh -h 2>&1 | grep -i "usage:"
|
|
|
|
bash ikev2.sh --invalidoption 2>&1 | grep -i "usage:"
|
|
|
|
|
|
|
|
bash ikev2.sh --removeikev2 --exportclient vpnclient1 2>&1 | grep -i "invalid"
|
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
invalidfqdn
|
|
|
|
vpn.example.com
|
|
|
|
|
|
|
|
|
|
|
|
y
|
|
|
|
invaliddns
|
|
|
|
1.1.1.1
|
|
|
|
invaliddns
|
|
|
|
1.0.0.1
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
grep -q 'leftid=@vpn.example.com' /etc/ipsec.d/ikev2.conf
|
|
|
|
grep -q 'modecfgdns="1.1.1.1 1.0.0.1"' /etc/ipsec.d/ikev2.conf
|
|
|
|
restart_ipsec
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
|
|
|
|
invalidip
|
|
|
|
1.2.3.4
|
|
|
|
invalidclient:
|
|
|
|
vpnclient1
|
|
|
|
1000
|
|
|
|
12
|
|
|
|
y
|
|
|
|
1.1.1.1
|
|
|
|
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
grep -q 'leftid=1.2.3.4' /etc/ipsec.d/ikev2.conf
|
|
|
|
grep -q 'modecfgdns=1.1.1.1' /etc/ipsec.d/ikev2.conf
|
|
|
|
restart_ipsec
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
VPN_DNS_SRV1=1.1.1.1 \
|
|
|
|
bash ikev2.sh --auto
|
|
|
|
|
|
|
|
grep -q 'modecfgdns=1.1.1.1' /etc/ipsec.d/ikev2.conf
|
|
|
|
restart_ipsec
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
bash ikev2.sh --auto
|
|
|
|
|
|
|
|
grep -q 'modecfgdns="8.8.8.8 8.8.4.4"' /etc/ipsec.d/ikev2.conf
|
|
|
|
restart_ipsec
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
2021-09-14 17:44:06 +03:00
|
|
|
wget -t 3 -T 30 -nv -O vpnup.sh https://git.io/vpnupgrade
|
|
|
|
sed -i '/curl /a sed -i "/swan_ver_latest=/s/^/#/" "$tmpdir/vpnup.sh"' vpnup.sh
|
|
|
|
|
|
|
|
for ver in 3.32 4.1 4.2; do
|
|
|
|
sed -i "s/^SWAN_VER=.*/SWAN_VER=$ver/" vpnup.sh
|
|
|
|
bash vpnup.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
restart_ipsec
|
|
|
|
ipsec --version | grep "$ver"
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
done
|
|
|
|
|
2021-08-03 08:49:11 +03:00
|
|
|
if [ "$1" != "amazon" ]; then
|
2021-06-04 06:09:56 +03:00
|
|
|
wget -t 3 -T 30 -nv -O vpnup.sh https://git.io/vpnupgrade-centos
|
2021-04-25 00:16:44 +03:00
|
|
|
else
|
2021-06-04 06:09:56 +03:00
|
|
|
wget -t 3 -T 30 -nv -O vpnup.sh https://git.io/vpnupgrade-amzn
|
2021-04-25 00:16:44 +03:00
|
|
|
fi
|
2021-06-04 06:09:56 +03:00
|
|
|
sed -i '/swan_ver_latest=/s/^/#/' vpnup.sh
|
2021-04-25 00:16:44 +03:00
|
|
|
|
2021-09-14 17:44:06 +03:00
|
|
|
for ver in 4.3 4.4 4.5; do
|
2021-08-20 07:00:57 +03:00
|
|
|
[ "$ver" = "4.3" ] && shc=sh || shc=bash
|
2021-06-04 06:09:56 +03:00
|
|
|
sed -i "s/^SWAN_VER=.*/SWAN_VER=$ver/" vpnup.sh
|
2021-08-20 07:00:57 +03:00
|
|
|
"$shc" vpnup.sh <<ANSWERS
|
2021-02-22 08:54:37 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
2021-06-04 06:09:56 +03:00
|
|
|
restart_ipsec
|
2021-08-20 07:00:57 +03:00
|
|
|
ipsec --version | grep "$ver"
|
2021-06-04 06:09:56 +03:00
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
done
|
2021-02-22 08:54:37 +03:00
|
|
|
|
2021-01-29 19:04:09 +03:00
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
2021-01-19 10:05:48 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
restart_ipsec
|
2021-02-21 00:51:40 +03:00
|
|
|
ls -ld /etc/ipsec.d/ikev2.conf && exit 1
|
2021-01-19 10:05:48 +03:00
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
2021-02-21 00:51:40 +03:00
|
|
|
ipsec status | grep -q ikev2-cp && exit 1
|
2021-01-19 10:05:48 +03:00
|
|
|
certutil -L -d sql:/etc/ipsec.d
|
|
|
|
|
2020-07-09 09:41:52 +03:00
|
|
|
ls -ld vpnsetup.sh
|
|
|
|
ls -ld ikev2.sh
|
2021-04-25 00:16:44 +03:00
|
|
|
ls -ld vpnup.sh
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2020-07-07 09:25:07 +03:00
|
|
|
exit 0
|
|
|
|
EOF
|
|
|
|
|
2021-04-26 08:08:16 +03:00
|
|
|
if [ "$OS_VERSION" = "centos:8s" ]; then
|
|
|
|
echo "FROM quay.io/centos/centos:stream8" > Dockerfile
|
2021-08-03 08:49:11 +03:00
|
|
|
elif [ "$OS_VERSION" = "rockylinux:8" ]; then
|
|
|
|
echo "FROM rockylinux/rockylinux:8" > Dockerfile
|
2021-04-26 08:08:16 +03:00
|
|
|
else
|
|
|
|
echo "FROM $OS_VERSION" > Dockerfile
|
|
|
|
fi
|
2020-07-07 09:25:07 +03:00
|
|
|
|
|
|
|
cat >> Dockerfile <<'EOF'
|
|
|
|
|
|
|
|
ENV container docker
|
|
|
|
WORKDIR /opt/src
|
|
|
|
|
2020-12-28 09:45:59 +03:00
|
|
|
RUN if command -v amazon-linux-extras; then amazon-linux-extras install -y kernel-ng; fi
|
|
|
|
|
2020-07-07 09:25:07 +03:00
|
|
|
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ "$i" = \
|
|
|
|
systemd-tmpfiles-setup.service ] || rm -f "$i"; done); \
|
|
|
|
rm -f /lib/systemd/system/multi-user.target.wants/*; \
|
|
|
|
rm -f /etc/systemd/system/*.wants/*; \
|
|
|
|
rm -f /lib/systemd/system/local-fs.target.wants/*; \
|
|
|
|
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
|
|
|
|
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
|
|
|
|
rm -f /lib/systemd/system/basic.target.wants/*; \
|
|
|
|
rm -f /lib/systemd/system/anaconda.target.wants/*;
|
|
|
|
|
|
|
|
COPY ./run.sh /opt/src/run.sh
|
|
|
|
RUN chmod 755 /opt/src/run.sh
|
|
|
|
|
|
|
|
VOLUME [ "/sys/fs/cgroup" ]
|
|
|
|
|
|
|
|
CMD ["/sbin/init"]
|
|
|
|
EOF
|
|
|
|
cat Dockerfile
|
|
|
|
cat run.sh
|
|
|
|
docker build -t "${OS_VERSION//:}-test" .
|
|
|
|
|
|
|
|
- name: Test
|
|
|
|
run: |
|
|
|
|
docker run -d --name "${OS_VERSION//:}-test-1" -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
|
|
|
|
--privileged "${OS_VERSION//:}-test"
|
2021-06-04 06:09:56 +03:00
|
|
|
sleep 5
|
2020-07-07 09:25:07 +03:00
|
|
|
docker exec "${OS_VERSION//:}-test-1" /opt/src/run.sh "${OS_VERSION::6}"
|
|
|
|
|
|
|
|
- name: Clear
|
|
|
|
if: always()
|
|
|
|
run: |
|
|
|
|
rm -rf "$GITHUB_WORKSPACE/testing/${OS_VERSION//:}"
|
|
|
|
docker rm -f "${OS_VERSION//:}-test-1" || true
|
|
|
|
docker rmi "${OS_VERSION//:}-test" || true
|
|
|
|
|
|
|
|
test_set_2:
|
2021-06-04 06:09:56 +03:00
|
|
|
needs: [shellcheck, check_urls]
|
2020-11-18 07:32:08 +03:00
|
|
|
runs-on: ubuntu-20.04
|
2020-07-07 09:25:07 +03:00
|
|
|
if: github.repository_owner == 'hwdsl2'
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2021-09-14 17:44:06 +03:00
|
|
|
os_version: ["ubuntu:20.04", "ubuntu:18.04", "debian:11", "debian:10", "debian:9"]
|
2020-07-07 09:25:07 +03:00
|
|
|
fail-fast: false
|
|
|
|
container:
|
|
|
|
image: ${{ matrix.os_version }}
|
2021-08-03 08:49:11 +03:00
|
|
|
options: --cap-add=NET_ADMIN --device=/dev/ppp
|
2020-07-07 09:25:07 +03:00
|
|
|
steps:
|
|
|
|
- name: Test
|
|
|
|
run: |
|
2021-08-07 10:15:11 +03:00
|
|
|
set -ex
|
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
log1=/var/log/auth.log
|
|
|
|
log2=/var/log/syslog
|
|
|
|
|
|
|
|
restart_ipsec() {
|
|
|
|
echo "Waiting for IPsec to restart."
|
|
|
|
count=0
|
2021-06-13 06:34:34 +03:00
|
|
|
while ! grep -q "pluto\[$(cat /var/run/pluto/pluto.pid)\]: listening for IKE messages" "$log1"; do
|
2021-06-04 06:09:56 +03:00
|
|
|
[ "$count" -ge "30" ] && { echo "IPsec failed to start."; exit 1; }
|
|
|
|
count=$((count+1))
|
|
|
|
printf '%s' '.'
|
|
|
|
sleep 0.5
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
restart_fail2ban() {
|
|
|
|
rm -f /var/log/fail2ban.log
|
|
|
|
service fail2ban restart
|
|
|
|
echo "Waiting for Fail2ban to restart."
|
|
|
|
count=0
|
|
|
|
while ! grep -qs -E "Jail '(sshd?|ssh-iptables)' started" /var/log/fail2ban.log; do
|
|
|
|
[ "$count" -ge "30" ] && { echo "Fail2ban failed to start."; exit 1; }
|
|
|
|
count=$((count+1))
|
|
|
|
printf '%s' '.'
|
|
|
|
sleep 0.5
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
}
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2020-07-07 09:25:07 +03:00
|
|
|
mkdir -p /opt/src
|
|
|
|
cd /opt/src
|
|
|
|
echo "# hwdsl2" > run.sh
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2020-12-03 08:40:54 +03:00
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
2021-08-03 08:49:11 +03:00
|
|
|
apt-get -yqq update
|
|
|
|
apt-get -yqq dist-upgrade
|
|
|
|
apt-get -yqq install wget rsyslog
|
2020-12-03 08:40:54 +03:00
|
|
|
service rsyslog start
|
2021-06-04 06:09:56 +03:00
|
|
|
|
2021-09-14 17:44:06 +03:00
|
|
|
wget -t 3 -T 30 -nv -O vpnsetup.sh https://git.io/vpnsetup
|
|
|
|
sed -i '/curl /a sed -i "/swan_ver_latest=/s/^/#/" "$tmpdir/vpn.sh"' vpnsetup.sh
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2020-07-07 09:25:07 +03:00
|
|
|
sh vpnsetup.sh
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
restart_ipsec
|
|
|
|
restart_fail2ban
|
|
|
|
cat /var/log/fail2ban.log
|
|
|
|
|
2020-07-09 09:41:52 +03:00
|
|
|
netstat -anpu | grep pluto
|
|
|
|
netstat -anpu | grep xl2tpd
|
2021-06-20 23:22:32 +03:00
|
|
|
iptables -nvL
|
|
|
|
iptables -nvL | grep -q 'ppp+'
|
|
|
|
iptables -nvL | grep -q '192\.168\.43\.0/24'
|
|
|
|
iptables -nvL -t nat
|
|
|
|
iptables -nvL -t nat | grep -q '192\.168\.42\.0/24'
|
|
|
|
iptables -nvL -t nat | grep -q '192\.168\.43\.0/24'
|
2021-06-04 06:09:56 +03:00
|
|
|
grep pluto "$log1"
|
|
|
|
grep xl2tpd "$log2"
|
2020-12-28 09:45:59 +03:00
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
2021-01-29 19:04:09 +03:00
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
ls -l /usr/bin/ikev2.sh
|
|
|
|
ls -l /opt/src/ikev2.sh
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-09-14 17:44:06 +03:00
|
|
|
wget -t 3 -T 30 -nv -O vpnunst.sh https://git.io/vpnuninstall
|
|
|
|
bash vpnunst.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
wget -t 3 -T 30 -nv -O quickstart.sh https://git.io/vpnquickstart
|
|
|
|
sed -i -e '/curl /a sed -i "/swan_ver_latest=/s/^/#/" "$tmpdir/vpn.sh"' \
|
|
|
|
-e '/sleep 1/a sed -i "/swan_ver_latest=/s/^/#/" /opt/src/ikev2.sh' quickstart.sh
|
|
|
|
|
|
|
|
sh quickstart.sh
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
restart_fail2ban
|
|
|
|
cat /var/log/fail2ban.log
|
|
|
|
|
|
|
|
netstat -anpu | grep pluto
|
|
|
|
netstat -anpu | grep xl2tpd
|
|
|
|
iptables -nvL
|
|
|
|
iptables -nvL | grep -q 'ppp+'
|
|
|
|
iptables -nvL | grep -q '192\.168\.43\.0/24'
|
|
|
|
iptables -nvL -t nat
|
|
|
|
iptables -nvL -t nat | grep -q '192\.168\.42\.0/24'
|
|
|
|
iptables -nvL -t nat | grep -q '192\.168\.43\.0/24'
|
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.p12
|
|
|
|
|
|
|
|
ls -l /usr/bin/ikev2.sh
|
|
|
|
ls -l /opt/src/ikev2.sh
|
|
|
|
|
|
|
|
bash vpnunst.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
wget -t 3 -T 30 -nv -O vpnsetup.sh https://git.io/vpnsetup-ubuntu
|
|
|
|
sed -i '/swan_ver_latest=/s/^/#/' vpnsetup.sh
|
|
|
|
|
2020-07-09 09:41:52 +03:00
|
|
|
VPN_IPSEC_PSK='your_ipsec_pre_shared_key' \
|
|
|
|
VPN_USER='your_vpn_username' \
|
|
|
|
VPN_PASSWORD='your_vpn_password' \
|
2021-02-21 00:51:40 +03:00
|
|
|
VPN_DNS_SRV1='1.1.1.1' \
|
|
|
|
VPN_DNS_SRV2='1.0.0.1' \
|
2021-08-20 07:00:57 +03:00
|
|
|
bash vpnsetup.sh
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
restart_ipsec
|
2021-02-21 00:51:40 +03:00
|
|
|
grep -q "your_ipsec_pre_shared_key" /etc/ipsec.secrets
|
|
|
|
grep -q "your_vpn_username" /etc/ppp/chap-secrets
|
|
|
|
grep -q "your_vpn_password" /etc/ppp/chap-secrets
|
|
|
|
grep -q "your_vpn_username" /etc/ipsec.d/passwd
|
|
|
|
grep -q 'modecfgdns="1.1.1.1 1.0.0.1"' /etc/ipsec.conf
|
|
|
|
grep -q 'ms-dns 1.1.1.1' /etc/ppp/options.xl2tpd
|
|
|
|
grep -q 'ms-dns 1.0.0.1' /etc/ppp/options.xl2tpd
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
wget -t 3 -T 30 -nv -O ikev2.sh https://git.io/ikev2setup
|
2021-01-18 09:01:46 +03:00
|
|
|
sed -i '/swan_ver_latest=/s/^/#/' ikev2.sh
|
2021-06-04 06:09:56 +03:00
|
|
|
|
2021-01-29 19:04:09 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
y
|
|
|
|
ANSWERS
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
grep -q 'modecfgdns="8.8.8.8 8.8.4.4"' /etc/ipsec.d/ikev2.conf
|
2021-02-21 00:51:40 +03:00
|
|
|
ls -ld /etc/ipsec.d/vpnclient.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.p12
|
2021-06-04 06:09:56 +03:00
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
grep pluto "$log1" | tail -n 20
|
2020-12-28 09:45:59 +03:00
|
|
|
ipsec status | grep -q ikev2-cp
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2020-07-07 09:25:07 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
2021-01-19 07:01:39 +03:00
|
|
|
1
|
2021-08-06 09:50:09 +03:00
|
|
|
invalidclient:
|
|
|
|
vpnclient
|
2020-07-07 09:25:07 +03:00
|
|
|
vpnclient2
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-01-19 07:01:39 +03:00
|
|
|
ANSWERS
|
|
|
|
|
2021-02-21 00:51:40 +03:00
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.p12
|
2021-01-19 07:01:39 +03:00
|
|
|
|
2021-02-04 06:49:40 +03:00
|
|
|
rm -f /etc/ipsec.d/vpnclient2*
|
2021-01-19 07:01:39 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
2
|
2021-08-06 09:50:09 +03:00
|
|
|
nonexistclient
|
2021-01-19 07:01:39 +03:00
|
|
|
vpnclient2
|
2020-07-07 09:25:07 +03:00
|
|
|
ANSWERS
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-02-21 00:51:40 +03:00
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.p12
|
2020-08-10 02:14:56 +03:00
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
3
|
|
|
|
ANSWERS
|
|
|
|
|
2021-01-29 19:04:09 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
2021-02-02 07:38:53 +03:00
|
|
|
4
|
2021-08-06 09:50:09 +03:00
|
|
|
nonexistclient
|
2021-06-01 10:43:44 +03:00
|
|
|
vpnclient2
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
bash ikev2.sh <<ANSWERS 2>&1 | grep -i "abort"
|
|
|
|
4
|
|
|
|
vpnclient2
|
|
|
|
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
bash ikev2.sh <<ANSWERS 2>&1 | grep -i "abort"
|
|
|
|
2
|
|
|
|
vpnclient2
|
|
|
|
|
|
|
|
ANSWERS
|
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
2021-08-06 09:50:09 +03:00
|
|
|
100
|
2021-06-04 06:09:56 +03:00
|
|
|
6
|
|
|
|
ANSWERS
|
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
bash ikev2.sh <<ANSWERS 2>&1 | grep -i "abort"
|
|
|
|
5
|
|
|
|
|
|
|
|
ANSWERS
|
|
|
|
|
2021-06-01 10:43:44 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
5
|
2021-01-29 19:04:09 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
restart_ipsec
|
2021-02-21 00:51:40 +03:00
|
|
|
ls -ld /etc/ipsec.d/ikev2.conf && exit 1
|
2021-01-29 19:04:09 +03:00
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
2021-02-21 00:51:40 +03:00
|
|
|
ipsec status | grep -q ikev2-cp && exit 1
|
2021-01-29 19:04:09 +03:00
|
|
|
certutil -L -d sql:/etc/ipsec.d
|
|
|
|
|
|
|
|
rm -f /etc/ipsec.d/vpnclient*
|
2021-04-11 00:25:22 +03:00
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
VPN_DNS_SRV1=invaliddns \
|
|
|
|
bash ikev2.sh --auto 2>&1 | grep -i "invalid"
|
|
|
|
|
|
|
|
apt-get -yqq remove uuid-runtime
|
|
|
|
sed -i '/^include /d' /etc/ipsec.conf
|
|
|
|
|
2021-04-11 00:25:22 +03:00
|
|
|
VPN_CLIENT_NAME=vpnclient1 \
|
|
|
|
VPN_DNS_NAME=vpn.example.com \
|
|
|
|
VPN_DNS_SRV1=1.1.1.1 \
|
|
|
|
VPN_DNS_SRV2=1.0.0.1 \
|
|
|
|
bash ikev2.sh --auto
|
2021-02-21 00:51:40 +03:00
|
|
|
|
|
|
|
grep -q 'leftid=@vpn.example.com' /etc/ipsec.d/ikev2.conf
|
|
|
|
grep -q 'modecfgdns="1.1.1.1 1.0.0.1"' /etc/ipsec.d/ikev2.conf
|
2021-04-11 00:25:22 +03:00
|
|
|
ls -ld /etc/ipsec.d/vpnclient1.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient1.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient1.p12
|
|
|
|
grep -q 'vpn.example.com' /etc/ipsec.d/vpnclient1.mobileconfig
|
|
|
|
grep -q 'vpn.example.com' /etc/ipsec.d/vpnclient1.sswan
|
2021-06-04 06:09:56 +03:00
|
|
|
|
|
|
|
restart_ipsec
|
2021-01-29 19:04:09 +03:00
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
bash ikev2.sh --auto --addclient invalidclient: 2>&1 | grep -i "warning"
|
|
|
|
bash ikev2.sh --addclient invalidclient: 2>&1 | grep -i "invalid"
|
|
|
|
bash ikev2.sh --addclient vpnclient1 2>&1 | grep -i "already exists"
|
|
|
|
|
2021-01-29 19:04:09 +03:00
|
|
|
bash ikev2.sh --addclient vpnclient2
|
|
|
|
|
2021-02-21 00:51:40 +03:00
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.p12
|
2021-01-29 19:04:09 +03:00
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
bash ikev2.sh --exportclient nonexistclient 2>&1 | grep -i "does not exist"
|
|
|
|
|
2021-02-04 06:49:40 +03:00
|
|
|
rm -f /etc/ipsec.d/vpnclient2*
|
2021-01-29 19:04:09 +03:00
|
|
|
bash ikev2.sh --exportclient vpnclient2
|
|
|
|
|
2021-02-21 00:51:40 +03:00
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.p12
|
2021-01-29 19:04:09 +03:00
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
bash ikev2.sh --addclient vpnclient2 --exportclient vpnclient2 2>&1 | grep -i "invalid"
|
|
|
|
|
|
|
|
bash ikev2.sh --listclients | grep "vpnclient1"
|
|
|
|
bash ikev2.sh --listclients | grep "vpnclient2"
|
2021-06-04 06:09:56 +03:00
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
bash ikev2.sh --revokeclient nonexistclient 2>&1 | grep -i "does not exist"
|
2021-06-01 10:43:44 +03:00
|
|
|
bash ikev2.sh --revokeclient vpnclient2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
2021-08-06 09:50:09 +03:00
|
|
|
bash ikev2.sh --revokeclient vpnclient2 2>&1 | grep -i "already been revoked"
|
|
|
|
bash ikev2.sh --exportclient vpnclient2 2>&1 | grep -i "revoked"
|
|
|
|
bash ikev2.sh -h 2>&1 | grep -i "usage:"
|
|
|
|
bash ikev2.sh --invalidoption 2>&1 | grep -i "usage:"
|
|
|
|
|
|
|
|
bash ikev2.sh --removeikev2 --exportclient vpnclient1 2>&1 | grep -i "invalid"
|
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
invalidfqdn
|
|
|
|
vpn.example.com
|
|
|
|
|
|
|
|
|
|
|
|
y
|
|
|
|
invaliddns
|
|
|
|
1.1.1.1
|
|
|
|
invaliddns
|
|
|
|
1.0.0.1
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
grep -q 'leftid=@vpn.example.com' /etc/ipsec.d/ikev2.conf
|
|
|
|
grep -q 'modecfgdns="1.1.1.1 1.0.0.1"' /etc/ipsec.d/ikev2.conf
|
|
|
|
restart_ipsec
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
|
|
|
|
invalidip
|
|
|
|
1.2.3.4
|
|
|
|
invalidclient:
|
|
|
|
vpnclient1
|
|
|
|
1000
|
|
|
|
12
|
|
|
|
y
|
|
|
|
1.1.1.1
|
|
|
|
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
grep -q 'leftid=1.2.3.4' /etc/ipsec.d/ikev2.conf
|
|
|
|
grep -q 'modecfgdns=1.1.1.1' /etc/ipsec.d/ikev2.conf
|
|
|
|
restart_ipsec
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
VPN_DNS_SRV1=1.1.1.1 \
|
|
|
|
bash ikev2.sh --auto
|
|
|
|
|
|
|
|
grep -q 'modecfgdns=1.1.1.1' /etc/ipsec.d/ikev2.conf
|
|
|
|
restart_ipsec
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
bash ikev2.sh --auto
|
|
|
|
|
|
|
|
grep -q 'modecfgdns="8.8.8.8 8.8.4.4"' /etc/ipsec.d/ikev2.conf
|
|
|
|
restart_ipsec
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
2021-09-14 17:44:06 +03:00
|
|
|
wget -t 3 -T 30 -nv -O vpnup.sh https://git.io/vpnupgrade
|
|
|
|
sed -i '/curl /a sed -i "/swan_ver_latest=/s/^/#/" "$tmpdir/vpnup.sh"' vpnup.sh
|
2021-04-25 00:16:44 +03:00
|
|
|
|
2021-08-15 08:46:50 +03:00
|
|
|
os_ver=$(sed 's/\..*//' /etc/debian_version | tr -dc 'A-Za-z0-9')
|
2021-09-14 17:44:06 +03:00
|
|
|
for ver in 3.32 4.1 4.2; do
|
2021-08-15 08:46:50 +03:00
|
|
|
[ "$ver" = "3.32" ] && [ "$os_ver" = "11" ] && continue
|
2021-09-14 17:44:06 +03:00
|
|
|
sed -i "s/^SWAN_VER=.*/SWAN_VER=$ver/" vpnup.sh
|
|
|
|
bash vpnup.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
restart_ipsec
|
|
|
|
ipsec --version | grep "$ver"
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
done
|
|
|
|
|
|
|
|
wget -t 3 -T 30 -nv -O vpnup.sh https://git.io/vpnupgrade-ubuntu
|
|
|
|
sed -i '/swan_ver_latest=/s/^/#/' vpnup.sh
|
|
|
|
|
|
|
|
for ver in 4.3 4.4 4.5; do
|
2021-08-20 07:00:57 +03:00
|
|
|
[ "$ver" = "4.3" ] && shc=sh || shc=bash
|
2021-06-04 06:09:56 +03:00
|
|
|
sed -i "s/^SWAN_VER=.*/SWAN_VER=$ver/" vpnup.sh
|
2021-08-20 07:00:57 +03:00
|
|
|
"$shc" vpnup.sh <<ANSWERS
|
2021-02-04 10:47:04 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
2021-06-04 06:09:56 +03:00
|
|
|
restart_ipsec
|
2021-08-20 07:00:57 +03:00
|
|
|
ipsec --version | grep "$ver"
|
2021-06-04 06:09:56 +03:00
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
done
|
2021-02-22 08:54:37 +03:00
|
|
|
|
2021-01-29 19:04:09 +03:00
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
2021-01-19 10:05:48 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
2021-06-04 06:09:56 +03:00
|
|
|
restart_ipsec
|
2021-02-21 00:51:40 +03:00
|
|
|
ls -ld /etc/ipsec.d/ikev2.conf && exit 1
|
2021-01-19 10:05:48 +03:00
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
2021-02-21 00:51:40 +03:00
|
|
|
ipsec status | grep -q ikev2-cp && exit 1
|
2021-01-19 10:05:48 +03:00
|
|
|
certutil -L -d sql:/etc/ipsec.d
|
|
|
|
|
2020-07-09 09:41:52 +03:00
|
|
|
ls -ld vpnsetup.sh
|
|
|
|
ls -ld ikev2.sh
|
2021-04-25 00:16:44 +03:00
|
|
|
ls -ld vpnup.sh
|
2021-09-14 17:44:06 +03:00
|
|
|
|
|
|
|
test_set_3:
|
|
|
|
needs: [shellcheck, check_urls]
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
if: github.repository_owner == 'hwdsl2'
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os_version: ["alpine:3.14"]
|
|
|
|
fail-fast: false
|
|
|
|
container:
|
|
|
|
image: ${{ matrix.os_version }}
|
|
|
|
options: --cap-add=NET_ADMIN --device=/dev/ppp
|
|
|
|
steps:
|
|
|
|
- name: Test
|
|
|
|
run: |
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
log1=/var/log/auth.log
|
|
|
|
log2=/var/log/messages
|
|
|
|
|
|
|
|
restart_ipsec() {
|
|
|
|
ipsec whack --shutdown || true
|
|
|
|
ipsec pluto --config /etc/ipsec.conf
|
|
|
|
echo "Waiting for IPsec to restart."
|
|
|
|
count=0
|
|
|
|
while ! grep -q "pluto\[$(cat /var/run/pluto/pluto.pid)\]: listening for IKE messages" "$log1"; do
|
|
|
|
[ "$count" -ge "30" ] && { echo "IPsec failed to start."; exit 1; }
|
|
|
|
count=$((count+1))
|
|
|
|
printf '%s' '.'
|
|
|
|
sleep 0.5
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
}
|
|
|
|
|
|
|
|
mkdir -p /opt/src
|
|
|
|
cd /opt/src
|
|
|
|
echo "# hwdsl2" > run.sh
|
|
|
|
|
|
|
|
apk add -U wget rsyslog
|
|
|
|
rsyslogd
|
|
|
|
|
|
|
|
wget -t 3 -T 30 -nv -O vpnsetup.sh https://git.io/vpnsetup
|
|
|
|
sed -i '/curl /a sed -i "/swan_ver_latest=/s/^/#/" "$tmpdir/vpn.sh"' vpnsetup.sh
|
|
|
|
|
|
|
|
sh vpnsetup.sh
|
|
|
|
|
|
|
|
ipsec initnss
|
|
|
|
xl2tpd -c /etc/xl2tpd/xl2tpd.conf
|
|
|
|
restart_ipsec
|
|
|
|
|
|
|
|
netstat -anpu | grep pluto
|
|
|
|
netstat -anpu | grep xl2tpd
|
|
|
|
iptables -nvL
|
|
|
|
iptables -nvL | grep -q 'ppp+'
|
|
|
|
iptables -nvL | grep -q '192\.168\.43\.0/24'
|
|
|
|
iptables -nvL -t nat
|
|
|
|
iptables -nvL -t nat | grep -q '192\.168\.42\.0/24'
|
|
|
|
iptables -nvL -t nat | grep -q '192\.168\.43\.0/24'
|
|
|
|
grep pluto "$log1"
|
|
|
|
grep xl2tpd "$log2"
|
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
|
|
|
|
ls -l /usr/bin/ikev2.sh
|
|
|
|
ls -l /opt/src/ikev2.sh
|
|
|
|
|
|
|
|
wget -t 3 -T 30 -nv -O vpnunst.sh https://git.io/vpnuninstall
|
|
|
|
bash vpnunst.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
killall pluto || true
|
|
|
|
killall xl2tpd || true
|
|
|
|
|
|
|
|
wget -t 3 -T 30 -nv -O quickstart.sh https://git.io/vpnquickstart
|
|
|
|
sed -i -e '/curl /a sed -i "/swan_ver_latest=/s/^/#/" "$tmpdir/vpn.sh"' \
|
|
|
|
-e '/sleep 1/a sed -i "/swan_ver_latest=/s/^/#/" /opt/src/ikev2.sh' quickstart.sh
|
|
|
|
|
|
|
|
sh quickstart.sh
|
|
|
|
|
|
|
|
xl2tpd -c /etc/xl2tpd/xl2tpd.conf
|
|
|
|
restart_ipsec
|
|
|
|
|
|
|
|
netstat -anpu | grep pluto
|
|
|
|
netstat -anpu | grep xl2tpd
|
|
|
|
iptables -nvL
|
|
|
|
iptables -nvL | grep -q 'ppp+'
|
|
|
|
iptables -nvL | grep -q '192\.168\.43\.0/24'
|
|
|
|
iptables -nvL -t nat
|
|
|
|
iptables -nvL -t nat | grep -q '192\.168\.42\.0/24'
|
|
|
|
iptables -nvL -t nat | grep -q '192\.168\.43\.0/24'
|
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.p12
|
|
|
|
|
|
|
|
ls -l /usr/bin/ikev2.sh
|
|
|
|
ls -l /opt/src/ikev2.sh
|
|
|
|
|
|
|
|
bash vpnunst.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
killall pluto || true
|
|
|
|
killall xl2tpd || true
|
|
|
|
|
|
|
|
wget -t 3 -T 30 -nv -O vpnsetup.sh https://git.io/vpnsetup-alpine
|
|
|
|
sed -i '/swan_ver_latest=/s/^/#/' vpnsetup.sh
|
|
|
|
|
|
|
|
VPN_IPSEC_PSK='your_ipsec_pre_shared_key' \
|
|
|
|
VPN_USER='your_vpn_username' \
|
|
|
|
VPN_PASSWORD='your_vpn_password' \
|
|
|
|
VPN_DNS_SRV1='1.1.1.1' \
|
|
|
|
VPN_DNS_SRV2='1.0.0.1' \
|
|
|
|
bash vpnsetup.sh
|
|
|
|
|
|
|
|
ipsec initnss
|
|
|
|
restart_ipsec
|
|
|
|
grep -q "your_ipsec_pre_shared_key" /etc/ipsec.secrets
|
|
|
|
grep -q "your_vpn_username" /etc/ppp/chap-secrets
|
|
|
|
grep -q "your_vpn_password" /etc/ppp/chap-secrets
|
|
|
|
grep -q "your_vpn_username" /etc/ipsec.d/passwd
|
|
|
|
grep -q 'modecfgdns="1.1.1.1 1.0.0.1"' /etc/ipsec.conf
|
|
|
|
grep -q 'ms-dns 1.1.1.1' /etc/ppp/options.xl2tpd
|
|
|
|
grep -q 'ms-dns 1.0.0.1' /etc/ppp/options.xl2tpd
|
|
|
|
|
|
|
|
wget -t 3 -T 30 -nv -O ikev2.sh https://git.io/ikev2setup
|
|
|
|
sed -i '/swan_ver_latest=/s/^/#/' ikev2.sh
|
|
|
|
|
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
grep -q 'modecfgdns="8.8.8.8 8.8.4.4"' /etc/ipsec.d/ikev2.conf
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient.p12
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
grep pluto "$log1" | tail -n 20
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
1
|
|
|
|
invalidclient:
|
|
|
|
vpnclient
|
|
|
|
vpnclient2
|
|
|
|
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.p12
|
|
|
|
|
|
|
|
rm -f /etc/ipsec.d/vpnclient2*
|
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
2
|
|
|
|
nonexistclient
|
|
|
|
vpnclient2
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.p12
|
|
|
|
|
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
3
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
4
|
|
|
|
nonexistclient
|
|
|
|
vpnclient2
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
bash ikev2.sh <<ANSWERS 2>&1 | grep -i "abort"
|
|
|
|
4
|
|
|
|
vpnclient2
|
|
|
|
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
bash ikev2.sh <<ANSWERS 2>&1 | grep -i "abort"
|
|
|
|
2
|
|
|
|
vpnclient2
|
|
|
|
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
100
|
|
|
|
6
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
bash ikev2.sh <<ANSWERS 2>&1 | grep -i "abort"
|
|
|
|
5
|
|
|
|
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
5
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
ls -ld /etc/ipsec.d/ikev2.conf && exit 1
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp && exit 1
|
|
|
|
certutil -L -d sql:/etc/ipsec.d
|
|
|
|
|
|
|
|
rm -f /etc/ipsec.d/vpnclient*
|
|
|
|
|
|
|
|
VPN_DNS_SRV1=invaliddns \
|
|
|
|
bash ikev2.sh --auto 2>&1 | grep -i "invalid"
|
|
|
|
|
|
|
|
apk del uuidgen
|
|
|
|
sed -i '/^include /d' /etc/ipsec.conf
|
|
|
|
|
|
|
|
VPN_CLIENT_NAME=vpnclient1 \
|
|
|
|
VPN_DNS_NAME=vpn.example.com \
|
|
|
|
VPN_DNS_SRV1=1.1.1.1 \
|
|
|
|
VPN_DNS_SRV2=1.0.0.1 \
|
|
|
|
bash ikev2.sh --auto
|
|
|
|
|
|
|
|
grep -q 'leftid=@vpn.example.com' /etc/ipsec.d/ikev2.conf
|
|
|
|
grep -q 'modecfgdns="1.1.1.1 1.0.0.1"' /etc/ipsec.d/ikev2.conf
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient1.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient1.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient1.p12
|
|
|
|
grep -q 'vpn.example.com' /etc/ipsec.d/vpnclient1.mobileconfig
|
|
|
|
grep -q 'vpn.example.com' /etc/ipsec.d/vpnclient1.sswan
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
bash ikev2.sh --auto --addclient invalidclient: 2>&1 | grep -i "warning"
|
|
|
|
bash ikev2.sh --addclient invalidclient: 2>&1 | grep -i "invalid"
|
|
|
|
bash ikev2.sh --addclient vpnclient1 2>&1 | grep -i "already exists"
|
|
|
|
|
|
|
|
bash ikev2.sh --addclient vpnclient2
|
|
|
|
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.p12
|
|
|
|
|
|
|
|
bash ikev2.sh --exportclient nonexistclient 2>&1 | grep -i "does not exist"
|
|
|
|
|
|
|
|
rm -f /etc/ipsec.d/vpnclient2*
|
|
|
|
bash ikev2.sh --exportclient vpnclient2
|
|
|
|
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.mobileconfig
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.sswan
|
|
|
|
ls -ld /etc/ipsec.d/vpnclient2.p12
|
|
|
|
|
|
|
|
bash ikev2.sh --addclient vpnclient2 --exportclient vpnclient2 2>&1 | grep -i "invalid"
|
|
|
|
|
|
|
|
bash ikev2.sh --listclients | grep "vpnclient1"
|
|
|
|
bash ikev2.sh --listclients | grep "vpnclient2"
|
|
|
|
|
|
|
|
bash ikev2.sh --revokeclient nonexistclient 2>&1 | grep -i "does not exist"
|
|
|
|
bash ikev2.sh --revokeclient vpnclient2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
bash ikev2.sh --revokeclient vpnclient2 2>&1 | grep -i "already been revoked"
|
|
|
|
bash ikev2.sh --exportclient vpnclient2 2>&1 | grep -i "revoked"
|
|
|
|
bash ikev2.sh -h 2>&1 | grep -i "usage:"
|
|
|
|
bash ikev2.sh --invalidoption 2>&1 | grep -i "usage:"
|
|
|
|
|
|
|
|
bash ikev2.sh --removeikev2 --exportclient vpnclient1 2>&1 | grep -i "invalid"
|
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
invalidfqdn
|
|
|
|
vpn.example.com
|
|
|
|
|
|
|
|
|
|
|
|
y
|
|
|
|
invaliddns
|
|
|
|
1.1.1.1
|
|
|
|
invaliddns
|
|
|
|
1.0.0.1
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
grep -q 'leftid=@vpn.example.com' /etc/ipsec.d/ikev2.conf
|
|
|
|
grep -q 'modecfgdns="1.1.1.1 1.0.0.1"' /etc/ipsec.d/ikev2.conf
|
|
|
|
restart_ipsec
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
|
|
|
|
invalidip
|
|
|
|
1.2.3.4
|
|
|
|
invalidclient:
|
|
|
|
vpnclient1
|
|
|
|
1000
|
|
|
|
12
|
|
|
|
y
|
|
|
|
1.1.1.1
|
|
|
|
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
grep -q 'leftid=1.2.3.4' /etc/ipsec.d/ikev2.conf
|
|
|
|
grep -q 'modecfgdns=1.1.1.1' /etc/ipsec.d/ikev2.conf
|
|
|
|
restart_ipsec
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
VPN_DNS_SRV1=1.1.1.1 \
|
|
|
|
bash ikev2.sh --auto
|
|
|
|
|
|
|
|
grep -q 'modecfgdns=1.1.1.1' /etc/ipsec.d/ikev2.conf
|
|
|
|
restart_ipsec
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
bash ikev2.sh --auto
|
|
|
|
|
|
|
|
grep -q 'modecfgdns="8.8.8.8 8.8.4.4"' /etc/ipsec.d/ikev2.conf
|
|
|
|
restart_ipsec
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
wget -t 3 -T 30 -nv -O vpnup.sh https://git.io/vpnupgrade
|
|
|
|
sed -i '/curl /a sed -i "/swan_ver_latest=/s/^/#/" "$tmpdir/vpnup.sh"' vpnup.sh
|
|
|
|
|
|
|
|
for ver in 4.5; do
|
|
|
|
sed -i "s/^SWAN_VER=.*/SWAN_VER=$ver/" vpnup.sh
|
|
|
|
bash vpnup.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
restart_ipsec
|
|
|
|
ipsec --version | grep "$ver"
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
done
|
|
|
|
|
|
|
|
wget -t 3 -T 30 -nv -O vpnup.sh https://git.io/vpnupgrade-alpine
|
|
|
|
sed -i '/swan_ver_latest=/s/^/#/' vpnup.sh
|
|
|
|
|
|
|
|
for ver in 4.5; do
|
|
|
|
sed -i "s/^SWAN_VER=.*/SWAN_VER=$ver/" vpnup.sh
|
|
|
|
bash vpnup.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
restart_ipsec
|
|
|
|
ipsec --version | grep "$ver"
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
done
|
|
|
|
|
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
restart_ipsec
|
|
|
|
ls -ld /etc/ipsec.d/ikev2.conf && exit 1
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp && exit 1
|
|
|
|
certutil -L -d sql:/etc/ipsec.d
|
|
|
|
|
|
|
|
ls -ld vpnsetup.sh
|
|
|
|
ls -ld ikev2.sh
|
|
|
|
ls -ld vpnup.sh
|