ola amigo estou precisando de uma ajuda gostaria de uma ajuda gostaria de saber se tem como criar um script pra habilitar e desabilitar automatico um mac ou ip cadastrado no ip briding
Visualizações: 102
Para adicionar comentários, você deve ser membro de MK-AUTH.
:foreach h in=[/ip hotspot active find] do={ :global address [/ ip hotspot active get $h address]; :global user [/ip hotspot active get $h user]; :global mac [/ip hotspot active get $h mac-address]; /ip hotspot user set $user comment=$user mac=$mac address=$address; :foreach x in=[/ip dhcp-server lease find] do={/ip dhcp-server lease make-static $x}; }
#1 início do laço :foreach h in=[/ip hotspot active find] do={
#2 obter e armazenar ip :global ip [/ip hotspot active get $h value-name=address];
#3 obter e armazenar nome de usuário :global usuario [/ip hotspot active get $h value-name=user];
#4 obter e armazenar mac :global mac [/ip hotspot active get $h value-name=mac-address];
#5 setar mac armazenado ao usuário obtido /ip hotspot user set $usuario mac-address=$mac
}
Estou tentando adaptar para também pegar o ip dos ativos e inserir nos users que estão em branco. Seria somente trocar na última linha o parâmetro mac-address=$mac por adress=$ip ?
#auto mac pppoe # :foreach h in=[/ppp active find] do={ :global nome [/ppp active get $h value-name=name]; :global ip [/ppp active get $h value-name=address]; :global mac [/ppp active get $h value-name=caller-id]; /ppp secret set $nome caller-id=$mac } #-----------------------------------------------------
#auto mac hotspot # :foreach h in=[/ip hotspot active find] do={ :global ip [/ip hotspot active get $h value-name=address]; :global usuario [/ip hotspot active get $h value-name=user]; :global mac [/ip hotspot active get $h value-name=mac-address]; /ip hotspot user set $usuario mac-address=$mac } #-------------------------------------------------------------
Explica melhor! vou dá um exemplo bem prático, a base é a mesma, abaixo todo estes comandos tem a mesma função, apenas com buscas diferentes, um exemplo, tenho um cliente no hotspot em ip-binding assim: ip = 192.168.2.10 mac-address = 00:0E:4C:D1:D2:D3 comment = teste type = bypassed
para habilitar, desabilitar, remover e etc... este cliente por por script, posso fazer um script com a busca por ip, mac-address, comment ou type...
# Habilitar com busca por mac-address /ip hotspot ip-binding disable [find mac-address="00:0E:4C:D1:D2:D3"] # Desabilitar com busca por mac-address /ip hotspot ip-binding enable [find mac-address="00:0E:4C:D1:D2:D3"] # Habilitar com busca por ip /ip hotspot ip-binding disable [find address="192.168.2.10"] # Desabilitar com busca por ip /ip hotspot ip-binding enable [find address="192.168.2.10"] # Habilitar com busca por comentario /ip hotspot ip-binding disable [find comment="teste"] # Desabilitar com busca por comentario /ip hotspot ip-binding enable [find comment="teste"] # Habilitar com busca por type /ip hotspot ip-binding disable [find type="bypassed"] # Desabilitar com busca por type /ip hotspot ip-binding enable [find type="bypassed"]
para que essa tarefa seja automatica no mikrotik, você vai precisar de dois scripts, um para habilitar e outro para desabilitar com o comandos de busca que você preferir acima.
Bem pelo que eu entendi, é isso que você está procurando?
Respostas
:foreach h in=[/ip hotspot active find] do={
:global address [/ ip hotspot active get $h address];
:global user [/ip hotspot active get $h user];
:global mac [/ip hotspot active get $h mac-address];
/ip hotspot user set $user comment=$user mac=$mac address=$address;
:foreach x in=[/ip dhcp-server lease find] do={/ip dhcp-server lease make-static $x};
}
Enoque Pereira Marques disse:
Alguém?
Alguém saberia responder?
Muito útil o script. Deixe-me ver se entendi
#1 início do laço
:foreach h in=[/ip hotspot active find] do={
#2 obter e armazenar ip
:global ip [/ip hotspot active get $h value-name=address];
#3 obter e armazenar nome de usuário
:global usuario [/ip hotspot active get $h value-name=user];
#4 obter e armazenar mac
:global mac [/ip hotspot active get $h value-name=mac-address];
#5 setar mac armazenado ao usuário obtido
/ip hotspot user set $usuario mac-address=$mac
}
Estou tentando adaptar para também pegar o ip dos ativos e inserir nos users que estão em branco. Seria somente trocar na última linha o parâmetro mac-address=$mac por adress=$ip ?
#auto mac pppoe
#
:foreach h in=[/ppp active find] do={
:global nome [/ppp active get $h value-name=name];
:global ip [/ppp active get $h value-name=address];
:global mac [/ppp active get $h value-name=caller-id];
/ppp secret set $nome caller-id=$mac
}
#-----------------------------------------------------
#auto mac hotspot
#
:foreach h in=[/ip hotspot active find] do={
:global ip [/ip hotspot active get $h value-name=address];
:global usuario [/ip hotspot active get $h value-name=user];
:global mac [/ip hotspot active get $h value-name=mac-address];
/ip hotspot user set $usuario mac-address=$mac
}
#-------------------------------------------------------------
Explica melhor!
vou dá um exemplo bem prático, a base é a mesma, abaixo todo estes comandos tem a mesma função, apenas com buscas diferentes,
um exemplo, tenho um cliente no hotspot em ip-binding assim:
ip = 192.168.2.10
mac-address = 00:0E:4C:D1:D2:D3
comment = teste
type = bypassed
para habilitar, desabilitar, remover e etc... este cliente por por script, posso fazer um script com a busca por ip, mac-address, comment ou type...
# Habilitar com busca por mac-address
/ip hotspot ip-binding disable [find mac-address="00:0E:4C:D1:D2:D3"]
# Desabilitar com busca por mac-address
/ip hotspot ip-binding enable [find mac-address="00:0E:4C:D1:D2:D3"]
# Habilitar com busca por ip
/ip hotspot ip-binding disable [find address="192.168.2.10"]
# Desabilitar com busca por ip
/ip hotspot ip-binding enable [find address="192.168.2.10"]
# Habilitar com busca por comentario
/ip hotspot ip-binding disable [find comment="teste"]
# Desabilitar com busca por comentario
/ip hotspot ip-binding enable [find comment="teste"]
# Habilitar com busca por type
/ip hotspot ip-binding disable [find type="bypassed"]
# Desabilitar com busca por type
/ip hotspot ip-binding enable [find type="bypassed"]
para que essa tarefa seja automatica no mikrotik, você vai precisar de dois scripts, um para habilitar e outro para desabilitar com o comandos de busca que você preferir acima.
Bem pelo que eu entendi, é isso que você está procurando?
se não é isso explica melhor!