{"id":1116,"date":"2019-07-11T12:00:00","date_gmt":"2019-07-11T15:00:00","guid":{"rendered":"http:\/\/www.bfnetworks.com.br\/?p=1116"},"modified":"2022-07-15T10:18:04","modified_gmt":"2022-07-15T13:18:04","slug":"vpn-server-l2tp-ipsec-edgerouter","status":"publish","type":"post","link":"https:\/\/bfnetworks.com.br\/vpn-server-l2tp-ipsec-edgerouter\/","title":{"rendered":"VPN SERVER L2TP\/IPsec PSK – EdgeRouter"},"content":{"rendered":"\n

CEN\u00c1RIO<\/h3>\n\n\n

Neste cen\u00e1rio a configura\u00e7\u00e3o foi Client-to-site, foi usado 1 edgerouter para ser o server vpn com 1 windows para client vpn para se conectar. A WAN da edgerouter era a interface eth0, e era roteada por um modem de internet, nele havia uma DMZ para a edgerouter.<\/p>\n\n\n

EdgeRouter X SFP 6-Port
Version EdgeOS v1.10.7<\/pre>\n\n\n
OS Client VPN: Windows 10, 8<\/pre>\n\n\n

Verifique a vers\u00e3o do seu EdgeOS com o comando: <\/p>\n\n\n

\n
show version<\/div> <\/div>\n\n\n

ENTRANDO NO MODO DE CONFIGURA\u00c7\u00c3O<\/h3>\n\n\n

Acesse via SSH a edgerouter e vamos iniciar a configura\u00e7\u00e3o entrando no modo de configura\u00e7\u00e3o:<\/p>\n\n\n

\n
configure<\/div> <\/div>\n\n\n

REGRAS DE FIREWALL<\/h3>\n\n\n

Liberando IKE com porta 500 UDP:<\/p>\n\n\n

\n
set firewall name WAN_LOCAL rule 30 action accept<\/div>
set firewall name WAN_LOCAL rule 30 description ike<\/div>
set firewall name WAN_LOCAL rule 30 destination port 500<\/div>
set firewall name WAN_LOCAL rule 30 log disable<\/div>
set firewall name WAN_LOCAL rule 30 protocol udp<\/div> <\/div>\n\n\n

Liberando protocolo ESP:<\/p>\n\n\n

\n
set firewall name WAN_LOCAL rule 40 action accept<\/div>
set firewall name WAN_LOCAL rule 40 description esp<\/div>
set firewall name WAN_LOCAL rule 40 log disable<\/div>
set firewall name WAN_LOCAL rule 40 protocol esp<\/div> <\/div>\n\n\n

Liberando porta 4500 com UDP:<\/p>\n\n\n

\n
set firewall name WAN_LOCAL rule 50 action accept<\/div>
set firewall name WAN_LOCAL rule 50 description nat-t<\/div>
set firewall name WAN_LOCAL rule 50 destination port 4500<\/div>
set firewall name WAN_LOCAL rule 50 log disable<\/div>
set firewall name WAN_LOCAL rule 50 protocol udp<\/div> <\/div>\n\n\n

Liberando L2TP com porta 1701 e IPsec:<\/p>\n\n\n

\n
set firewall name WAN_LOCAL rule 60 action accept<\/div>
set firewall name WAN_LOCAL rule 60 description l2tp<\/div>
set firewall name WAN_LOCAL rule 60 destination port 1701<\/div>
set firewall name WAN_LOCAL rule 60 ipsec match-ipsec<\/div>
set firewall name WAN_LOCAL rule 60 log disable<\/div>
set firewall name WAN_LOCAL rule 60 protocol udp<\/div> <\/div>\n\n\n

CONFIGURANDO AUTENTICA\u00c7\u00c3O LOCAL<\/h4>\n\n\n

Abaixo ativamos o modo de autentica\u00e7\u00e3o do IPsec por PSK e definimos a chave no segundo comando, no exemplo foi usado “SuaChavePSK<\/strong>” troque isso por sua chave:<\/p>\n\n\n

\n
set vpn l2tp remote-access ipsec-settings authentication mode pre-shared-secret<\/div>
set vpn l2tp remote-access ipsec-settings authentication pre-shared-secret SuaChavePSK<\/div> <\/div>\n\n\n

A seguir definimos a autentica\u00e7\u00e3o no modo local (poderia ser por outro tipo exemplo RADIUS), no segundo comando defina um usu\u00e1rio(aqui chamado de gabriel<\/strong>) e senha, altere o campo “SenhaUser<\/strong>“<\/p>\n\n\n

\n
set vpn l2tp remote-access authentication mode local<\/div>
set vpn l2tp remote-access authentication local-users username gabriel password “SenhaUser”<\/div> <\/div>\n\n\n

DEFINIR FAIXA DE ENDERE\u00c7O IP QUE CLIENTES IR\u00c3O OBTER<\/h4>\n\n\n
\n
set vpn l2tp remote-access client-ip-pool start 172.16.0.100<\/div>
set vpn l2tp remote-access client-ip-pool stop 172.16.0.200<\/div> <\/div>\n\n\n

DEFINIR DNS DOS CLIENTES<\/h4>\n\n\n
\n
set vpn l2tp remote-access dns-servers server-1 208.67.222.222<\/div>
set vpn l2tp remote-access dns-servers server-2 208.67.220.220<\/div> <\/div>\n\n\n

DEFINIR INTERFACE RECEBER\u00c1 REQUISI\u00c7\u00d5ES DA VPN<\/h4>\n\n\n

CUIDADO<\/strong>, aqui dever\u00e1 ser executa um dos 3 comando abaixo, apenas 1 deles, pois o primeiro \u00e9 caso receba o link de internet atrav\u00e9s de um dhcp, o segundo comando \u00e9 caso use IP static, o terceiro receba atrav\u00e9s de PPPoE:<\/p>\n\n\n

\n
(WAN via DHCP) # set vpn l2tp remote-access dhcp-interface eth0<\/div>
(WAN STATIC IP) # set vpn l2tp remote-access outside-address<\/div>
(WAN via PPPoE) # set vpn l2tp remote-access outside-address 0.0.0.0<\/div> <\/div>\n\n\n

Para qualquer um dos casos acima, defina a interface que receber\u00e1 requisi\u00e7\u00f5es com o comando abaixo, no exemplo foi usado eth0:<\/p>\n\n\n

\n
set vpn ipsec ipsec-interfaces interface eth0<\/div> <\/div>\n\n\n

SALVANDO CONFIGURA\u00c7\u00d5ES<\/h4>\n\n\n
\n
commit ; save<\/div> <\/div>\n\n\n

CONFIGURA\u00c7\u00c3O CLIENT WINDOWS<\/h4>\n\n\n

No Windows a configura\u00e7\u00e3o \u00e9 bem simples, pode acompanhar este link <\/a>para configura\u00e7\u00e3o.<\/p>\n\n\n

Apenas um ajuste do registro do Windows foi preciso para que ele pudesse suportar a VPN com PSK. Abaixo execute o comando no cmd como administrador e depois reinicie a esta\u00e7\u00e3o:<\/p>\n\n\n

REG ADD HKLM\\SYSTEM\\CurrentControlSet\\Services\\PolicyAgent \/v AssumeUDPEncapsulationContextOnSendRule \/t REG_DWORD \/d 0x2 \/f<\/pre>\n\n\n

FONTES<\/h4>\n\n\n

https:\/\/help.ubnt.com\/hc\/en-us\/articles\/115005445768-UniFi-USG-Configuring-L2TP-Remote-Access-VPN<\/a><\/p>\n\n\n

https:\/\/help.ubnt.com\/hc\/en-us\/articles\/204950294-EdgeRouter-L2TP-IPsec-VPN-Server<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

CEN\u00c1RIO Neste cen\u00e1rio a configura\u00e7\u00e3o foi Client-to-site, foi usado 1 edgerouter para ser o server vpn com 1 windows para client vpn para se conectar. A WAN da edgerouter era a interface eth0, e era roteada por um modem de internet, nele havia uma DMZ para a edgerouter. EdgeRouter X SFP 6-PortVersion EdgeOS v1.10.7 OS […]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,8],"tags":[55,72,77,142,151],"_links":{"self":[{"href":"https:\/\/bfnetworks.com.br\/wp-json\/wp\/v2\/posts\/1116"}],"collection":[{"href":"https:\/\/bfnetworks.com.br\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bfnetworks.com.br\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bfnetworks.com.br\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bfnetworks.com.br\/wp-json\/wp\/v2\/comments?post=1116"}],"version-history":[{"count":1,"href":"https:\/\/bfnetworks.com.br\/wp-json\/wp\/v2\/posts\/1116\/revisions"}],"predecessor-version":[{"id":1856,"href":"https:\/\/bfnetworks.com.br\/wp-json\/wp\/v2\/posts\/1116\/revisions\/1856"}],"wp:attachment":[{"href":"https:\/\/bfnetworks.com.br\/wp-json\/wp\/v2\/media?parent=1116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bfnetworks.com.br\/wp-json\/wp\/v2\/categories?post=1116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bfnetworks.com.br\/wp-json\/wp\/v2\/tags?post=1116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}