How to add/delete the IPv4 and IPv6 static route entry via SNMP?

Steven_zhangCreated at:Dec 11, 2019 11:27:44Updated at:Dec 11, 2019 11:27:50

Supported models: ECS4120 series (V1.2.2.13)

SNMPSET command format.

snmpset -v 2c -c private {switch IP Address} {inetCidrRouteStatus}.{IPv4 or IPv6}.{Destination network segment}.{mask}.{IPv4 or IPv6}.{Next hop} {integer} {value}

{inetCidrRouteStatus}

  • OID: 1.3.6.1.2.1.4.24.7.1.17

{IPv4 or IPv6} 

  • IPv4 OID: 1.4    -->  1 = IPv4 , 4 = IPv4 address is 4 byte.

  • IPv6 OID: 2.16  -->  2 = IPv6 , 16 = IPv6 address is 16 byte. (Please indicate in decimal. e.g. 2002::1 = 32.2.0.0.0.0.0.0.0.0.0.0.0.0.0.1)

{value}

  • 4 = Active 

  • 6 = Destroy

 

Configure IPv4 static route via SNMP.

  • Adding a IPv4 static route as follow:

ip route 192.168.87.0 255.255.255.0 192.168.2.11
  • NET-SNMP command: 

snmpset -v 2c -c private 192.168.2.10 1.3.6.1.2.1.4.24.7.1.17.1.4.192.168.87.0.24.1.4.192.168.2.11 i 4

{inetCidrRouteStatus=1.3.6.1.2.1.4.24.7.1.17}.{IPv4=1.4}.{Destination network segment=192.168.87.0}.{mask=24}.{IPv4=1.4}.{Next hop=192.168.2.11}.{integer} {value=4}

 

Configure IPv6 static route via SNMP.

  • Adding a IPv6 static route as follow:

ipv6 route 2002:8787::/64 2002::1
  • NET-SNMP command: 

snmpset -v 2c -c private 192.168.2.10 1.3.6.1.2.1.4.24.7.1.17.2.16.32.2.135.135.0.0.0.0.0.0.0.0.0.0.0.0.64.2.16.32.2.0.0.0.0.0.0.0.0.0.0.0.0.0.1 i 4

{inetCidrRouteStatus=1.3.6.1.2.1.4.24.7.1.17}.{IPv6=2.16}.{Destination network segment="2002:8787::"(Please indicate in Decimal)}.{mask=64}.{IPv6=2.16}.{Next hop="2002::1"(Please indicate in Decimal)}.{integer} {value=4}

 

Result:

!
interface vlan 1
 ip address 192.168.2.10 255.255.255.0
!
interface craft
!
!
ip route 192.168.87.0 255.255.255.0 192.168.2.11
!
!
interface vlan 1
 ipv6 address 2002::1/64
!
ipv6 route 2002:8787::/64 2002::1
!