{"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
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\nOS Client VPN: Windows 10, 8<\/pre>\n\n\nVerifique a vers\u00e3o do seu EdgeOS com o comando: <\/p>\n\n\n
\nshow version<\/div> <\/div>\n\n\nENTRANDO 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
\nconfigure<\/div> <\/div>\n\n\nREGRAS DE FIREWALL<\/h3>\n\n\n
Liberando IKE com porta 500 UDP:<\/p>\n\n\n
\nset 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\nLiberando protocolo ESP:<\/p>\n\n\n
\nset 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\nLiberando porta 4500 com UDP:<\/p>\n\n\n
\nset 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\nLiberando L2TP com porta 1701 e IPsec:<\/p>\n\n\n
\nset 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\nCONFIGURANDO 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
\nset 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\nA 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
\nset vpn l2tp remote-access authentication mode local<\/div>set vpn l2tp remote-access authentication local-users username gabriel password “SenhaUser”<\/div> <\/div>\n\n\nDEFINIR FAIXA DE ENDERE\u00c7O IP QUE CLIENTES IR\u00c3O OBTER<\/h4>\n\n\n
\nset 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\nDEFINIR DNS DOS CLIENTES<\/h4>\n\n\n
\nset 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\nDEFINIR 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\nPara 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
\nset vpn ipsec ipsec-interfaces interface eth0<\/div> <\/div>\n\n\nSALVANDO CONFIGURA\u00c7\u00d5ES<\/h4>\n\n\n
\ncommit ; save<\/div> <\/div>\n\n\nCONFIGURA\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\nFONTES<\/h4>\n\n\n