Hi
I'm trying to change IP address on ePMP SM via SNMP.
Works fine when new IP is in the same subnet as existing IP but if I try to change to a different subnet it throws an error. Same for when changing Gateway IP.
Is there any way around this?
I was hoping to be able to use a bash script to bulk change a bunch of SM's by SNMP.
Thanks
colin
newkirk
(newkirk)
February 14, 2018, 5:23pm
#2
What firmware version, what error is it returning, and can you provide an example of the snmpset you're using?Β Also, have you tried setting both at the same time in one snmpset invokation?
j
Firmware: 3.5.1
Error Returned: Error in packet. Reason: (badValue) The value given has the wrong type or length.
snmpset Command: snmpset -c private -v2c 10.96.10.22 1.3.6.1.4.1.17713.21.3.4.7.2.0 a "10.96.23.254" 1.3.6.1.4.1.17713.21.3.4.7.4.0 a "10.96.23.1"
The above command works when the IP and Gateway are in the same subnet as the current radio IP.
Running same command with IP and GW in different subnet and I get the above error.
Thanks
colin
colinhowlin
(colinhowlin)
February 20, 2018, 12:50pm
#4
I ended up just using SSH commands in the bash script to change the IP and gateway.
Completed script is below for anyone interested.
It takes a list of IP addresses (could also be stored in a file).
Then checks to see if network mode is set to Bridge or NAT and changes IP and gateway accordingly.
It also adds DNS and cnMaestro details via SNMP.
#!/bin/bash
IP_LIST=(192.168.2.54 192.168.2.58 192.168.2.64 192.168.2.70)
CN_URL="CNMAESTRO_URL"
CN_USER="cnmaestro_on_premises"
CN_PASS="CNMAESTRO_ONBOARDING_KEY"
DNS1="8.8.8.8"
DNS2="8.8.4.4"
SSHPASS="PASSWORD"
SSHCOMMAND="ssh -p 22 -T -o StrictHostKeyChecking=no -o BatchMode=no"
SSHACC="admin"
BRIDGE="INTEGER: 2"
IP_NET="192.168.5."
IP_HOST="10"
NEW_GW="192.168.5.1"
for IP in β${IP_LIST[@]}β
do
echo β";
echo βLogging into: ${IP}β;
echo " β;
NEW_IP=$IP_NET.$IP_HOST
NETWORK_MODE=snmpget -c private -v 2c -O v ${IP} 1.3.6.1.4.1.17713.21.1.4.4.0
snmpset -c private -v 2c ${IP} 1.3.6.1.4.1.17713.21.3.4.7.7.0 a ${DNS1}
snmpset -c private -v 2c ${IP} 1.3.6.1.4.1.17713.21.3.4.7.8.0 a ${DNS2}
snmpset -c private -v 2c ${IP} 1.3.6.1.4.1.17713.21.3.20.1.0 i β1β
snmpset -c private -v 2c ${IP} 1.3.6.1.4.1.17713.21.3.20.2.0 s ${CN_URL}
snmpset -c private -v 2c ${IP} 1.3.6.1.4.1.17713.21.3.20.3.0 s ${CN_USER}
snmpset -c private -v 2c ${IP} 1.3.6.1.4.1.17713.21.3.20.4.0 s ${CN_PASS}
if [ "$NETWORK_MODE" = "$BRIDGE" ]; then
echo "Network Mode is Bridge"
sshpass -p "$SSHPASS" $SSHCOMMAND $SSHACC@$IP <<-EOF
config set networkBridgeIPAddr $NEW_IP
config set networkBridgeGatewayIP $NEW_GW
config save
config apply
EOF
else
echo "Network Mode is NAT"
sshpass -p "$SSHPASS" $SSHCOMMAND $SSHACC@$IP <<-EOF
config set mgmtIFIPAddr $NEW_IP
config set mgmtIFGateway $NEW_GW
config save
config apply
EOF
fi
((IP_HOST++))
done
1 Like