Escolar Documentos
Profissional Documentos
Cultura Documentos
GenieACS
PASSO 1:
Instalação do NGINX
mkdir /etc/nginx/ssl
PASSO 2:
Precisamos copiar e colar esse comando no terminal. Gera-se os certificados auto
assinados para possibilitar usar o https.
openssl req -x509 -nodes -days 730 -newkey rsa:2048 -keyout /etc/nginx/ssl/server.key -out
/etc/nginx/ssl/server.crt
PASSO 3:
Natal
GenieACS
GenieACS
localhost
admin@localhost
PASSO 4:
Seguindo esse processo de interação, cria-se um token de acesso.
O Token de acesso pode ser gerado de qualquer forma. Contudo, uma forma fácil de gerar
um token seguro é pelo comando :
cat /proc/sys/kernel/random/uuid
PASSO 5:
Substitui-se o arquivo /etc/nginx/sites-enabled/default .
server {
root /var/www/html;
server_name _;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
location / {
proxy_read_timeout 3600;
proxy_pass_request_headers on;
if (\$http_apikey != "TOKEN_AQUI"){
return 401;
proxy_pass http://localhost:7557/;
EOF
Basta apenas copiar e colar os comandos no terminal com a informação do token gerado no
passo 4.
Por fim:
/etc/init.d/nginx restart
Feito isso, basta bloquear a conexão externa para a porta 7557 e liberar para a 7558 e a api vai
estar com um nível básico de segurança.
2 - Configurando o GenieACS
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.MACAddress",
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Username",
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Uptime",
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.RemoteIPAddress",
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.DefaultGateway",
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANIPConnection.*.ExternalIPAddress",
hourly});
value: hourly});
value: hourly});
value: hourly});
value: hourly});
value: every_ten_minutes});
value: every_ten_minutes});
value: every_ten_minutes});
value: every_ten_minutes});
declare("InternetGatewayDevice.LANDevice.*.Hosts.Host.*.MACAddress", {path:
Na página de configuração GenieCAS, é necessário acessar Admin > Provisions e editar o script
bootstrap com o conteúdo:
/*
*/
return;
"InternetGatewayDevice.WANDevice.1.WANEthernetInterfaceConfig.MACAddress", {value:
1}).value[0];
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.*",
const username =
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Username",
{value: 1} );
username.value[0] ) {
return;
createPPPOEConnection( auth );
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANIPConnection.*.Enable",
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*",
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.*",
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.ConnectionType",
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.*.Enable",
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Password",
declare("InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.PPPAuthenticationP
declare("InternetGatewayDevice.LANDevice.*.WLANConfiguration.1.SSID",{value: now},
{value: auth.wifi_ssid});
declare("InternetGatewayDevice.LANDevice.*.WLANConfiguration.1.PreSharedKey.*.KeyPassphrase",{value:
declare("InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.Channel",{value: now},
{value: auth.wifi_channel});
PASSO 3:
Em seguida, Acessar o servidor do GenieACS via SSH e criar/adicionar o arquivo
/opt/genieacs/ext/sistema com o conteúdo:
#!/usr/bin/env node
return {
hostname: 'demo.sgp.net.br',
port: 443,
path: '/api/ura/consultacliente',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(JSON.stringify(dados)),
},
const dados = {
mac_dhcp: args[0],
"app": "ura",
"token": "1a551977-a459-4743-9a52-e9d1ca46a480"
data += newData
});
response.on('end', function(){
auth = {
username: parsedData.contratos[0].servico_login,
password: parsedData.contratos[0].servico_senha,
wifi_ssid: parsedData.contratos[0].servico_wifi_ssid,
wifi_password:
parsedData.contratos[0].servico_wifi_password,
wifi_channel:
parsedData.contratos[0].servico_wifi_channel,
wifi_ssid_5:
parsedData.contratos[0].servico_wifi_ssid_5,
wifi_password_5:
parsedData.contratos[0].servico_wifi_password_5,
wifi_channel_5:
parsedData.contratos[0].servico_wifi_channel_5,
};
});
});
req.write(JSON.stringify(dados))
req.end()
exports.pppoeLoginByMac = pppoeLoginByMac;
O script acima pode ser substituído pelo abaixo caso o cliente utilize VOIP e queira pegar os
dados do SIP.
(SGP de exemplo nos comentários)
#!/usr/bin/env node
return {
hostname: 'demo.sgp.net.br',
port: 443,
path: '/api/ura/consultacliente',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(JSON.stringify(dados)),
},
const dados = {
mac_dhcp: args[0],
"app": "ura",
"token": "1a551977-a459-4743-9a52-e9d1ca46a480",
"servicos_dados": 1
data += newData
});
response.on('end', function(){
})[0]
auth = {
cpf_cnpj: parsedData.contratos[0].cpfCnpj,
contrato: parsedData.contratos[0].contratoId,
username: parsedData.contratos[0].servico_login,
password: parsedData.contratos[0].servico_senha,
wifi_ssid: parsedData.contratos[0].servico_wifi_ssid,
wifi_password:
parsedData.contratos[0].servico_wifi_password,
wifi_channel:
parsedData.contratos[0].servico_wifi_channel,
wifi_ssid_5:
parsedData.contratos[0].servico_wifi_ssid_5,
wifi_password_5:
parsedData.contratos[0].servico_wifi_password_5,
wifi_channel_5:
parsedData.contratos[0].servico_wifi_channel_5,
sip_url: telefonia?.linhas?.[0]?.dados?.domain,
sip_username: telefonia?.login,
sip_password: telefonia?.password
};
});
});
req.write(JSON.stringify(dados))
req.end()
exports.pppoeLoginByMac = pppoeLoginByMac;
OBS: se o cliente estiver utilizando o GenieACS em docker, utilizar o comando "docker ps" para
buscar o CONTAINER ID e o comando "docker exec -it #CONTAINER-ID /bin/bash" para acessar
o servidor
["InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.1.Username",
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.1.WANPPPConnection.2.Username",
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username",
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.2.Username",
"InternetGatewayDevice.WANDevice.1.WANConnectionDevice.2.WANPPPConnection.1.Username",
"InternetGatewayDevice.WANDevice.2.WANConnectionDevice.1.WANPPPConnection.1.Username",
"InternetGatewayDevice.WANDevice.2.WANConnectionDevice.1.WANPPPConnection.2.Username",
"InternetGatewayDevice.WANDevice.2.WANConnectionDevice.2.WANPPPConnection.1.Username",
"InternetGatewayDevice.WANDevice.2.WANConnectionDevice.2.WANPPPConnection.2.Username"]}
SALVAR
4- Configurar os dados do Roteador
EDITAR O WIFI
Salvar e depois ir na Aba "Gerenciador CPE" e botão "Definir Wifi" para aplicar as alterações e
enviar para o GenieACS.
image-1623676225344.png
Por motivos de segurança, nenhum equipamento envia campos relativos a senha para o
GenieACS. Entretanto, quando o GenieACS envia qualquer desses campos ao equipamento,
ele salva a informação enviada. Por esses motivos acima, atualizar um atributo de senha
(buscando do equipamento) irá fazer a o campo ser apagado do GenieACS.
Revisão #42