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
|
|
|
|
if: success()
|
|
|
|
run: |
|
2020-07-09 09:41:52 +03:00
|
|
|
if [ ! -x /usr/bin/shellcheck ]; then
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
sudo apt-get -yq update
|
|
|
|
sudo apt-get -yq install shellcheck
|
|
|
|
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
|
|
|
|
|
|
|
|
export SHELLCHECK_OPTS="-e 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
|
|
|
|
|
|
|
test_set_1:
|
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-04-26 08:08:16 +03:00
|
|
|
os_version: ["centos:8", "centos:8s", "centos:7", "amazonlinux:2"]
|
2020-07-07 09:25:07 +03:00
|
|
|
fail-fast: false
|
|
|
|
env:
|
|
|
|
OS_VERSION: ${{ matrix.os_version }}
|
|
|
|
steps:
|
|
|
|
- name: Build
|
|
|
|
run: |
|
2021-03-10 08:26:06 +03:00
|
|
|
echo "Waiting 60 seconds..."
|
|
|
|
sleep 60
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2020-07-07 09:25:07 +03:00
|
|
|
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
|
|
|
|
set -e
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-12-28 09:45:59 +03:00
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
2020-07-12 00:48:12 +03:00
|
|
|
yum -y update
|
2020-07-07 09:25:07 +03:00
|
|
|
yum -y -q install wget rsyslog
|
|
|
|
systemctl start rsyslog
|
2020-12-28 09:45:59 +03:00
|
|
|
if [ "$1" = "centos" ]; then
|
|
|
|
wget -t 3 -T 30 -nv -O vpnsetup.sh https://git.io/vpnsetup-centos
|
|
|
|
else
|
2021-01-03 08:44:12 +03:00
|
|
|
wget -t 3 -T 30 -nv -O vpnsetup.sh https://git.io/vpnsetup-amzn
|
2020-12-28 09:45:59 +03:00
|
|
|
fi
|
2020-07-07 09:25:07 +03:00
|
|
|
else
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
apt-get -yq update
|
2020-07-12 00:48:12 +03:00
|
|
|
apt-get -yq dist-upgrade
|
2020-07-07 09:25:07 +03:00
|
|
|
apt-get -yq install wget rsyslog
|
|
|
|
service rsyslog start
|
|
|
|
wget -t 3 -T 30 -nv -O vpnsetup.sh https://git.io/vpnsetup
|
|
|
|
fi
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-01-03 08:44:12 +03:00
|
|
|
sed -i '/swan_ver_url/s/^/#/' vpnsetup.sh
|
2020-07-07 09:25:07 +03:00
|
|
|
sh vpnsetup.sh
|
2020-12-28 09:45:59 +03:00
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
2020-07-07 09:25:07 +03:00
|
|
|
systemctl start ipsec
|
|
|
|
systemctl start xl2tpd
|
2020-07-12 00:48:12 +03:00
|
|
|
sleep 5
|
|
|
|
systemctl restart fail2ban
|
|
|
|
else
|
|
|
|
sleep 5
|
|
|
|
service fail2ban restart
|
2020-07-07 09:25:07 +03:00
|
|
|
fi
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2020-07-12 00:48:12 +03:00
|
|
|
sleep 5
|
2020-07-09 09:41:52 +03:00
|
|
|
netstat -anpu | grep pluto
|
|
|
|
netstat -anpu | grep xl2tpd
|
2020-07-07 09:25:07 +03:00
|
|
|
iptables -nL
|
|
|
|
iptables -nL | grep -q '192\.168\.42\.0/24'
|
|
|
|
iptables -nL -t nat
|
|
|
|
iptables -nL -t nat | grep -q '192\.168\.43\.0/24'
|
2020-12-28 09:45:59 +03:00
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
2020-07-07 09:25:07 +03:00
|
|
|
grep pluto /var/log/secure
|
|
|
|
grep xl2tpd /var/log/messages
|
|
|
|
else
|
|
|
|
grep pluto /var/log/auth.log
|
|
|
|
grep xl2tpd /var/log/syslog
|
|
|
|
fi
|
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
|
|
|
|
2020-07-12 00:48:12 +03:00
|
|
|
cat /var/log/fail2ban.log
|
|
|
|
grep -E "Jail '(sshd?|ssh-iptables)' started" /var/log/fail2ban.log
|
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' \
|
2020-07-09 09:41:52 +03:00
|
|
|
sh vpnsetup.sh
|
2020-12-28 09:45:59 +03:00
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
2020-07-09 09:41:52 +03:00
|
|
|
systemctl restart ipsec
|
|
|
|
fi
|
|
|
|
|
2020-08-10 02:14:56 +03:00
|
|
|
sleep 10
|
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
|
|
|
|
2020-12-27 00:19:21 +03:00
|
|
|
wget -t 3 -T 30 -nv -O ikev2.sh https://raw.githubusercontent.com/hwdsl2/setup-ipsec-vpn/master/extras/ikev2setup.sh # hwdsl2
|
2021-01-18 09:01:46 +03:00
|
|
|
sed -i '/swan_ver_latest=/s/^/#/' ikev2.sh
|
2020-07-07 09:25:07 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
2020-07-09 09:41:52 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-01-16 08:26:25 +03:00
|
|
|
|
2020-07-07 09:25:07 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
2020-07-09 09:41:52 +03:00
|
|
|
|
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
|
2020-12-28 09:45:59 +03:00
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
2020-07-07 09:25:07 +03:00
|
|
|
systemctl restart ipsec
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/secure | tail -n 20
|
|
|
|
else
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/auth.log | tail -n 20
|
|
|
|
fi
|
2020-12-28 09:45:59 +03:00
|
|
|
ipsec status
|
|
|
|
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
|
2020-07-07 09:25:07 +03:00
|
|
|
vpnclient2
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-01-16 08:26:25 +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
|
|
|
|
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-01-29 19:04:09 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
2021-02-02 07:38:53 +03:00
|
|
|
4
|
2021-01-29 19:04:09 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
|
|
|
systemctl restart ipsec
|
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 10
|
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
|
|
|
|
|
|
|
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-01-29 19:04:09 +03:00
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
|
|
|
systemctl restart ipsec
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/secure | tail -n 20
|
|
|
|
else
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/auth.log | tail -n 20
|
|
|
|
fi
|
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
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-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
|
|
|
|
2020-12-28 09:45:59 +03:00
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
2020-08-10 02:14:56 +03:00
|
|
|
sed -i '/pluto/d' /var/log/secure
|
|
|
|
pkill -HUP rsyslog
|
2020-12-28 09:45:59 +03:00
|
|
|
if [ "$1" = "centos" ]; then
|
2021-04-25 00:16:44 +03:00
|
|
|
wget -t 3 -T 30 -nv -O vpnup.sh https://git.io/vpnupgrade-centos
|
2020-12-28 09:45:59 +03:00
|
|
|
else
|
2021-04-25 00:16:44 +03:00
|
|
|
wget -t 3 -T 30 -nv -O vpnup.sh https://git.io/vpnupgrade-amzn
|
2020-12-28 09:45:59 +03:00
|
|
|
fi
|
2020-08-10 02:14:56 +03:00
|
|
|
else
|
|
|
|
sed -i '/pluto/d' /var/log/auth.log
|
|
|
|
pkill -HUP rsyslog
|
2021-04-25 00:16:44 +03:00
|
|
|
wget -t 3 -T 30 -nv -O vpnup.sh https://git.io/vpnupgrade
|
2020-08-10 02:14:56 +03:00
|
|
|
fi
|
2021-01-03 08:44:12 +03:00
|
|
|
|
2021-04-25 00:16:44 +03:00
|
|
|
sed -i '/swan_ver_url/s/^/#/' vpnup.sh
|
|
|
|
sed -i 's/^SWAN_VER=.*/SWAN_VER=3.32/' vpnup.sh
|
|
|
|
sh vpnup.sh <<ANSWERS
|
2020-08-10 02:14:56 +03:00
|
|
|
y
|
2021-01-03 08:44:12 +03:00
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
|
|
|
systemctl restart ipsec
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/secure
|
|
|
|
else
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/auth.log
|
|
|
|
fi
|
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
|
|
|
sed -i '/pluto/d' /var/log/secure
|
|
|
|
pkill -HUP rsyslog
|
|
|
|
else
|
|
|
|
sed -i '/pluto/d' /var/log/auth.log
|
|
|
|
pkill -HUP rsyslog
|
|
|
|
fi
|
|
|
|
|
2021-04-25 00:16:44 +03:00
|
|
|
sed -i 's/^SWAN_VER=.*/SWAN_VER=4.1/' vpnup.sh
|
|
|
|
sh vpnup.sh <<ANSWERS
|
2021-02-04 10:47:04 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
|
|
|
systemctl restart ipsec
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/secure
|
|
|
|
else
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/auth.log
|
|
|
|
fi
|
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
|
|
|
sed -i '/pluto/d' /var/log/secure
|
|
|
|
pkill -HUP rsyslog
|
|
|
|
else
|
|
|
|
sed -i '/pluto/d' /var/log/auth.log
|
|
|
|
pkill -HUP rsyslog
|
|
|
|
fi
|
|
|
|
|
2021-04-25 00:16:44 +03:00
|
|
|
sed -i 's/^SWAN_VER=.*/SWAN_VER=4.2/' vpnup.sh
|
|
|
|
sh vpnup.sh <<ANSWERS
|
2020-08-10 02:14:56 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
2020-12-28 09:45:59 +03:00
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
2020-08-10 02:14:56 +03:00
|
|
|
systemctl restart ipsec
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/secure
|
|
|
|
else
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/auth.log
|
|
|
|
fi
|
2020-12-28 09:45:59 +03:00
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
2020-08-10 02:14:56 +03:00
|
|
|
|
2021-02-22 08:54:37 +03:00
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
|
|
|
sed -i '/pluto/d' /var/log/secure
|
|
|
|
pkill -HUP rsyslog
|
|
|
|
else
|
|
|
|
sed -i '/pluto/d' /var/log/auth.log
|
|
|
|
pkill -HUP rsyslog
|
|
|
|
fi
|
|
|
|
|
2021-04-25 00:16:44 +03:00
|
|
|
sed -i 's/^SWAN_VER=.*/SWAN_VER=4.3/' vpnup.sh
|
|
|
|
sh vpnup.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
|
|
|
systemctl restart ipsec
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/secure
|
|
|
|
else
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/auth.log
|
|
|
|
fi
|
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
|
|
|
sed -i '/pluto/d' /var/log/secure
|
|
|
|
pkill -HUP rsyslog
|
|
|
|
else
|
|
|
|
sed -i '/pluto/d' /var/log/auth.log
|
|
|
|
pkill -HUP rsyslog
|
|
|
|
fi
|
|
|
|
|
|
|
|
sed -i 's/^SWAN_VER=.*/SWAN_VER=4.4/' vpnup.sh
|
|
|
|
sh vpnup.sh <<ANSWERS
|
2021-02-22 08:54:37 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
|
|
|
systemctl restart ipsec
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/secure
|
|
|
|
else
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/auth.log
|
|
|
|
fi
|
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
2021-01-29 19:04:09 +03:00
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
2021-01-19 10:05:48 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
if [ "$1" = "centos" ] || [ "$1" = "amazon" ]; then
|
|
|
|
systemctl restart ipsec
|
|
|
|
fi
|
|
|
|
|
|
|
|
sleep 10
|
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
|
|
|
|
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
|
|
|
|
if: success()
|
|
|
|
run: |
|
|
|
|
docker run -d --name "${OS_VERSION//:}-test-1" -v /sys/fs/cgroup:/sys/fs/cgroup:ro \
|
|
|
|
--privileged "${OS_VERSION//:}-test"
|
|
|
|
sleep 10
|
|
|
|
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:
|
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:
|
2020-12-03 08:40:54 +03:00
|
|
|
os_version: ["ubuntu:20.04", "ubuntu:18.04", "debian:10", "debian:9"]
|
2020-07-07 09:25:07 +03:00
|
|
|
fail-fast: false
|
|
|
|
container:
|
|
|
|
image: ${{ matrix.os_version }}
|
|
|
|
options: --privileged -v /lib/modules:/lib/modules:ro
|
|
|
|
steps:
|
|
|
|
- name: Test
|
|
|
|
run: |
|
2021-03-10 08:26:06 +03:00
|
|
|
echo "Waiting 60 seconds..."
|
|
|
|
sleep 60
|
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
|
|
|
|
apt-get -yq update
|
|
|
|
apt-get -yq dist-upgrade
|
|
|
|
apt-get -yq install wget rsyslog
|
|
|
|
service rsyslog start
|
|
|
|
wget -t 3 -T 30 -nv -O vpnsetup.sh https://git.io/vpnsetup
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-01-03 08:44:12 +03:00
|
|
|
sed -i '/swan_ver_url/s/^/#/' vpnsetup.sh
|
2020-07-07 09:25:07 +03:00
|
|
|
sh vpnsetup.sh
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2020-07-12 00:48:12 +03:00
|
|
|
sleep 5
|
|
|
|
service fail2ban restart
|
|
|
|
sleep 5
|
2020-07-09 09:41:52 +03:00
|
|
|
netstat -anpu | grep pluto
|
|
|
|
netstat -anpu | grep xl2tpd
|
2020-07-07 09:25:07 +03:00
|
|
|
iptables -nL
|
|
|
|
iptables -nL | grep -q '192\.168\.42\.0/24'
|
|
|
|
iptables -nL -t nat
|
|
|
|
iptables -nL -t nat | grep -q '192\.168\.43\.0/24'
|
2020-12-03 08:40:54 +03:00
|
|
|
grep pluto /var/log/auth.log
|
|
|
|
grep xl2tpd /var/log/syslog
|
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
|
|
|
|
2020-07-12 00:48:12 +03:00
|
|
|
cat /var/log/fail2ban.log
|
|
|
|
grep -E "Jail '(sshd?|ssh-iptables)' started" /var/log/fail2ban.log
|
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' \
|
2020-07-09 09:41:52 +03:00
|
|
|
sh vpnsetup.sh
|
|
|
|
|
2020-08-10 02:14:56 +03:00
|
|
|
sleep 10
|
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
|
|
|
|
2020-12-27 00:19:21 +03:00
|
|
|
wget -t 3 -T 30 -nv -O ikev2.sh https://github.com/hwdsl2/setup-ipsec-vpn/raw/master/extras/ikev2setup.sh
|
2021-01-18 09:01:46 +03:00
|
|
|
sed -i '/swan_ver_latest=/s/^/#/' ikev2.sh
|
2021-01-29 19:04:09 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
y
|
|
|
|
ANSWERS
|
2020-07-09 09:41:52 +03:00
|
|
|
|
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
|
2020-07-07 09:25:07 +03:00
|
|
|
sleep 10
|
2020-12-03 08:40:54 +03:00
|
|
|
grep pluto /var/log/auth.log | tail -n 20
|
2020-12-28 09:45:59 +03:00
|
|
|
ipsec status
|
|
|
|
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
|
2020-07-07 09:25:07 +03:00
|
|
|
vpnclient2
|
2020-07-09 09:41:52 +03:00
|
|
|
|
2021-01-16 08:26:25 +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
|
|
|
|
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-01-29 19:04:09 +03:00
|
|
|
bash ikev2.sh <<ANSWERS
|
2021-02-02 07:38:53 +03:00
|
|
|
4
|
2021-01-29 19:04:09 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
sleep 10
|
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
|
|
|
|
|
|
|
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-01-29 19:04:09 +03:00
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/auth.log | tail -n 20
|
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
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-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
|
|
|
|
2020-12-03 08:40:54 +03:00
|
|
|
sed -i '/pluto/d' /var/log/auth.log
|
|
|
|
pkill -HUP rsyslog
|
2021-01-03 08:44:12 +03:00
|
|
|
|
2021-04-25 00:16:44 +03:00
|
|
|
wget -t 3 -T 30 -nv -O vpnup.sh https://git.io/vpnupgrade
|
|
|
|
|
|
|
|
sed -i '/swan_ver_url/s/^/#/' vpnup.sh
|
|
|
|
sed -i 's/^SWAN_VER=.*/SWAN_VER=3.32/' vpnup.sh
|
|
|
|
sh vpnup.sh <<ANSWERS
|
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/auth.log
|
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
sed -i '/pluto/d' /var/log/auth.log
|
|
|
|
pkill -HUP rsyslog
|
2021-01-03 08:44:12 +03:00
|
|
|
|
2021-04-25 00:16:44 +03:00
|
|
|
sed -i 's/^SWAN_VER=.*/SWAN_VER=4.1/' vpnup.sh
|
|
|
|
sh vpnup.sh <<ANSWERS
|
2021-02-04 10:47:04 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/auth.log
|
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
sed -i '/pluto/d' /var/log/auth.log
|
|
|
|
pkill -HUP rsyslog
|
|
|
|
|
2021-04-25 00:16:44 +03:00
|
|
|
sed -i 's/^SWAN_VER=.*/SWAN_VER=4.2/' vpnup.sh
|
|
|
|
sh vpnup.sh <<ANSWERS
|
2020-08-10 02:14:56 +03:00
|
|
|
y
|
2021-01-03 08:44:12 +03:00
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/auth.log
|
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
|
|
|
sed -i '/pluto/d' /var/log/auth.log
|
|
|
|
pkill -HUP rsyslog
|
|
|
|
|
2021-04-25 00:16:44 +03:00
|
|
|
sed -i 's/^SWAN_VER=.*/SWAN_VER=4.3/' vpnup.sh
|
|
|
|
sh vpnup.sh <<ANSWERS
|
2020-08-10 02:14:56 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
sleep 10
|
2020-12-03 08:40:54 +03:00
|
|
|
grep pluto /var/log/auth.log
|
2020-12-28 09:45:59 +03:00
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
2020-08-10 02:14:56 +03:00
|
|
|
|
2021-02-22 08:54:37 +03:00
|
|
|
sed -i '/pluto/d' /var/log/auth.log
|
|
|
|
pkill -HUP rsyslog
|
|
|
|
|
2021-04-25 00:16:44 +03:00
|
|
|
sed -i 's/^SWAN_VER=.*/SWAN_VER=4.4/' vpnup.sh
|
|
|
|
sh vpnup.sh <<ANSWERS
|
2021-02-22 08:54:37 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
|
|
|
sleep 10
|
|
|
|
grep pluto /var/log/auth.log
|
|
|
|
ipsec status
|
|
|
|
ipsec status | grep -q l2tp-psk
|
|
|
|
ipsec status | grep -q xauth-psk
|
|
|
|
ipsec status | grep -q ikev2-cp
|
|
|
|
|
2021-01-29 19:04:09 +03:00
|
|
|
bash ikev2.sh --removeikev2 <<ANSWERS
|
2021-01-19 10:05:48 +03:00
|
|
|
y
|
|
|
|
ANSWERS
|
|
|
|
|
2021-01-29 19:04:09 +03:00
|
|
|
sleep 10
|
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
|