From ff8dd58749cdc80631ccbec8ee789ddeaea9338f Mon Sep 17 00:00:00 2001 From: hwdsl2 Date: Mon, 16 May 2016 13:56:05 -0500 Subject: [PATCH] :tada: Feature: Add support for IPsec/XAUTH --- vpnsetup.sh | 65 ++++++++++++++++++++++++++++++++++------------ vpnsetup_centos.sh | 65 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 98 insertions(+), 32 deletions(-) diff --git a/vpnsetup.sh b/vpnsetup.sh index 6089788..4408ae9 100644 --- a/vpnsetup.sh +++ b/vpnsetup.sh @@ -80,7 +80,7 @@ export DEBIAN_FRONTEND=noninteractive apt-get -y update # Make sure basic commands exist -apt-get -y install wget dnsutils +apt-get -y install wget dnsutils openssl apt-get -y install iproute gawk grep sed net-tools if [ "$(sed 's/\..*//' /etc/debian_version)" = "7" ]; then @@ -162,33 +162,54 @@ cat > /etc/ipsec.conf < /etc/ppp/chap-secrets </dev/null +VPN_PASSWORD_ENC=$(openssl passwd -1 "$VPN_PASSWORD") +echo "${VPN_USER}:${VPN_PASSWORD_ENC}:xauth-psk" > /etc/ipsec.d/passwd + # Update sysctl settings for VPN and performance if ! grep -qs "hwdsl2 VPN script" /etc/sysctl.conf; then /bin/cp -f /etc/sysctl.conf "/etc/sysctl.conf.old-$SYS_DT" 2>/dev/null @@ -303,8 +328,11 @@ cat > /etc/iptables.rules < /etc/iptables.rules @@ -403,7 +436,7 @@ sysctl -p chmod +x /etc/rc.local chmod +x /etc/network/if-pre-up.d/iptablesload chmod +x /etc/network/if-pre-up.d/ip6tablesload -chmod 600 /etc/ipsec.secrets* /etc/ppp/chap-secrets* +chmod 600 /etc/ipsec.secrets* /etc/ppp/chap-secrets* /etc/ipsec.d/passwd* # Apply new IPTables rules iptables-restore < /etc/iptables.rules diff --git a/vpnsetup_centos.sh b/vpnsetup_centos.sh index 2d78014..40450b4 100644 --- a/vpnsetup_centos.sh +++ b/vpnsetup_centos.sh @@ -88,7 +88,7 @@ mkdir -p /opt/src cd /opt/src || exit 1 # Make sure basic commands exist -yum -y install wget bind-utils +yum -y install wget bind-utils openssl yum -y install iproute gawk grep sed net-tools echo @@ -183,33 +183,54 @@ cat > /etc/ipsec.conf < /etc/ppp/chap-secrets </dev/null +VPN_PASSWORD_ENC=$(openssl passwd -1 "$VPN_PASSWORD") +echo "${VPN_USER}:${VPN_PASSWORD_ENC}:xauth-psk" > /etc/ipsec.d/passwd + # Update sysctl settings for VPN and performance if ! grep -qs "hwdsl2 VPN script" /etc/sysctl.conf; then /bin/cp -f /etc/sysctl.conf "/etc/sysctl.conf.old-$SYS_DT" 2>/dev/null @@ -324,8 +349,11 @@ cat > /etc/sysconfig/iptables < /etc/sysconfig/iptables @@ -422,7 +455,7 @@ sysctl -p # Update file attributes chmod +x /etc/rc.local -chmod 600 /etc/ipsec.secrets* /etc/ppp/chap-secrets* +chmod 600 /etc/ipsec.secrets* /etc/ppp/chap-secrets* /etc/ipsec.d/passwd* # Apply new IPTables rules iptables-restore < /etc/sysconfig/iptables