Configurações de Rede

Obter Configurações de Rede

Por meio da chamada abaixo é possível obter as configurações de rede.

Requisição - GET

http://192.168.1.201/cgi-bin/configManager.cgi?action=getConfig&name=General

paramtypedescription
getConfig *StringComando para obter
General *String

Exemplo de Retorno - text/plain

table.Network.DefaultInterface=eth0
table.Network.Domain=intelbras
table.Network.Hostname=BSC
table.Network.eth0.DefaultGateway=192.168.5.1
table.Network.eth0.DhcpEnable=false
table.Network.eth0.DnsServers[0]=223.5.5.5
table.Network.eth0.DnsServers[1]=223.6.6.6
table.Network.eth0.EnableDhcpReservedIP=false
table.Network.eth0.IPAddress=192.168.5.115
table.Network.eth0.MTU=1500
table.Network.eth0.PhysicalAddress=bc:32:5f:48:59:34
table.Network.eth0.SubnetMask=255.255.255.0
table.Network.eth2.DefaultGateway=192.168.0.1
table.Network.eth2.DhcpEnable=true
table.Network.eth2.DnsServers[0]=223.5.5.5
table.Network.eth2.DnsServers[1]=223.6.6.6
table.Network.eth2.EnableDhcpReservedIP=false
table.Network.eth2.IPAddress=192.168.0.108
table.Network.eth2.MTU=1500
table.Network.eth2.PhysicalAddress=bc:32:5f:48:59:66
table.Network.eth2.SubnetMask=255.255.0.0

Exemplos

import requests
 
device_ip = '192.168.3.87'
username = 'admin'
password = 'acesso1234'
 
url = "http://{}/cgi-bin/configManager.cgi?action=getConfig&name=Network".format(
                            str(device_ip), 
                        )
 
digest_auth = requests.auth.HTTPDigestAuth(username, password)
rval = requests.get(url, auth=digest_auth, stream=True, timeout=20, verify=False)
 
print(rval.text)

Habilitar/Desabilitar Servidor DHCP

Requisição - GET

http://192.168.1.201/cgi-bin/configManager.cgi?action=setConfig&Network.eth0.DhcpEnable=false

paramtypedescription
setConfig *StringComando para Definir configuração
DhcpEnable *BooleanAtiva ou Desativa o Servidor DHCP

Exemplo de Retorno - text/plain

OK

Exemplos

import requests
 
device_ip = '192.168.3.87'
username = 'admin'
password = 'acesso1234'
 
enable_dhcp = False
 
url = "http://{}/cgi-bin/configManager.cgi?action=setConfig&Network.eth0.DhcpEnable={}".format(
                            str(device_ip),
                            str(enable_dhcp).lower(), 
                        )
 
digest_auth = requests.auth.HTTPDigestAuth(username, password)
rval = requests.get(url, auth=digest_auth, stream=True, timeout=20, verify=False)
 
print(rval.text)

Definir Endereço de IP

Requisição - GET

http://192.168.1.201/cgi-bin/configManager.cgi?action=setConfig&Network.eth0.IPAddress=192.168.5.115

paramtypedescription
setConfig *StringComando para Definir configuração
IPAddress *StringEndereço de IP Exemplo: 192.168.5.115

Exemplo de Retorno - text/plain

OK

Exemplos

import requests
 
device_ip = '192.168.3.87'
username = 'admin'
password = 'acesso1234'
 
ip_address = '192.168.3.87'
 
url = "http://{}/cgi-bin/configManager.cgi?action=setConfig&Network.eth0.IPAddress={}".format(
                            str(device_ip),
                            str(ip_address), 
                        )
 
digest_auth = requests.auth.HTTPDigestAuth(username, password)
rval = requests.get(url, auth=digest_auth, stream=True, timeout=20, verify=False)
 
print(rval.text)