> For the complete documentation index, see [llms.txt](https://www.oraclelabs.link/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.oraclelabs.link/blog/articles/creating-an-l2tp-vpn-tunnel-over-ipsec.md).

# Creating an L2TP vpn tunnel over IPSec

In this series of mini articles, we describe how to deploy high-availability and secure Chainlink node. This article is dedicated to creating an L2TP vpn tonnel over IPSec for Guard VM, that will have access to Chainlink Virtual Private Cloud infrastructure.

### Setting up IPSec

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*HxsTqHgm7XKar0F9NoMrzg.png" alt="https://cdn-images-1.medium.com/max/1280/1*HxsTqHgm7XKar0F9NoMrzg.png"><figcaption></figcaption></figure>

Warning. For strongswan-starter setup it is better to go to source #1. This step was skipped when setting up.

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*VYGeFEbsbKB9nY-b0lO9YQ.png" alt="https://cdn-images-1.medium.com/max/1280/1*VYGeFEbsbKB9nY-b0lO9YQ.png"><figcaption></figcaption></figure>

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*KlwbA67ndjCi7hmC1XqjNg.png" alt="https://cdn-images-1.medium.com/max/1280/1*KlwbA67ndjCi7hmC1XqjNg.png"><figcaption></figcaption></figure>

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*z-iWc8dQc3M2sCh5pRUoug.png" alt="https://cdn-images-1.medium.com/max/1280/1*z-iWc8dQc3M2sCh5pRUoug.png"><figcaption></figcaption></figure>

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*E1KIciY4uVdbo8NIqFYL6w.png" alt="https://cdn-images-1.medium.com/max/1280/1*E1KIciY4uVdbo8NIqFYL6w.png"><figcaption></figcaption></figure>

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*1wthr1ig-XjwFQV4X8vkgg.png" alt="https://cdn-images-1.medium.com/max/1280/1*1wthr1ig-XjwFQV4X8vkgg.png"><figcaption></figcaption></figure>

### Setting up L2TP

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*mjh6my4fCDlTRaQ9DNOZYQ.png" alt="https://cdn-images-1.medium.com/max/1280/1*mjh6my4fCDlTRaQ9DNOZYQ.png"><figcaption></figcaption></figure>

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*AynTUt5G-tD9DbQFCJObzA.png" alt="https://cdn-images-1.medium.com/max/1280/1*AynTUt5G-tD9DbQFCJObzA.png"><figcaption></figcaption></figure>

Note: It is mandatory that the local ip and ip range are specified correctly.

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*MWBx8hwla7e6EzrKCs9YgQ.png" alt=""><figcaption></figcaption></figure>

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*eQ77IP3jBxZgygpTy5qm1Q.png" alt="https://cdn-images-1.medium.com/max/1280/1*eQ77IP3jBxZgygpTy5qm1Q.png"><figcaption></figcaption></figure>

### Setting up PPP

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*cOCedUKfzjM-R5CwQrVbNQ.png" alt="https://cdn-images-1.medium.com/max/1280/1*cOCedUKfzjM-R5CwQrVbNQ.png"><figcaption></figcaption></figure>

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*sDxmS--K6K73m_Eor5W0LA.png" alt="https://cdn-images-1.medium.com/max/1280/1*sDxmS--K6K73m_Eor5W0LA.png"><figcaption></figcaption></figure>

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*HtnzxOLr8NHbc81yK1_bOA.png" alt="https://cdn-images-1.medium.com/max/1280/1*HtnzxOLr8NHbc81yK1_bOA.png"><figcaption></figcaption></figure>

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*6zhckvch09BnqtEqucmpDQ.png" alt="https://cdn-images-1.medium.com/max/1280/1*6zhckvch09BnqtEqucmpDQ.png"><figcaption></figcaption></figure>

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*eG0QLfIq-L-nxJRPwgBexA.png" alt="https://cdn-images-1.medium.com/max/1280/1*eG0QLfIq-L-nxJRPwgBexA.png"><figcaption></figcaption></figure>

#### Adding firewall rules (does not work temporarily with the firewall)

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*k3I-BUmp7UtFZVuRs1eYbQ.png" alt="https://cdn-images-1.medium.com/max/1280/1*k3I-BUmp7UtFZVuRs1eYbQ.png"><figcaption></figcaption></figure>

#### NAT settings

Required for local network and internet access with a vpn connection.

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*TsFNC4QEKtLmYkrZit4ZQA.png" alt="https://cdn-images-1.medium.com/max/1280/1*TsFNC4QEKtLmYkrZit4ZQA.png"><figcaption></figcaption></figure>

Remember the rules, so that they are not wiped after restarting the server

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*uKKh-1MVgbe7ZunI7db5UA.png" alt="https://cdn-images-1.medium.com/max/1280/1*uKKh-1MVgbe7ZunI7db5UA.png"><figcaption></figcaption></figure>

Checking service status

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*3-TWkNdBT_9GYXpANT4vHQ.png" alt="https://cdn-images-1.medium.com/max/1280/1*3-TWkNdBT_9GYXpANT4vHQ.png"><figcaption></figcaption></figure>

Saving the rules

<figure><img src="https://cdn-images-1.medium.com/max/1600/1*u6F03F5tApY46uS_CtQeeA.png" alt="https://cdn-images-1.medium.com/max/1280/1*u6F03F5tApY46uS_CtQeeA.png"><figcaption></figcaption></figure>

Let’s check that everything works. Turn off and on the server. Check that the rule for NAT is still in place.

Next we will set up 2FA on Guard VM via ssh.

### Sources:

1. <https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-with-ufw-on-ubuntu-18-04-ru>
2. <https://www.digitalocean.com/community/tutorials/how-to-set-up-an-ikev2-vpn-server-with-strongswan-on-ubuntu-20-04-ru>
3. <https://interface31.ru/tech_it/2021/07/osnovy-iptables-dlya-nachinayushhih-chast-3-tablica-nat.html>
4. <https://www.cyberciti.biz/faq/how-to-save-iptables-firewall-rules-permanently-on-linux/>
5. <https://www.dmosk.ru/miniinstruktions.php?mini=l2tpd-ubuntu>
