{"id":839,"date":"2022-11-13T17:12:20","date_gmt":"2022-11-13T17:12:20","guid":{"rendered":"https:\/\/james-batchelor.com\/?p=839"},"modified":"2022-11-13T17:14:55","modified_gmt":"2022-11-13T17:14:55","slug":"yealink-openvpn-to-draytek-router","status":"publish","type":"post","link":"https:\/\/james-batchelor.com\/index.php\/2022\/11\/13\/yealink-openvpn-to-draytek-router\/","title":{"rendered":"Yealink OpenVPN to Draytek Router"},"content":{"rendered":"\n<p>The firewalls in front of our PBX\u2019s are configured to only allow SIP traffic from UK IP addresses, this reduces the attack surface and is usually not an issue as almost all legitimate traffic is from the UK.<\/p>\n\n\n\n<p>As we expand there is greater need for international connections, this is fine if they have a static WAN IP or FQDN, but the more recent requirements are for \u201chome\u201d users with phones on their residential connections where dynamic IPs are the standard.<\/p>\n\n\n\n<p>Changing the whitelisted IP every time their IP changes is not only tedious, but gives poor service, plus due to recent events (here and here) I\u2019m not prepared to open access to another country for a single extension.<\/p>\n\n\n\n<p>In my case, these internationals are satellites of a UK based office, so the idea is having the overseas phone route all voice traffic through the UK office where its free to connect to the PBX\u2026<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>For this setup, a Yealink T46S will connect to a Draytek 2927 via OpenVPN and crucially, route all traffic destined for the PBX via the VPN to get around the GeoIP block.<\/p>\n\n\n\n<p>This guide should also be compatible with the Draytek 2865, and Yealink T4xS and T4xU series phones.<\/p>\n\n\n\n<p>Notepad++ and 7zip are required.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Draytek Setup<\/h2>\n\n\n\n<p>Original Guide: <a href=\"https:\/\/www.draytek.com\/support\/knowledge-base\/7462\">https:\/\/www.draytek.com\/support\/knowledge-base\/7462<\/a><\/p>\n\n\n\n<p>First create a user for the Yealink, at the router GUI navigate to: <em>VPN and Remote Access &gt;&gt; Remote Dial-in User.<\/em><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn01.png\"><img loading=\"lazy\" decoding=\"async\" width=\"717\" height=\"191\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn01.png\" alt=\"\" class=\"wp-image-843\"\/><\/a><\/figure><\/div>\n\n\n<p>Click an Index number and make the following changes:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Enable this account: <strong>On<\/strong><\/li>\n\n\n\n<li>Allowed Dail-In Type: OpenVPN Tunnel: <strong>On<\/strong><\/li>\n\n\n\n<li>Username: <strong>Enter a username<\/strong><\/li>\n\n\n\n<li>Password: <strong>Enter a password<\/strong><\/li>\n<\/ul>\n\n\n\n<p>It should look like this:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn02.png\"><img loading=\"lazy\" decoding=\"async\" width=\"766\" height=\"627\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn02.png\" alt=\"\" class=\"wp-image-844\"\/><\/a><\/figure><\/div>\n\n\n<p>Next is to setup the Draytek to accept OpenVPN connections.<\/p>\n\n\n\n<p>Navigate to <em>VPN and Remote Access  &gt;&gt; Remote Access Control<\/em>. And check OpenVPN is enabled.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn03.png\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"207\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn03.png\" alt=\"\" class=\"wp-image-845\"\/><\/a><\/figure><\/div>\n\n\n<p>Then navigate to <em>VPN and Remote Access &gt;&gt; OpenVPN &gt;&gt; OpenVPN Server Setup<\/em>.<\/p>\n\n\n\n<p>In the General Certificates section, select Router Generated Certificates, and then press generate.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn04.png\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"690\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn04.png\" alt=\"\" class=\"wp-image-846\"\/><\/a><\/figure><\/div>\n\n\n<p>After some time, the generated certificates appear in this section:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn05.png\"><img loading=\"lazy\" decoding=\"async\" width=\"474\" height=\"122\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn05.png\" alt=\"\" class=\"wp-image-847\"\/><\/a><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">OpenVPN Setup<\/h2>\n\n\n\n<p>The Draytek has the ability to create an OpenVPN config file for clients. However, what the Draytek generates and what the Yealink requires is not compatible. Therefore, we\u2019ll need to manipulate the file to file to get what we want.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Extracting Certificates<\/h3>\n\n\n\n<p>On the Draytek, navigate to <em>Remote Access &gt;&gt; OpenVPN &gt;&gt; Client Config<\/em>.<\/p>\n\n\n\n<p>Leaving defaults in place, enter a filename and click the Export button to download the config file.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn06.png\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"678\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn06.png\" alt=\"\" class=\"wp-image-848\"\/><\/a><\/figure><\/div>\n\n\n<p>Open the file in Notepad++.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn07.png\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"468\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn07.png\" alt=\"\" class=\"wp-image-849\"\/><\/a><\/figure><\/div>\n\n\n<p>You\u2019ll see the protocol config at start of file, followed by each of the certificates in the following order:<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\">\n<li>CA<\/li>\n\n\n\n<li>Client<\/li>\n\n\n\n<li>Private Key<\/li>\n<\/ol>\n\n\n\n<p>The Yealink requires the certificates in their own file so they need to be extracted.<\/p>\n\n\n\n<p>Copy the text from <em>&#8212;&#8211;BEGIN CERTIFICATE&#8212;&#8211;<\/em> to <em>&#8212;&#8211;END CERTIFICATE&#8212;&#8211;<\/em> of the first certificate and paste into a new Notepad++ file.<\/p>\n\n\n\n<p>Save this file as <strong>ca.crt<\/strong> (remove the txt file extension)<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn08.png\"><img loading=\"lazy\" decoding=\"async\" width=\"600\" height=\"377\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn08.png\" alt=\"\" class=\"wp-image-850\"\/><\/a><\/figure><\/div>\n\n\n<p>Repeat this for the second certificate, naming this one <strong>client.crt<\/strong><\/p>\n\n\n\n<p>Now it\u2019s the private key, copy text from <em>&#8212;&#8211;BEGIN RSA PRIVATE KEY&#8212;&#8211;<\/em> to <em>&#8212;&#8211;END RSA PRIVATE KEY&#8212;&#8211;<\/em> to a new file and save as <strong>client.key<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Config files<\/h3>\n\n\n\n<p>For the next file, you\u2019ll need to add the Draytek VPN user details as a file to allow the Yealink to authenticate.<\/p>\n\n\n\n<p>In a new text file, enter the username and password on separate lines as below:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn09.png\"><img loading=\"lazy\" decoding=\"async\" width=\"200\" height=\"78\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn09.png\" alt=\"\" class=\"wp-image-851\"\/><\/a><\/figure><\/div>\n\n\n<p>Save the file as <strong>auth.txt<\/strong><\/p>\n\n\n\n<p>You\u2019ll now have the following files:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn10.png\"><img loading=\"lazy\" decoding=\"async\" width=\"155\" height=\"148\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn10.png\" alt=\"\" class=\"wp-image-852\"\/><\/a><\/figure><\/div>\n\n\n<p>With the supporting files ready, it\u2019s time to reference them together with the OpenVPN config file.<\/p>\n\n\n\n<p>In a new text file, enter the following info:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>client\ndev tun\nproto udp\nremote nnn.nnn.nnn.nnn 1194                  # IP address of Draytek\nauth sha256\ncipher aes-256-cbc\nresolv-retry infinite                        # Reconnect if dropped\nnobind\n\nca \/config\/openvpn\/keys\/ca.crt\ncert \/config\/openvpn\/keys\/client.crt\nkey \/config\/openvpn\/keys\/client.key\n\nauth-user-pass \/config\/openvpn\/keys\/auth.txt\n\npersist-key\npersist-tun\n\nroute nnn.nnn.nnn.nnn 255.nnn.nnn.nnn nnn.nnn.nnn.nnn  # Static route:\n                                                       # PBX IP\n                                                       # IP Subnet\n                                                       # Draytek LAN Gateway\nverb 5<\/code><\/pre>\n\n\n\n<p>Save this as <strong>vpn.cnf<\/strong><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Preparing Yealink File<\/h3>\n\n\n\n<p>Original Guide: <a href=\"https:\/\/support.yealink.com\/forward2download?path=ZIjHOJbWuW\/DFrGTLnGypjZRKhDplusSymbolXJQ4JaUSvKXmAoZw0rMev5uUPSPDoclfqojerLoiDU\/Ol0NW5DZdXcWplusSymbolZDNbde0dvqwZjDVChAjsaqHDjPW14991UaBvXhQ10P6Rm4u3tO4pNBqXRzzyvj9PbA==\">https:\/\/support.yealink.com\/forward2download?path=ZIjHOJbWuW\/DFrGTLnGypjZRKhDplusSymbolXJQ4JaUSvKXmAoZw0rMev5uUPSPDoclfqojerLoiDU\/Ol0NW5DZdXcWplusSymbolZDNbde0dvqwZjDVChAjsaqHDjPW14991UaBvXhQ10P6Rm4u3tO4pNBqXRzzyvj9PbA==<\/a><\/p>\n\n\n\n<p>The OpenVPN configuration is uploaded to the Yealink via a specifically arranged tar file, so the directory structure needs to be prepared.<\/p>\n\n\n\n<p>On your desktop, create a new folder (named anything you like) and within this folder create another named \u201ckeys\u201d<\/p>\n\n\n\n<p>Move vpn.cnf to the upper folder, and move auth.txt, ca.crt, client.crt and client.key to keys directory.<\/p>\n\n\n\n<p>Open 7-Zip and navigate to the newly created folder:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn11.png\"><img loading=\"lazy\" decoding=\"async\" width=\"558\" height=\"219\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn11.png\" alt=\"\" class=\"wp-image-853\"\/><\/a><\/figure><\/div>\n\n\n<p>Highlight vpn.cnf and keys, right click and choose <em>7-Zip &gt;&gt; add to archive<\/em>.<\/p>\n\n\n\n<p>Ensure the following is set:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Archive format: <strong>tar<\/strong><\/li>\n\n\n\n<li>Compression level: <strong>Store<\/strong><\/li>\n\n\n\n<li><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn12.png\"><img loading=\"lazy\" decoding=\"async\" width=\"628\" height=\"630\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn12.png\" alt=\"\" class=\"wp-image-854\"\/><\/a><\/figure><\/div>\n\n\n<p>Click OK to create the file. The tar file is created in the directory and it\u2019s ready to be uploaded to the Yealink<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Yealink Setup<\/h2>\n\n\n\n<p>On the phone, press the OK key to discover it\u2019s IP address, then navigate to it\u2019s Web interface via a browser on your computer.<\/p>\n\n\n\n<p>Login, then move to <em>Network &gt;&gt; Advanced<\/em> and scroll down to the VPN section.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn13.png\"><img loading=\"lazy\" decoding=\"async\" width=\"531\" height=\"439\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn13.png\" alt=\"\" class=\"wp-image-855\"\/><\/a><\/figure><\/div>\n\n\n<p>Set Active to <strong>Enabled<\/strong> and set Mode to <strong>OpenVPN<\/strong><\/p>\n\n\n\n<p>Click browse next to <em>Upload VPN Config<\/em> and choose the created tar file.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn14.png\"><img loading=\"lazy\" decoding=\"async\" width=\"534\" height=\"437\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn14.png\" alt=\"\" class=\"wp-image-856\"\/><\/a><\/figure><\/div>\n\n\n<p>Click <strong>Upload<\/strong>, the page will refresh and now Upload VPN Config is populated with vpn.cnf<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn15.png\"><img loading=\"lazy\" decoding=\"async\" width=\"546\" height=\"431\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn15.png\" alt=\"\" class=\"wp-image-857\"\/><\/a><\/figure><\/div>\n\n\n<p>Click Save at the bottom of the page.<\/p>\n\n\n\n<p>OpenVPN will be set back to Disabled, scroll down and <strong>Enable<\/strong> it again, then click <strong>Save<\/strong>.<\/p>\n\n\n\n<p>As there\u2019s a network change pending, you\u2019ll need to click apply at the warning message:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn16.png\"><img loading=\"lazy\" decoding=\"async\" width=\"619\" height=\"89\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn16.png\" alt=\"\" class=\"wp-image-858\"\/><\/a><\/figure><\/div>\n\n\n<p>It\u2019ll now connect to the VPN.<\/p>\n\n\n\n<p>Note: If you are configuring a phone remotely, the web page will stop responding as traffic is now passing through the VPN. To get back to the interface, check the Draytek for the VPN connection (<em>VPN and Remote Access &gt;&gt; Connection Management<\/em>) to discover it\u2019s local IP:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><a href=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn17.png\"><img loading=\"lazy\" decoding=\"async\" width=\"796\" height=\"49\" src=\"https:\/\/james-batchelor.com\/wp-content\/uploads\/2022\/11\/yovpn17.png\" alt=\"\" class=\"wp-image-859\"\/><\/a><\/figure><\/div>\n\n\n<p>The phone is now connected and routing traffic via the VPN.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The firewalls in front of our PBX\u2019s are configured to only allow SIP traffic from UK IP addresses, this reduces the attack surface and is usually not an issue as almost all legitimate traffic is from the UK. As we expand there is greater need for international connections, this is fine if they have a &hellip; <a href=\"https:\/\/james-batchelor.com\/index.php\/2022\/11\/13\/yealink-openvpn-to-draytek-router\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Yealink OpenVPN to Draytek Router&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[212,247],"tags":[293,351,352,353,276,355,354,114,249],"class_list":["post-839","post","type-post","status-publish","format-standard","hentry","category-network","category-voip","tag-draytek","tag-draytek-2927","tag-draytek-2927ac","tag-openvpn","tag-pbx","tag-routing","tag-static-routing","tag-vpn","tag-yealink"],"_links":{"self":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/comments?post=839"}],"version-history":[{"count":4,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/839\/revisions"}],"predecessor-version":[{"id":862,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/posts\/839\/revisions\/862"}],"wp:attachment":[{"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/media?parent=839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/categories?post=839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/james-batchelor.com\/index.php\/wp-json\/wp\/v2\/tags?post=839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}