Setting Subnet Mask with SNMP

I have been automating some management network changes, namely breaking up a larger subnet/VLAN into much smaller subnets/VLANs. For this, I am using Python and the "HNMP" library to configure these settings on all the different types of radios we have in our network. I had a script that was working mostly well (Except for those pesky PMP320 CPEs...), though after a recent ePMP software update I noticed script would fail when it's setting the subnet mask and I would get an error that says "Bad Value".

After banging my head against the wall for way too long, I found that the issue was because there seems to be some added input validation on the subnet mask field that prevents you from making a silly mistake like changing the subnet mask to one that would put the default gateway outside the subnet. To work around this, I had to change the flow of my script that was previously:

(Set Management VLAN)
'.1.3.6.1.4.1.17713.21.3.4.4.2.0' = 100

(Set Subnet Mask)
'.1.3.6.1.4.1.17713.21.3.4.7.3.0' = '255.255.255.0'

(Set Default Gateway)
'.1.3.6.1.4.1.17713.21.3.4.7.4.0' = '10.0.0.254'

(Save Settings)
'.1.3.6.1.4.1.17713.21.4.3.0' = 1

(Apply Settings)
'.1.3.6.1.4.1.17713.21.4.4.0' = 1

After the changes, it flows like this:

(Set Management VLAN)
'.1.3.6.1.4.1.17713.21.3.4.4.2.0' = 400

(Set Default Gateway)
'.1.3.6.1.4.1.17713.21.3.4.7.4.0' = '10.4.0.254'

(Save Settings)
'.1.3.6.1.4.1.17713.21.4.3.0' = 1

(Set Subnet Mask)
'.1.3.6.1.4.1.17713.21.3.4.7.3.0' = '255.255.255.0'

(Save Settings)
'.1.3.6.1.4.1.17713.21.4.3.0' = 1

(Apply Settings)
'.1.3.6.1.4.1.17713.21.4.4.0' = 1

So, you can't just change the default gateway first, you also have to change it, SAVE IT, then you're able to change the subnet mask.

I hope this helps someone else, I spent way too long trying to figure that out.

3 Likes