Disable port over snmp

Is it possible to disable interface over snmp?

snmpset -v2c -c 192.168.88.1 1.3.6.1.2.1.2.2.1.7.1 i 2

IF-MIB::ifAdminStatus.1 = INTEGER: down(2)

but interface anyway in running state:
[admin@TEST] > int pr
Flags: D - dynamic, X - disabled, R - running, S - slave

NAME

0 ether1-gateway

snmp settings:
/snmp set enabled=yes
/snmp community add name=test read-access=yes security=none write-access=yes

version: 5.14
board-name: RB750

snmp-write in routeros is very limited and it is not possible to disable port in this way. If you require some automation, you can create script, or if you are using some server to monitor routers using SNMP you can use API, to do configuration changes.

Thank you.
Do you plan to add full snmp-write access in future releases?

SNMP write can run scripts. If your tasks are known and repeat often, this makes it possible to run almost any configuration:
http://wiki.mikrotik.com/wiki/SNMP#SNMP_write

Ok, thank you for help. I think I will choose the API for my task.

Can you please let me know when will you implement the option of port disabling via SNMP?
MikroTik switches cannot be used in data centers that rent dedicated servers only because of the impossibility of disabling the port via SNMP, because this is the main function when suspending the server via DCIm software. So far, I have refused to implement Mikrotik CRS in dozens of data centers just because of the lack of this very important function (more then 4k switches). So, MikroTik loses millions of dollars because CRS has no basic SNMP function implemented.

Here is how to do it on a Cisco device:

Interface UP:

snmpset -v1 -c community hostname IF-MIB::ifAdminStatus.interface i 1

Interface DOWN:

snmpset -v1 -c community hostname IF-MIB::ifAdminStatus.interface i 2

Yes, this is for Cisco, but MikroTik don’t have that simple option. There is no possibility to disable port via SNMP. I believe MikroTik is the only vendor who does not that option and they are not aware that they are loosing millions $ because of that…

Is it still impossible via snmp?

I need to reset cusomers ports … as I implemendet my software product some years ago, I had to switch to the api to do that but that solution is not elegant. I really would prefer to reset a port via snmp…

This works 1.3.6.1.2.1.2.2.1.7.{PORT Number} INTERGER (i) 1 for enable, 2 for disable

Tested on CRS305

Working on hAP ac^2 :slight_smile:

You need to specify i for integer. And 1 is up and 2 is down.

snmpwalk -v2c -c public 192.168.1.14 1.3.6.1.2.1.2.2.1.7
IF-MIB::ifAdminStatus.1 = INTEGER: up(1)
IF-MIB::ifAdminStatus.2 = INTEGER: up(1)
IF-MIB::ifAdminStatus.3 = INTEGER: up(1)
IF-MIB::ifAdminStatus.4 = INTEGER: up(1)
IF-MIB::ifAdminStatus.5 = INTEGER: up(1)
IF-MIB::ifAdminStatus.6 = INTEGER: up(1)
IF-MIB::ifAdminStatus.7 = INTEGER: up(1)
IF-MIB::ifAdminStatus.8 = INTEGER: up(1)

snmpset -v2c -c private 192.168.1.14 1.3.6.1.2.1.2.2.1.7.6 i 2
IF-MIB::ifAdminStatus.6 = INTEGER: down(2)

snmpwalk -v2c -c public 10.10.10.14 1.3.6.1.2.1.2.2.1.7
IF-MIB::ifAdminStatus.1 = INTEGER: up(1)
IF-MIB::ifAdminStatus.2 = INTEGER: up(1)
IF-MIB::ifAdminStatus.3 = INTEGER: up(1)
IF-MIB::ifAdminStatus.4 = INTEGER: up(1)
IF-MIB::ifAdminStatus.5 = INTEGER: up(1)
IF-MIB::ifAdminStatus.6 = INTEGER: down(2)
IF-MIB::ifAdminStatus.7 = INTEGER: up(1)
IF-MIB::ifAdminStatus.8 = INTEGER: up(1)

Take care 1: Adding a virtual interface or other interface change, may change the interface numbering.
So to us this in a script, use snmpwalk to find interface number for the interface you like to set, then set it based on that.

Take care 2: These action are not logged in command log history, not in system change. So MT please add this, and for all, only enable SNMP write from specific IP