Created
August 30, 2021 05:25
-
-
Save JfrAziz/5c69e59c03ebf0d31fbf0ea851787f08 to your computer and use it in GitHub Desktop.
Github Action Connect to IPSEC / L2TP VPN Connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Greeting from Mona | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
deploy: | |
name: Deploy To Server | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Network Manager | |
run: | | |
sudo apt-get -y update | |
sudo apt-get -y install strongswan xl2tpd libstrongswan-standard-plugins libstrongswan-extra-plugins | |
- name: Add Ipsec Conf | |
run: | | |
sudo tee -a /etc/ipsec.conf << EOF | |
config setup | |
conn %default | |
ikelifetime=60m | |
keylife=20m | |
rekeymargin=3m | |
keyingtries=1 | |
keyexchange=ikev1 | |
authby=secret | |
conn VPN1 | |
auto=add | |
keyexchange=ikev1 | |
authby=secret | |
type=transport | |
left=%defaultroute | |
leftprotoport=17/1701 | |
rightprotoport=17/1701 | |
right=${{ secrets.VPN_SERVER }} | |
ike=3des-sha1-modp1024 | |
esp=3des-sha1 | |
EOF | |
- name: Add Ipsec Secret | |
run: | | |
sudo tee -a /etc/ipsec.secrets << EOF | |
: PSK "${{ secrets.VPN_PSK }}" | |
EOF | |
sudo chmod 600 /etc/ipsec.secrets | |
- name: Add Ipsec Options | |
run: | | |
sudo tee -a /etc/xl2tpd/xl2tpd.conf << EOF | |
[lac VPN1] | |
lns = $VPN_SERVER_IPV4 | |
ppp debug = yes | |
pppoptfile = /etc/ppp/options.l2tpd.client | |
length bit = yes | |
EOF | |
sudo tee -a /etc/ppp/options.l2tpd.client << EOF | |
ipcp-accept-local | |
ipcp-accept-remote | |
refuse-eap | |
require-chap | |
noccp | |
noauth | |
mtu 1280 | |
mru 1280 | |
noipdefault | |
defaultroute | |
usepeerdns | |
connect-delay 5000 | |
name "${{ secrets.VPN_USERNAME }}" | |
password "${{ secrets.VPN_PASSWORD }}" | |
EOF | |
sudo chmod 600 /etc/ppp/options.l2tpd.client | |
- name: Restart Services | |
run: | | |
sudo service ipsec restart | |
sudo service xl2tpd restart | |
- name: Connect To VPN | |
run: | | |
sudo service ipsec start | |
sudo service xl2tpd start | |
sudo ipsec up VPN1 | |
- name: Ping Server | |
run: | | |
ping ${{ secrets.SERVER_URL }} -c 4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment