{"componentChunkName":"component---src-templates-post-template-js","path":"/azure-vpn-setup-en","result":{"data":{"markdownRemark":{"id":"c7c4e073-0ca9-50da-97d2-44f9c5eac7ec","html":"<blockquote>\n<p>This page has been machine-translated from the <a href=\"/azure-vpn-setup\">original page</a>.</p>\n</blockquote>\n<p>The other day I wrote <a href=\"/honeypot-setup-on-azure-en\">this article</a> about building a honeypot on Azure. From both an access-control and security perspective, it seemed better to connect to the honeypot over a VPN, so I used Azure Virtual Network Gateway to configure a P2S VPN connection to the virtual network.</p>\n<p>While I was at it, I also thought it might be nice to use a server on AzureVM as a cloud proxy for extra security (a shallow thought, admittedly), so I built a proxy server on the Azure virtual network that I connect to over VPN.</p>\n<!-- omit in toc -->\n<h2 id=\"table-of-contents\" style=\"position:relative;\"><a href=\"#table-of-contents\" aria-label=\"table of contents permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Table of Contents</h2>\n<ul>\n<li><a href=\"#create-a-virtual-network-and-virtual-network-gateway\">Create a virtual network and virtual network gateway</a></li>\n<li><a href=\"#generate-a-self-signed-root-certificate-and-client-certificate\">Generate a self-signed root certificate and client certificate</a></li>\n<li><a href=\"#configure-the-p2s-vpn-connection\">Configure the P2S VPN connection</a></li>\n<li><a href=\"#configure-vpn-on-windows\">Configure VPN on Windows</a></li>\n<li><a href=\"#configure-a-proxy-on-azurevm\">Configure a proxy on AzureVM</a></li>\n<li><a href=\"#connection-test\">Connection test</a></li>\n</ul>\n<h2 id=\"create-a-virtual-network-and-virtual-network-gateway\" style=\"position:relative;\"><a href=\"#create-a-virtual-network-and-virtual-network-gateway\" aria-label=\"create a virtual network and virtual network gateway permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Create a virtual network and virtual network gateway</h2>\n<p>First, create a virtual network.</p>\n<p>This time, I created a virtual network with <code class=\"language-text\">172.16.0.0/20</code> and created a subnet in it for virtual machines.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 764px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/9763efe3f469ddd0448c1c516dd153a1/f3c12/image-20220304201840502.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 77.91666666666667%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAQCAYAAAAWGF8bAAAACXBIWXMAAAsTAAALEwEAmpwYAAABxklEQVQ4y61TC2/eIAzk//+9VWsntdI2bcsbEgIk5HXzsfApa9WHpiGdYoixz2ejSj3iR2uhx4DvnUdlHIbR49h3HACO47gB5/6tpe7uPuHLwwOqqkJT13h6esT9/WdM0/QiwEeCq9cyXS9/BPmOstbChwlloxGmGeNoEWPEsiwYhgFN04A+760cWLlxRFk3KLoBRfmnbAZyzp0Ba/R9j65rJdmYzrquS8g+JHBGheJG6w5VWaQLz8vdpTkZr+1vJVNDis9sxhhpRMAgbHLmXs6M0WAV27piPbGduO23FWGOMG6CCsEjeI8pBCQ74W97egPpvxDxboTtDRTLJMiwKIrUgPdm7SrL8/FR8zyjbdskPANrrVFLY2gzeAbPmZQ2v/TJ9zjDWmTbtw1q3Q+hPCdHL6VTE45MjDP+ZSnnpSltI+NSYV2idG2T75ICUx9rh8SuFZ9cZp5RktiE1XUq1BoDtJthwga7APtFPiZgSZn5VT/uOTIvGH6rRUNjUbUavyp5FdROsmsj6O1N19tXWJEdO5t15zTwhbEfavBrcjIy3K28Cl6iBD/bAV8bh7isyZEPYJ4nKTcmmwx5vpzy8JzlK/zn9Rvm19/kFBhR6QAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/9763efe3f469ddd0448c1c516dd153a1/8ac56/image-20220304201840502.webp 240w,\n/static/9763efe3f469ddd0448c1c516dd153a1/d3be9/image-20220304201840502.webp 480w,\n/static/9763efe3f469ddd0448c1c516dd153a1/79237/image-20220304201840502.webp 764w\"\n              sizes=\"(max-width: 764px) 100vw, 764px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/9763efe3f469ddd0448c1c516dd153a1/8ff5a/image-20220304201840502.png 240w,\n/static/9763efe3f469ddd0448c1c516dd153a1/e85cb/image-20220304201840502.png 480w,\n/static/9763efe3f469ddd0448c1c516dd153a1/f3c12/image-20220304201840502.png 764w\"\n            sizes=\"(max-width: 764px) 100vw, 764px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/9763efe3f469ddd0448c1c516dd153a1/f3c12/image-20220304201840502.png\"\n            alt=\"image-20220304201840502\"\n            title=\"image-20220304201840502\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Next, I created a virtual network gateway.</p>\n<p>At this point, the address range configured for the gateway subnet must be both within the virtual network’s address space and not overlap with any existing subnet in that virtual network.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 755px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/19c219e1f532d0dbfc3dbcf0916e30dc/cab43/image-20220304202022318.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 99.16666666666667%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAACXBIWXMAAAsTAAALEwEAmpwYAAACXUlEQVQ4y51U7XKbMBDk/Z8vf5xOp820cTAgvoWEJLjuHpDYnqTulJm1ZAF3e3t7ZE9PT3I6naQsCymKDZfLRc7ns3x7ftZ7IQThta7rQ2T8SSnJPM96cLz4v1fWNo1UVaWMQphvmDCJ906cc8qSZ8uy/AVJsq5tJcX4nuFgx5u1MZCi1IR938vsvQa/hwemacJ+ksxaKxHZWfbBjFdCxrw0UtdmZ+oVZPoZ+AyR8aHKVFKBCZnuKkpYRMoBgZC1A7sG0vDZhxpaO8olz5X2R8mrxGWVqndaBssax1HXuMvzZZdZe5hvm7FpuGi5xmwlX5f1GVRLNFA1VJ9dZdGA0LSpazFoyLzrd90Ef7P3e1MQsOs67SBvsDHHlSKacq7l9Vch+VsjboD4NirmfQ3Tvsfqcd+PaAqDaIdR4sZwC+jjKi+llaIe5NWMYsEihvhefpiDMuOZ7lEB9c3uu3SUHED25XcuP398FzsOqKKTASsrYoOGYVB9KRn3LfzMoGqb45AoMcsOetDYDEJjT3t3yWxbZ9WM73IlmGRyVrLDtDzkw+wuy5ereb6fbUpEEseEWGXcbwxJtUY3aWy3e1FfQozeBfUhEzlYQoM8MLf6kNEHzioCHpOSQDKvOnl7PUtjGnQ8l+JSih0sLLWqC24A0VNMR0CK3Sr1D9skMbmRtkKyZpTeDGqL5BdYJahdtnXfj1insBmbUGGxUkM19rrg/ygh4rMl//59VGNzZD6zz+wwUtYp6LcFpX0Flr1Ap21SgGWfko/RW6Wr8ZWpWlkCvj4uSiR82tZr4IzlEn8A4awbAE8ST9oAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/19c219e1f532d0dbfc3dbcf0916e30dc/8ac56/image-20220304202022318.webp 240w,\n/static/19c219e1f532d0dbfc3dbcf0916e30dc/d3be9/image-20220304202022318.webp 480w,\n/static/19c219e1f532d0dbfc3dbcf0916e30dc/a149a/image-20220304202022318.webp 755w\"\n              sizes=\"(max-width: 755px) 100vw, 755px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/19c219e1f532d0dbfc3dbcf0916e30dc/8ff5a/image-20220304202022318.png 240w,\n/static/19c219e1f532d0dbfc3dbcf0916e30dc/e85cb/image-20220304202022318.png 480w,\n/static/19c219e1f532d0dbfc3dbcf0916e30dc/cab43/image-20220304202022318.png 755w\"\n            sizes=\"(max-width: 755px) 100vw, 755px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/19c219e1f532d0dbfc3dbcf0916e30dc/cab43/image-20220304202022318.png\"\n            alt=\"image-20220304202022318\"\n            title=\"image-20220304202022318\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>With that in place, creation is complete. Next, create the root certificate to apply to the virtual network gateway.</p>\n<p>Reference: <a href=\"https://docs.microsoft.com/ja-jp/azure/vpn-gateway/vpn-gateway-howto-point-to-site-resource-manager-portal\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Connect to a VNet using P2S VPN and certificate authentication: portal - Azure VPN Gateway | Microsoft Docs</a></p>\n<h2 id=\"generate-a-self-signed-root-certificate-and-client-certificate\" style=\"position:relative;\"><a href=\"#generate-a-self-signed-root-certificate-and-client-certificate\" aria-label=\"generate a self signed root certificate and client certificate permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Generate a self-signed root certificate and client certificate</h2>\n<p>To connect over VPN using the virtual network gateway, create self-signed certificates on the Windows client.</p>\n<p>If you follow the steps in the official documentation below, you will be fine.</p>\n<p>Reference: <a href=\"https://docs.microsoft.com/ja-jp/azure/vpn-gateway/vpn-gateway-certificates-point-to-site\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Generate and export certificates for P2S: PowerShell - Azure VPN Gateway | Microsoft Docs</a></p>\n<p>First, run the following command in PowerShell launched with administrator privileges.</p>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\"><span class=\"token variable\">$cert</span> = <span class=\"token function\">New-SelfSignedCertificate</span> <span class=\"token operator\">-</span><span class=\"token function\">Type</span> Custom <span class=\"token operator\">-</span>KeySpec Signature `\n<span class=\"token operator\">-</span>Subject <span class=\"token string\">\"CN=P2SRootCert\"</span> <span class=\"token operator\">-</span>KeyExportPolicy Exportable `\n<span class=\"token operator\">-</span>HashAlgorithm sha256 <span class=\"token operator\">-</span>KeyLength 2048 `\n<span class=\"token operator\">-</span>CertStoreLocation <span class=\"token string\">\"Cert:\\CurrentUser\\My\"</span> <span class=\"token operator\">-</span>KeyUsageProperty Sign <span class=\"token operator\">-</span>KeyUsage CertSign</code></pre></div>\n<p>Now that the self-signed root certificate has been created, create a client certificate as well.</p>\n<p>Run the following command in the same PowerShell session.</p>\n<div class=\"gatsby-highlight\" data-language=\"powershell\"><pre class=\"language-powershell\"><code class=\"language-powershell\"><span class=\"token function\">New-SelfSignedCertificate</span> <span class=\"token operator\">-</span><span class=\"token function\">Type</span> Custom <span class=\"token operator\">-</span>DnsName P2SChildCert <span class=\"token operator\">-</span>KeySpec Signature `\n<span class=\"token operator\">-</span>Subject <span class=\"token string\">\"CN=P2SChildCert\"</span> <span class=\"token operator\">-</span>KeyExportPolicy Exportable `\n<span class=\"token operator\">-</span>HashAlgorithm sha256 <span class=\"token operator\">-</span>KeyLength 2048 `\n<span class=\"token operator\">-</span>CertStoreLocation <span class=\"token string\">\"Cert:\\CurrentUser\\My\"</span> `\n<span class=\"token operator\">-</span>Signer <span class=\"token variable\">$cert</span> <span class=\"token operator\">-</span>TextExtension @<span class=\"token punctuation\">(</span><span class=\"token string\">\"2.5.29.37={text}1.3.6.1.5.5.7.3.2\"</span><span class=\"token punctuation\">)</span></code></pre></div>\n<p>If it succeeds, the screen will look something like this.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 960px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/194ee083b47c67d0f91560b7aa6071b3/709cb/image-20220304203105251.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 25.83333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA7UlEQVQY022PW2+CQBSE10ZWRbDa1F5ieUApKqJIW0KqIVx3jf3//2c8C9j44MOXmZPsmTPL7N8zrB+JV+ItPuP9cMLTdworzmAfS0yCFM/7EtP9CUOvAl/m6K8KGJuqnjU3ByeU769LsGkoYHoZBmEC089hbivoPrET6BJMPVoWRA5Gi8p3HNJ51rBouc6PgYDhSwqT0DcCQ0J5g1T3mhaqjd6q6QtqLaGpIxSkwm9hdizxEhTofSbQFoSTgJPnpD03xSz6qwM4BWhuga7baL18L9BwIjx8fNV0ZmHD1VsRRluJMaGa/n+v5V7oBXKPkC7zRjjmAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/194ee083b47c67d0f91560b7aa6071b3/8ac56/image-20220304203105251.webp 240w,\n/static/194ee083b47c67d0f91560b7aa6071b3/d3be9/image-20220304203105251.webp 480w,\n/static/194ee083b47c67d0f91560b7aa6071b3/e46b2/image-20220304203105251.webp 960w,\n/static/194ee083b47c67d0f91560b7aa6071b3/43c62/image-20220304203105251.webp 1034w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/194ee083b47c67d0f91560b7aa6071b3/8ff5a/image-20220304203105251.png 240w,\n/static/194ee083b47c67d0f91560b7aa6071b3/e85cb/image-20220304203105251.png 480w,\n/static/194ee083b47c67d0f91560b7aa6071b3/d9199/image-20220304203105251.png 960w,\n/static/194ee083b47c67d0f91560b7aa6071b3/709cb/image-20220304203105251.png 1034w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/194ee083b47c67d0f91560b7aa6071b3/d9199/image-20220304203105251.png\"\n            alt=\"image-20220304203105251\"\n            title=\"image-20220304203105251\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>If you check the certificate store on Windows, you will see the following two certificates registered.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 960px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/b5c43c4ff1c25d259cc948972ffe094d/cdef6/image-20220304203801460.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 20%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAECAYAAACOXx+WAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA5ElEQVQY03WOy07CUBRF+9/GGeEhkmugipWfcECC1UE1DUqQ+AIMA56mURMUXwFLW1me2zpg4mDn3L3PPivXGFdTeE6efi3N0E7z6GwzPMryUlcEt/ssb8r/an3vXyfT8NwiUzePd6r4aCieXSUwEzoHBFIK9KEuiyIBrGf+1V78TnYWoQa+nWXoHW7w5BQI5WB+WeLBTvFa34l9DJbi5DjLvLXLSrzWomUytjN8C3Qm3dl50jeWzS0G1U1Gdo7JSU6AJp8XivdGkahtQbfCjwC018fcV+IsurP4apYIZfp/v9X5L/joCMlYBDZrAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/b5c43c4ff1c25d259cc948972ffe094d/8ac56/image-20220304203801460.webp 240w,\n/static/b5c43c4ff1c25d259cc948972ffe094d/d3be9/image-20220304203801460.webp 480w,\n/static/b5c43c4ff1c25d259cc948972ffe094d/e46b2/image-20220304203801460.webp 960w,\n/static/b5c43c4ff1c25d259cc948972ffe094d/5231b/image-20220304203801460.webp 1163w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/b5c43c4ff1c25d259cc948972ffe094d/8ff5a/image-20220304203801460.png 240w,\n/static/b5c43c4ff1c25d259cc948972ffe094d/e85cb/image-20220304203801460.png 480w,\n/static/b5c43c4ff1c25d259cc948972ffe094d/d9199/image-20220304203801460.png 960w,\n/static/b5c43c4ff1c25d259cc948972ffe094d/cdef6/image-20220304203801460.png 1163w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/b5c43c4ff1c25d259cc948972ffe094d/d9199/image-20220304203801460.png\"\n            alt=\"image-20220304203801460\"\n            title=\"image-20220304203801460\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>From these, export a <code class=\"language-text\">.cer</code> file from the root certificate named <code class=\"language-text\">P2SRootCert</code>.</p>\n<p>Right-click the root certificate, choose Export, and proceed by selecting <code class=\"language-text\">Base64 Encode~</code>.</p>\n<p>Export it with settings like the following.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 473px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/46960aabb8a03d1d20ca4efd91ff8d5a/c7c3c/image-20220304203933730.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 91.66666666666667%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAACXBIWXMAAAsTAAALEwEAmpwYAAAC/ElEQVQ4y51UW1cSURjlr9XqwdVfMFcr3+ulVQ+1ViWCIAyXmeEiAlarC48tDcm74hW8l4iIZomCkCiioZbA7jszCIO9WA+b7xzmnD3fZe9RHYV4fB/UIzHUjr2gCbkZAfmwiP1JC45CQhXZKQtyFDMTZvwYN0vnyhE3sNpJsZOiW4Iq5lfD73yAgPM+hryPEPmgxppfg5DvKZJjJmwN6LDeq8HXfj2So0bM+J4g+OoxJWAkAo9EVkeIqAdY76rAC6x5ZMQUa+WeRQZ2T8pOzhKRvwivEETdlcj23hqR8gwR1LKToyof5rEZ0GCrT48s9e2AkJ204pj6yPa5aR4Z6m1qlCMYkaH+sX4eTFlx8cVVJS1fZigNhfq0PWjA/oQFh3QwHxJRmLOBPWOR/Z8cMSI9xuGQXpAOcvQSM34tdSgIZaikcuIvK+Ww3lRiBWVlyVeel4isGKmBZakqzApIBdRI+J8jM6DBDsX9wVYcDmlxPKYnAsoiTqWtK7DWISPmqgf1UZUgPTVxRjQarWgyW3CrlaA242aLGTdemNCg5dHQVsNtnYBm3o57vIg7ZhHNFhF3rQIaOQHfgpRhivql93IweAVoOzk8FDg884jQve2oQ9sbBie0rx0wdPHguiywvbfD4bPD7nNAfGfH3pQLqrMFO7LDWqT7NciNtCM/qsPvkAlYFoElHsWwGefTRpRmLcACD3y2oUjrwiRHraD+btB0NynG3bhYdlIP5+1Y7VEj3qtFYtiEjYBWckFmwipZMebXItItu2fzkx7pcYtkvzRN+eeCA2c06dNFJwpsTVF1vuQgTcm62h5sx+6wAeVVT22qTPRxhZNI8LtUSYoktEtSYr7eoXvJYQ4sOSJ0ympnzojKzlDqqqRA1bfRSwcpHEUSYrqUCIsrrjqC8n+gtNJJhFQy+5G8qPTodRF1V78yTNQS4dmiA6fzNpzMiv+E47CAc7pbJj8zMLJzNpQT+ghs97Uh/pEm3XN9xLpbkCL/n8zwEjI0oMKcHX8A78KQdb7lPQ0AAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/46960aabb8a03d1d20ca4efd91ff8d5a/8ac56/image-20220304203933730.webp 240w,\n/static/46960aabb8a03d1d20ca4efd91ff8d5a/7124e/image-20220304203933730.webp 473w\"\n              sizes=\"(max-width: 473px) 100vw, 473px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/46960aabb8a03d1d20ca4efd91ff8d5a/8ff5a/image-20220304203933730.png 240w,\n/static/46960aabb8a03d1d20ca4efd91ff8d5a/c7c3c/image-20220304203933730.png 473w\"\n            sizes=\"(max-width: 473px) 100vw, 473px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/46960aabb8a03d1d20ca4efd91ff8d5a/c7c3c/image-20220304203933730.png\"\n            alt=\"image-20220304203933730\"\n            title=\"image-20220304203933730\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>In the exported <code class=\"language-text\">.cer</code> file, copy the content starting from the line after <code class=\"language-text\">BEGIN CERTIFICATE</code>.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">-----BEGIN CERTIFICATE-----\n<span class=\"token operator\">&lt;</span>copy this content<span class=\"token operator\">></span>\n-----END CERTIFICATE-----</code></pre></div>\n<h2 id=\"configure-the-p2s-vpn-connection\" style=\"position:relative;\"><a href=\"#configure-the-p2s-vpn-connection\" aria-label=\"configure the p2s vpn connection permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Configure the P2S VPN connection</h2>\n<p>From the virtual network gateway screen, open <code class=\"language-text\">Point-to-site configuration</code>.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 581px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/8a89e3e28bfcab709b0e7a873e089fd1/92d15/image-20220304204212568.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 68.33333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAAAsTAAALEwEAmpwYAAABi0lEQVQ4y51TaW+DMAzN//9Z28eu6tCkHpNKOQorBcJ9F97sbJlQV6lqLVkhxu89x07EYudh/WHg3TDw+vqC3XaLzXqN5fINBsV4b1kHcguu66i9ae7hOA5WqxUWiwWqqsI0TcqFFZaIwwBFUSDLMiRJgq7rMAwD+r5H27a4XC4qeRxHtbLp/TzGJmQcQcaxImMidiZpmuYnmZJYTIu0FGehuq7Vnp1zGZMnEsLxPBWYK2rVPM9RlSWyVKpkFnZsGxGtURQhTVNVvfaBhEQQxQrUkAKr6eOw+SSWZAUOYQEzyEm4JvIUJeWzc5XXJoqyUmrsDJgTHo9HEqI2jEAzTLhlehh/QymJUEqphsGq+ocm7LpWQ/+B5wPS3yIKY9Vk7gH37rpCbvY8NgffMuH7ngL6vq+qvEd4zwRXd6snTxOegjNNt1fH1cfm9WlC/xRg/CW4No+uzcOEtm3R0wvpfiWIwjPyLEVTV+Q1+B+/kIcIv3gojg2XwJ+7DV1mFxm9ilTGMPd7IuwfIvwGJ29AqTzHzX8AAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/8a89e3e28bfcab709b0e7a873e089fd1/8ac56/image-20220304204212568.webp 240w,\n/static/8a89e3e28bfcab709b0e7a873e089fd1/d3be9/image-20220304204212568.webp 480w,\n/static/8a89e3e28bfcab709b0e7a873e089fd1/39daa/image-20220304204212568.webp 581w\"\n              sizes=\"(max-width: 581px) 100vw, 581px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/8a89e3e28bfcab709b0e7a873e089fd1/8ff5a/image-20220304204212568.png 240w,\n/static/8a89e3e28bfcab709b0e7a873e089fd1/e85cb/image-20220304204212568.png 480w,\n/static/8a89e3e28bfcab709b0e7a873e089fd1/92d15/image-20220304204212568.png 581w\"\n            sizes=\"(max-width: 581px) 100vw, 581px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/8a89e3e28bfcab709b0e7a873e089fd1/92d15/image-20220304204212568.png\"\n            alt=\"image-20220304204212568\"\n            title=\"image-20220304204212568\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>From there, click <code class=\"language-text\">Configure now</code> to open the settings screen.</p>\n<p>For the address pool, specify an address pool included in the range of the virtual network.</p>\n<p>Also, unless you have a specific reason not to, <code class=\"language-text\">IKEv2</code> is probably a good choice for the tunnel type.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 960px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/4cf7cb7d01a1def6252ca3065e197ac9/218a4/image-20220304204407809.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 59.166666666666664%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAACXBIWXMAAAsTAAALEwEAmpwYAAABmklEQVQoz4WT23LbIBRF/f+f4sZxO8l7JnlJ/sB9cXNr7EhCFwTIEhftHo5cRvE4CTN7EAMsNpujxTbTeHp8xMvzM/b7PassSzRNg6qqIIRAlmUYxzHpq7YQTQutNbz3rEAbjPVwYYQPgQGBeucsrB14zRx+qkUuFZRs0sIIv725w2q5wtWva4isRHAjbO/gBs99CJPLs0ClB0gC9n3Pi6SUyN9zvL3u0DYK9mDhh8AwT3IEHI9AnLn9QtaSM/sPjNlFkOvJsccEmWsGPOuwaiRdwafDZNsi22Uo3gVDT2UPjjP9PMOyxuHQwVlLwTs0dY3ouq5qcgJ2M2m6IvdfvXJe5Ni9/UWR5zBaoaQyEaKAIqfeu/SySrX4s91SKZXQSvE4idZ2XTc5rFVHA5NOaGkybiryjNxWrHjQ780Gq4sL/Fyvsb68TIrjH8slHu7vJ4et0h8KNr5yhCpyEbOah/9dOzpsP4QcgfEPMUZzpvHacd5QfRpjjjFYLvRJLuXPQFGXGPohnRLLJm7gv8Na/rbHDVH8fSI7A/4DfMygpJYWvYEAAAAASUVORK5CYII='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/4cf7cb7d01a1def6252ca3065e197ac9/8ac56/image-20220304204407809.webp 240w,\n/static/4cf7cb7d01a1def6252ca3065e197ac9/d3be9/image-20220304204407809.webp 480w,\n/static/4cf7cb7d01a1def6252ca3065e197ac9/e46b2/image-20220304204407809.webp 960w,\n/static/4cf7cb7d01a1def6252ca3065e197ac9/c18de/image-20220304204407809.webp 1052w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/4cf7cb7d01a1def6252ca3065e197ac9/8ff5a/image-20220304204407809.png 240w,\n/static/4cf7cb7d01a1def6252ca3065e197ac9/e85cb/image-20220304204407809.png 480w,\n/static/4cf7cb7d01a1def6252ca3065e197ac9/d9199/image-20220304204407809.png 960w,\n/static/4cf7cb7d01a1def6252ca3065e197ac9/218a4/image-20220304204407809.png 1052w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/4cf7cb7d01a1def6252ca3065e197ac9/d9199/image-20220304204407809.png\"\n            alt=\"image-20220304204407809\"\n            title=\"image-20220304204407809\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Then set <code class=\"language-text\">Authentication type</code> to <code class=\"language-text\">Azure certificate</code>, paste the root certificate you copied earlier, and save.</p>\n<p>Once the configuration is complete, <code class=\"language-text\">Download VPN client</code> becomes available. Install the client you download here on the Windows machine that will use the VPN connection.</p>\n<h2 id=\"configure-vpn-on-windows\" style=\"position:relative;\"><a href=\"#configure-vpn-on-windows\" aria-label=\"configure vpn on windows permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Configure VPN on Windows</h2>\n<p>Once the client is installed, open Windows VPN settings and connect to Azure.</p>\n<p>If the connection succeeds, you will be able to connect over SSH and so on using the Azure-side local IP addresses configured for the virtual network, as shown below.</p>\n<p>Do not forget to allow it in the VM-side security group settings.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 960px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/8eb3966f00e81c5e29e709906e53c39b/e548f/image-20220304210335018.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 70.41666666666667%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAOCAYAAAAvxDzwAAAACXBIWXMAAAsTAAALEwEAmpwYAAACB0lEQVQ4y2VT2XLiQBDz4wbwfR/4wGASwOQg2aS2av//s7StNuMN5GFKc1mtlsbWaVjj+bHG5dThcuzw8tRgHErsN6mMAvsux7ZJ8dQXihxDm+ng3nFXCpYoUx+r5S9YoxDy4FE+Pu9rHdsm0/XHuEGVBcgTD+s81I+4LgS55pzYFBGKxIe9eoD1dmy1CgneRSULjPv/Rd4OreJhW0mBDmfphl2wq7Pc4/dGfRTasJoywqZOQGSLZeajreJZDc+4LmQ/Cmwkkat3cjlPY1fVe+4Sjv2gaHVVgr+XAX9ed6iFNA5dfJ570Nuvly2+nnvxtsVv2TtsSy3Mj1fSnmMvYMvcdRZKRrQyqbBrU1TiBatnsaeK6iLUNoi1eLRZJ3IvE3WB3HER+KuZyJCpQhJUeaCEvbRHlWwlDp25QCJzEnGPZyzAeeBNpDcKmzLWUPo6Fd8CdOvJT01S1BHZ/nFXqZ8kZJq5pDq1v7hVyCA+xafXQ6MtMdEkcjQAo3J6b5Wm34sNLEqVJGR3LDIT0i/zYDVxuVxcE6Z/RJMiA3DufPvRMon4N1AdU+Q7pMqTKOJb45xqlPzqNe/Tb99b3pCpQl+M5SS4orn03fBQEuWaZ7SAdkxntwkr4SDVqIJIhfz1GMI4VKr6JMhzekhltIWB3BPNhKE/mf89hPSqwvwZRLNnHvJ9q2b8Aw/lZ5EFks3UAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/8eb3966f00e81c5e29e709906e53c39b/8ac56/image-20220304210335018.webp 240w,\n/static/8eb3966f00e81c5e29e709906e53c39b/d3be9/image-20220304210335018.webp 480w,\n/static/8eb3966f00e81c5e29e709906e53c39b/e46b2/image-20220304210335018.webp 960w,\n/static/8eb3966f00e81c5e29e709906e53c39b/1e975/image-20220304210335018.webp 975w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/8eb3966f00e81c5e29e709906e53c39b/8ff5a/image-20220304210335018.png 240w,\n/static/8eb3966f00e81c5e29e709906e53c39b/e85cb/image-20220304210335018.png 480w,\n/static/8eb3966f00e81c5e29e709906e53c39b/d9199/image-20220304210335018.png 960w,\n/static/8eb3966f00e81c5e29e709906e53c39b/e548f/image-20220304210335018.png 975w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/8eb3966f00e81c5e29e709906e53c39b/d9199/image-20220304210335018.png\"\n            alt=\"image-20220304210335018\"\n            title=\"image-20220304210335018\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>For reference, my network security group looked like this.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 960px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/6a7ba15e8f1506feaa048ce87f057b43/11a8f/image-20220304221534416.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 23.75%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAFCAYAAABFA8wzAAAACXBIWXMAAAsTAAALEwEAmpwYAAAA50lEQVQY011QyU7FMBDr/38VF84gDhw4gQQP0TZ9TZplspqZCSdGclpZsT3O8vF5gzEG+3HH/Yo4nMd5ngghYN93BMoYkJnn/3HU8fJNeP0hPN8SFmsdYgxw3iPmitqB3gdyzqi1IpeGEJOKW2sKMScOkjG+4OHtwNNXwuN7wDJGV2GKcW4xJogIncUC7y8Vp5Swrqved86hlsoBhBTM374NSykFAqktVUXUe2cTr7yIr2saSsi2bfoVLvHmuRAOa9C4FXGrRQQCa61Wl6piKMbCS8XI248xn0F44TSYucahkRvoP9//Be67hRYwNfTTAAAAAElFTkSuQmCC'); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/6a7ba15e8f1506feaa048ce87f057b43/8ac56/image-20220304221534416.webp 240w,\n/static/6a7ba15e8f1506feaa048ce87f057b43/d3be9/image-20220304221534416.webp 480w,\n/static/6a7ba15e8f1506feaa048ce87f057b43/e46b2/image-20220304221534416.webp 960w,\n/static/6a7ba15e8f1506feaa048ce87f057b43/4cec6/image-20220304221534416.webp 1272w\"\n              sizes=\"(max-width: 960px) 100vw, 960px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/6a7ba15e8f1506feaa048ce87f057b43/8ff5a/image-20220304221534416.png 240w,\n/static/6a7ba15e8f1506feaa048ce87f057b43/e85cb/image-20220304221534416.png 480w,\n/static/6a7ba15e8f1506feaa048ce87f057b43/d9199/image-20220304221534416.png 960w,\n/static/6a7ba15e8f1506feaa048ce87f057b43/11a8f/image-20220304221534416.png 1272w\"\n            sizes=\"(max-width: 960px) 100vw, 960px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/6a7ba15e8f1506feaa048ce87f057b43/d9199/image-20220304221534416.png\"\n            alt=\"image-20220304221534416\"\n            title=\"image-20220304221534416\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>I also opened the port for the proxy that I set up afterward.</p>\n<p>Since <code class=\"language-text\">Source</code> is set to <code class=\"language-text\">VirtualNetwork</code>, it should reject connections over the global IP and only accept connections from terminals connected to the Azure virtual network over P2S VPN.</p>\n<p>Because the connection also requires a client certificate corresponding to the registered root certificate, it feels pretty secure.</p>\n<h2 id=\"configure-a-proxy-on-azurevm\" style=\"position:relative;\"><a href=\"#configure-a-proxy-on-azurevm\" aria-label=\"configure a proxy on azurevm permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Configure a proxy on AzureVM</h2>\n<p>Finally, I wanted to turn the AzureVM into a proxy by setting up Squid on it.</p>\n<p>The machine is running Ubuntu 20.04.</p>\n<p>First, update the machine.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">sudo</span> <span class=\"token function\">apt</span> update <span class=\"token operator\">&amp;&amp;</span> <span class=\"token function\">sudo</span> <span class=\"token function\">apt</span> upgrade -y\n<span class=\"token function\">sudo</span> <span class=\"token function\">apt</span> <span class=\"token function\">install</span> <span class=\"token function\">git</span> <span class=\"token function\">make</span> <span class=\"token function\">vim</span> -y</code></pre></div>\n<p>Next, install Squid and edit the configuration file.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">sudo</span> <span class=\"token function\">apt</span> <span class=\"token function\">install</span> squid -y\n<span class=\"token function\">sudo</span> <span class=\"token function\">cp</span> /etc/squid/squid.conf /etc/squid/squid.conf.origin\n<span class=\"token function\">sudo</span> <span class=\"token function\">vim</span> /etc/squid/squid.conf</code></pre></div>\n<p>This time I only wanted a minimal setup, so I changed the two entries <code class=\"language-text\">http_port</code> and <code class=\"language-text\">http_access</code>.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token comment\"># Squid normally listens to port 3128</span>\nhttp_port <span class=\"token operator\">&lt;</span>VM private IP<span class=\"token operator\">></span>:3128\n\nacl vGateways src <span class=\"token operator\">&lt;</span>virtual network gateway IP range<span class=\"token operator\">></span>\nhttp_access allow vGateways</code></pre></div>\n<p>By specifying <code class=\"language-text\">http_port</code> as <code class=\"language-text\">&lt;VM private IP>:3128</code>, you can configure it to accept traffic only on a port bound to that specific interface.</p>\n<p>Also, by setting the virtual network gateway IP range in <code class=\"language-text\">http_access</code>, only traffic coming over the VPN can use the proxy.</p>\n<p>That is enough for the minimal configuration, so start Squid.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">sudo</span> systemctl <span class=\"token builtin class-name\">enable</span> squid\n<span class=\"token function\">sudo</span> systemctl restart squid</code></pre></div>\n<h2 id=\"connection-test\" style=\"position:relative;\"><a href=\"#connection-test\" aria-label=\"connection test permalink\" class=\"anchor before\"><svg aria-hidden=\"true\" focusable=\"false\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>Connection test</h2>\n<p>On the Windows machine configured with the VPN, configure the server on AzureVM as a proxy.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 815px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/fe9ae4b91175dc4eeb8f5dcb32e030cc/ef916/image-20220304212806392.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 75%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAPCAYAAADkmO9VAAAACXBIWXMAAAsTAAALEwEAmpwYAAACyElEQVQ4y21TaVPaUBTFFdz3DZRNcKS0VsSqg0wtjlq1fnF0BBGSkIQlxCxi1f7703sfjbUdP5y5L8nkvHvuOdd3dHSE0/MzfD08RP5bAfuMQgEHx8eIJxNYXV3F2toaJiYmMDY2hvHxcYHR0VEMDg7C7/f/A9/l5SVKtyV8v7jAwckpCmc/cHh2jvOra3zMbCG4tIRkMolQKIQlOjOCwSBmZ2ffJ9R1Ha7romkYqDY03KhVlOQ7VNQaNrNZhOjnVCqF4eFh9PT0oL+/HwMDAwL/kwlCRVFgmiaqsoRyjYjqVVSUMhRVQSa7hfn5edHR9PS0OHNl0rfo6+sTF3DHPk3T4Dx0oDaaAlqrBUnTUa23sLm9g/DKCtbX1xGJRBCPx7G8vCzmOTc3h5mZGVEXFxcxOTnZ7VCSZRiWTUT3RGih1jBRlDVclBWkNrcRi0axsbEhwGTcIf/M3fIcmXBhYQFTU1N/JdudRzTMDqqaDaVuoSwruCpf48OnFKLUWTgcFmawrN7eXiGR4cn1zkKyTB0+PD2j7TyjotuQiVCtqzDMG+zsppFIJMjhIIaGhgQ4OtxhIBB43xRJkYTkWoPJHKhNC3VDg9u5Qy7/mToLClM8QpbI2WRiJuCu3sInaZKQXGvaZAbNkmrd0GG7MhFmSW4E6XQamUxGEPEc+QIeAY+CL2DD2JiuZF1G5+UX2u4L6uaT6FQnp22nhf38nhg4b0qUzGEjeEu8jeHK+RwZGRG1S0h5syg2jfufUI3HP4RtWI6D3H5ODNsf8L9uBcvm+fHq8bMXdO+7r6aqaFsOJN1CRSNDmkxownQfSHJexIHlsMQVyqQHfub3LJsveSUs3d5S/lpkCM1QmNIlvHc72MvlxM+cQZbI0rgzBkvkyu89cwRhsViEojdod1u0em0yxqAsNoXzX3b3RHhjsZgg8LLmSfR22iPj+htVH82nQkLdoAAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/fe9ae4b91175dc4eeb8f5dcb32e030cc/8ac56/image-20220304212806392.webp 240w,\n/static/fe9ae4b91175dc4eeb8f5dcb32e030cc/d3be9/image-20220304212806392.webp 480w,\n/static/fe9ae4b91175dc4eeb8f5dcb32e030cc/0ea8f/image-20220304212806392.webp 815w\"\n              sizes=\"(max-width: 815px) 100vw, 815px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/fe9ae4b91175dc4eeb8f5dcb32e030cc/8ff5a/image-20220304212806392.png 240w,\n/static/fe9ae4b91175dc4eeb8f5dcb32e030cc/e85cb/image-20220304212806392.png 480w,\n/static/fe9ae4b91175dc4eeb8f5dcb32e030cc/ef916/image-20220304212806392.png 815w\"\n            sizes=\"(max-width: 815px) 100vw, 815px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/fe9ae4b91175dc4eeb8f5dcb32e030cc/ef916/image-20220304212806392.png\"\n            alt=\"image-20220304212806392\"\n            title=\"image-20220304212806392\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>When you access any site, if the source address changes to the global IP address assigned to the AzureVM, you are done.</p>\n<p><span\n      class=\"gatsby-resp-image-wrapper\"\n      style=\"position: relative; display: block; margin-left: auto; margin-right: auto; max-width: 730px; \"\n    >\n      <a\n    class=\"gatsby-resp-image-link\"\n    href=\"/static/cb0e0cb96c6948928636e233cb8f0826/e9beb/image-20220304212900959.png\"\n    style=\"display: block\"\n    target=\"_blank\"\n    rel=\"noopener\"\n  >\n    <span\n    class=\"gatsby-resp-image-background-image\"\n    style=\"padding-bottom: 33.33333333333333%; position: relative; bottom: 0; left: 0; background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAHCAYAAAAIy204AAAACXBIWXMAAAsTAAALEwEAmpwYAAAB50lEQVQoz1WOS0+TYRCFv5/gDhcaFxrXxn+gO010ZbwsjHjZmLjSpCEiBUxqvLBgURTazwItIRCiMcTSUkKgtjUmGAq0FKn2Tu/QllJotZfHgbhx8eSdmfecmaMMOX5gFEbmgwzaNxiYWUc/48cwu4F5ISi9nyGpB2yH83XRBI506lyQ0YWf9E37jtB9XGXKE0a5rhnkdud72rtM3Owwck0zxI0Olfu9Yzx6McGD5+Pc67XQ3mPhTrdZegu3nqpHnrtaE1cev+Pqk0EuPuxHZ5pFMQxoGFW7GTZ0MWLUyvuMSYsOx7Qe+yc9TruRiREdU2NvmDS/ZHxYh/q2E5PoDj1mVcuYqUdmGtyLH1BgCVj+j1jCy4rPSyi6zJrfy6XLF2g7fozTZ05w8lQb586fpVB0iNYnfP/nW6LZCqI0m05aLQ/Npot63SkfLrJZN5Goh3Tmq/ANt1vFan2FzdaH9fNr5uf7qVTmqFadNBou4YuwSK0WQKlUVonH/KTTAaq1HMl0mNJunHojw04hwv7+lhwpcnCQlQRFqUuSLsXvPznRbZFMhUSTk0CbsnANJZ9fIZHYIJkMUCzFSaV/ScKwmOJkMiFy+QiFQoxsLszOTkw0CUkdZm8vSbm8RX47ym45LQeD7B9s8hcCBcNXc4vukgAAAABJRU5ErkJggg=='); background-size: cover; display: block;\"\n  ></span>\n  <picture>\n          <source\n              srcset=\"/static/cb0e0cb96c6948928636e233cb8f0826/8ac56/image-20220304212900959.webp 240w,\n/static/cb0e0cb96c6948928636e233cb8f0826/d3be9/image-20220304212900959.webp 480w,\n/static/cb0e0cb96c6948928636e233cb8f0826/87ca7/image-20220304212900959.webp 730w\"\n              sizes=\"(max-width: 730px) 100vw, 730px\"\n              type=\"image/webp\"\n            />\n          <source\n            srcset=\"/static/cb0e0cb96c6948928636e233cb8f0826/8ff5a/image-20220304212900959.png 240w,\n/static/cb0e0cb96c6948928636e233cb8f0826/e85cb/image-20220304212900959.png 480w,\n/static/cb0e0cb96c6948928636e233cb8f0826/e9beb/image-20220304212900959.png 730w\"\n            sizes=\"(max-width: 730px) 100vw, 730px\"\n            type=\"image/png\"\n          />\n          <img\n            class=\"gatsby-resp-image-image\"\n            src=\"/static/cb0e0cb96c6948928636e233cb8f0826/e9beb/image-20220304212900959.png\"\n            alt=\"image-20220304212900959\"\n            title=\"image-20220304212900959\"\n            loading=\"lazy\"\n            style=\"width:100%;height:100%;margin:0;vertical-align:middle;position:absolute;top:0;left:0;\"\n          />\n        </picture>\n  </a>\n    </span></p>\n<p>Reference: <a href=\"https://www.cman.jp/network/support/go_access.cgi\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Access Information [Check Your Current IP Address]</a></p>\n<p>This time I set it up in the Japan East region, but if you follow the same steps and use a machine in an overseas region as the proxy, you might be able to connect using a foreign IP address as well.</p>\n<p>The steps are simple, so this is pretty useful.</p>","fields":{"slug":"/azure-vpn-setup-en","tagSlugs":["/tag/security-en/","/tag/azure-en/","/tag/備忘録/","/tag/english/"]},"frontmatter":{"date":"2022-03-04","description":"","tags":["Security (en)","Azure (en)","備忘録","English"],"title":"Notes on connecting to Azure over VPN with a virtual network gateway and building a cloud-proxy-like environment","socialImage":{"publicURL":"/static/8bdcaa17f32134944fca438991248aac/azure-vpn-setup.png"}}}},"pageContext":{"slug":"/azure-vpn-setup-en"}},"staticQueryHashes":["251939775","401334301","825871152"]}