meta data for this page
Diferenças
Aqui você vê as diferenças entre duas revisões dessa página.
Ambos lados da revisão anterior Revisão anterior Próxima revisão | Revisão anterior Próxima revisão Ambos lados da revisão seguinte | ||
integracao_mikrotik [2019/01/08 09:30] raylan |
integracao_mikrotik [2020/02/01 16:30] djol |
||
---|---|---|---|
Linha 3: | Linha 3: | ||
<note important> | <note important> | ||
Substitua as seguintes variáveis nos comandos abaixo de acordo com sua configuração: | Substitua as seguintes variáveis nos comandos abaixo de acordo com sua configuração: | ||
- | * **IP_DO_SGP** - IP que o SGP usará para conectar-se ao MikroTik. Se estiver utilizando VPN do SGP, verifique a configuração de VPN com o suporte do SGP. | + | * **IP** - IP que o SGP que o SGP responde (privado ou publico) |
- | * **PORTA_BLOQUEIO** - Porta em que a página de bloqueio será exibida. Consulte a [[tabela_variaveis|tabela de variáveis]]. | + | * **BLQ** - Porta em que a página de bloqueio será exibida. Consulte a [[tabela_variaveis|tabela de variáveis]]. |
- | * **PORTA_BLOQUEIO_AVISO** - Porta em que a página de aviso de bloqueio será exibida. Consulte a [[tabela_variaveis|tabela de variáveis]]. | + | * **AVS** - Porta em que a página de aviso de bloqueio será exibida. Consulte a [[tabela_variaveis|tabela de variáveis]]. |
- | * **PASSWORD_USUARIO_SGP** - Password que o SGP Utilizará para acessar o NAS. Recomendamos que seja gerada por mecanismos de geração de password com um tamanho minimo de 15 caracteres. Armazene essa senha em um local seguro, ela será necessária para configurar o SGP. | + | * **PASSVPNUSER** - Password que o SGP Utilizará para acessar o NAS. Recomendamos que seja gerada (se usar VPN usa-se a mesma senha) por mecanismos de geração de password com um tamanho minimo de 15 caracteres. Armazene essa senha em um local seguro, ela será necessária para configurar o SGP. No Linux, é possível criar a senha com o comando **openssl rand - -hex 15**. |
</note> | </note> | ||
Linha 14: | Linha 14: | ||
<code> | <code> | ||
+ | :global USERVPN "USUÁRIO_DA_VPN" | ||
+ | /export file=BACKUP_ANTES_DO_SGP | ||
+ | :global PASSVPNUSER "SENHA_DA_VPN_E_USUÁRIO" | ||
+ | :global AUC "1812" | ||
+ | :global ACC "1813" | ||
+ | :global RADIUS "IP_DO_RADIUS" | ||
+ | :global TOKENAQUI "TOKEN_GERADO_NO_SGP" | ||
+ | :global LINKDOSGP "URL_DO_SGP" | ||
+ | :global IP "IP_DA_URL" | ||
+ | :global AVS "6402" | ||
+ | :global BLQ "6003" | ||
+ | /ip firewall address-list | ||
+ | add address=$IP list=SITES-LIBERADOS | ||
+ | add address=208.67.222.222 list=SITES-LIBERADOS | ||
+ | add address=208.67.222.220 list=SITES-LIBERADOS | ||
+ | add address=8.8.8.8 list=SITES-LIBERADOS | ||
+ | add address=8.8.4.4 list=SITES-LIBERADOS | ||
+ | add address=1.1.1.1 list=SITES-LIBERADOS | ||
+ | add address=45.227.76.22 list=SITES-LIBERADOS | ||
+ | add address=45.227.79.1 list=SITES-LIBERADOS | ||
+ | add address=10.24.0.0/22 list=BLOQUEADOS | ||
+ | /ip firewall filter | ||
+ | add action=drop chain=forward dst-address-list=!SITES-LIBERADOS src-address-list=BLOQUEADOS comment="SGP REGRAS" | ||
+ | /ip firewall filter | ||
+ | add chain=forward connection-mark=BLOQUEIO-AVISAR action=add-src-to-address-list \ | ||
+ | address-list=BLOQUEIO-AVISADOS address-list-timeout=2h comment="SGP REGRAS" dst-address=$IP dst-port=$AVS protocol=tcp | ||
+ | /ip firewall nat | ||
+ | add action=accept chain=srcnat comment="NAO FAZER NAT PARA O IP DO RADIUS" \ | ||
+ | dst-address=$RADIUS dst-port="$AUC-$ACC,3799" protocol=udp | ||
+ | add action=masquerade chain=srcnat comment="SGP REGRAS" src-address-list=\ | ||
+ | BLOQUEADOS | ||
+ | add action=dst-nat chain=dstnat comment="SGP REGRAS" dst-address-list=\ | ||
+ | !SITES-LIBERADOS dst-port=80,443 log-prefix="" protocol=tcp \ | ||
+ | src-address-list=BLOQUEADOS to-addresses=$IP to-ports=$BLQ | ||
+ | add action=dst-nat chain=dstnat comment="SGP REGRAS" connection-mark=\ | ||
+ | BLOQUEIO-AVISAR log-prefix="" protocol=tcp to-addresses=$IP to-ports=$AVS | ||
+ | # Aviso bloqueio | ||
+ | /ip firewall mangle | ||
+ | add chain=prerouting connection-state=new src-address-list=BLOQUEIO-AVISAR protocol=tcp dst-port=80 \ | ||
+ | action=mark-connection new-connection-mark=BLOQUEIO-VERIFICAR passthrough=yes comment="SGP REGRAS" | ||
+ | add chain=prerouting connection-mark=BLOQUEIO-VERIFICAR src-address-list=!BLOQUEIO-AVISADOS \ | ||
+ | action=mark-connection new-connection-mark=BLOQUEIO-AVISAR comment="SGP REGRAS" | ||
+ | /system scheduler | ||
+ | add interval=1h name=sgp-aviso on-event=sgp-aviso policy=\ | ||
+ | ftp,reboot,read,write,policy,test,password,sniff,sensitive start-date=\ | ||
+ | may/29/2017 start-time=01:00:00 | ||
+ | /system script | ||
+ | add name=sgp-aviso policy=\ | ||
+ | ftp,reboot,read,write,policy,test,password,sniff,sensitive source=":log info\ | ||
+ | \_\"sgp aviso\";\r\ | ||
+ | \n/file remove [find where name=sgp_aviso.rsc]\r\ | ||
+ | \n/tool fetch url=\"$LINKDOSGP/ws/mikrotik/aviso/pendencia/\?token=$TOKENAQUI&app=mikrotik\" dst-path=sgp_aviso.rsc;\r\ | ||
+ | \n:delay 30s\r\ | ||
+ | \nimport file-name=sgp_aviso.rsc;" | ||
+ | /ip accounting set account-local-traffic=yes enabled=yes | ||
+ | /system ntp client set enabled=yes primary-ntp=200.160.0.8 | ||
+ | /system clock set time-zone-name=America/Recife | ||
/radius incoming set accept=yes | /radius incoming set accept=yes | ||
- | + | /ip service | |
- | /ip service set api address=IP_DO_SGP disabled=no port=3540 | + | set api disabled=no port=3540 |
- | /user add name=SGP group=full address=IP_DO_SGP comment="USUARIO QUE O SGP UTILIZA PARA LOGAR NA RB" password=PASSWORD_USUARIO_SGP | + | set www disabled=no port=8008 |
/user aaa set use-radius=yes | /user aaa set use-radius=yes | ||
/ppp aaa set interim-update=5m use-radius=yes | /ppp aaa set interim-update=5m use-radius=yes | ||
+ | /interface pppoe-server server set authentication=pap [ find where .id!=999] | ||
+ | /interface pppoe-server server set one-session-per-host=no [find .id!=999] | ||
/tool graphing set page-refresh=300 store-every=5min | /tool graphing set page-refresh=300 store-every=5min | ||
/tool graphing interface add allow-address=0.0.0.0/0 disabled=no interface=all store-on-disk=yes | /tool graphing interface add allow-address=0.0.0.0/0 disabled=no interface=all store-on-disk=yes | ||
/tool graphing queue add allow-address=0.0.0.0/0 allow-target=yes disabled=no simple-queue=all store-on-disk=yes | /tool graphing queue add allow-address=0.0.0.0/0 allow-target=yes disabled=no simple-queue=all store-on-disk=yes | ||
/tool graphing resource add allow-address=0.0.0.0/0 disabled=no store-on-disk=yes | /tool graphing resource add allow-address=0.0.0.0/0 disabled=no store-on-disk=yes | ||
+ | /snmp community add addresses=$RADIUS name=SGP-GRAPHICs | ||
+ | /snmp set enabled=yes trap-community=SGP-GRAPHICs trap-version=2 | ||
+ | /system logging set 0 action=memory disabled=no prefix="" topics=info,!account | ||
+ | /radius | ||
+ | add comment="RADIUS SGP" secret=sgp@radius service=ppp,dhcp,login address=$RADIUS accounting-port=$ACC authentication-port=$AUC \ | ||
+ | timeout=00:00:03 | ||
+ | /user add name=SGP comment="USUARIO QUE O SERVIDOR SGP ACESSA A RB" group=full password=$PASSVPNUSER | ||
+ | |||
- | /ip firewall address-list add address=IP_DO_SGP list=SITES-LIBERADOS | + | /interface pptp-client |
- | /ip firewall address-list add address=208.67.222.222 list=SITES-LIBERADOS | + | add connect-to=$IP user=$USERVPN password=$PASSVPNUSER profile=default-encryption name="VPN-SGP"\ |
- | /ip firewall address-list add address=208.67.222.220 list=SITES-LIBERADOS | + | disabled=no |
- | /ip firewall address-list add address=8.8.8.8 list=SITES-LIBERADOS | + | |
- | /ip firewall address-list add address=8.8.4.4 list=SITES-LIBERADOS | + | |
- | /ip firewall address-list add address=1.1.1.1 list=SITES-LIBERADOS | + | |
- | /ip firewall address-list add address=172.16.100.2 list=SITES-LIBERADOS | + | |
- | /ip firewall address-list add address=172.16.150.2 list=SITES-LIBERADOS | + | |
- | /ip firewall address-list add address=10.24.0.0/22 list=BLOQUEADOS | + | |
- | /ip firewall filter add action=drop chain=forward dst-address-list=!SITES-LIBERADOS src-address-list=BLOQUEADOS comment="SGP REGRAS" | + | /interface ovpn-client |
- | /ip firewall filter add chain=forward connection-mark=BLOQUEIO-AVISAR action=add-src-to-address-list address-list=BLOQUEIO-AVISADOS address-list-timeout=2h comment="SGP REGRAS" dst-address=IP_DO_SGP dst-port=PORTA_BLOQUEIO_AVISO protocol=tcp | + | add connect-to=$IP user=$USERVPN password=$PASSVPNUSER profile=default-encryption name="OVPN-SGP"\ |
+ | disabled=no | ||
- | /ip firewall nat add action=masquerade chain=srcnat comment="SGP REGRAS" src-address-list=BLOQUEADOS | ||
- | /ip firewall nat add action=dst-nat chain=dstnat comment="SGP REGRAS" dst-address-list=!SITES-LIBERADOS dst-port=80,443 log-prefix="" protocol=tcp src-address-list=BLOQUEADOS to-addresses=IP_DO_SGP to-ports=PORTA_BLOQUEIO | ||
- | /ip firewall nat add action=dst-nat chain=dstnat comment="SGP REGRAS" connection-mark=BLOQUEIO-AVISAR log-prefix="" protocol=tcp to-addresses=IP_DO_SGP to-ports=PORTA_BLOQUEIO_AVISO | ||
- | /ip firewall mangle add chain=prerouting connection-state=new src-address-list=BLOQUEIO-AVISAR protocol=tcp dst-port=80 action=mark-connection new-connection-mark=BLOQUEIO-VERIFICAR passthrough=yes comment="SGP REGRAS" | ||
- | /ip firewall mangle add chain=prerouting connection-mark=BLOQUEIO-VERIFICAR src-address-list=!BLOQUEIO-AVISADOS action=mark-connection new-connection-mark=BLOQUEIO-AVISAR comment="SGP REGRAS" | ||
</code> | </code> | ||
Linha 59: | Linha 114: | ||
Se tudo deu certo, a seguinte página irá ser exibida. Caso contrário, verifique os passos novamente e contate a central de atendimentos. | Se tudo deu certo, a seguinte página irá ser exibida. Caso contrário, verifique os passos novamente e contate a central de atendimentos. | ||
- | FIXME |