cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
12794
Views
9
Helpful
11
Replies

API - MS add or update DHCP settings

edison_abad
Level 3
Level 3

Hi,

Is there any API call to add or update the DHCP settings in MS Switches or Switch Stacks?

We have 150+ networks and each has multiple VLANs that we are relaying to our DHCP servers.

It will be good if we could write a script to update the servers' IP addresses, and to revert in case of back out.

If the API is not available, do we have any suggestion on how could automate the changes?

Thanks in advance!

1 Accepted Solution

Accepted Solutions

DensyoV
Cisco Employee
Cisco Employee

Hi,

I ran through the API docs (help > API docs page on the Dashboard) there is still no API call available to update the DHCP configuration of the switches so you will need to update the configuration individually on each of the networks you have.

Thanks,

Please hit kudos if you found this post helpful and/or click "accept as solution" if this solved your problem.

View solution in original post

11 Replies 11

DensyoV
Cisco Employee
Cisco Employee

Hi,

I ran through the API docs (help > API docs page on the Dashboard) there is still no API call available to update the DHCP configuration of the switches so you will need to update the configuration individually on each of the networks you have.

Thanks,

Please hit kudos if you found this post helpful and/or click "accept as solution" if this solved your problem.

lsmith
Level 2
Level 2

Why wouldn't the code below work? I just threw it together to answer your question. It is how I would do it in Python 3.82 using Meraki API 0.100.1. This would update the DHCP relay servers on all vlans - adjust accordingly to fit your need. I have used the update vlan API call to update vlans on MX appliances. You may want to add some error checking logic. Replace ['se.rv.er.01, se.rv.er.02'] with your new server IP's. I would test it on one network/vlan first to be sure you get the desired result and confirm the new setting works, ie. no typos on the server IP's.

# no api_key specified below it uses environment variable "MERAKI_DASHBOARD_API_KEY"
Merakiclient = meraki.DashboardAPI(api_key='',
wait_on_rate_limit = True,
maximum_retries = 2,
log_file_prefix = __file__[:-3],
log_path='')

orgs = Merakiclient.organizations.getOrganizations()
orgid=orgs['id'] # use above API getorgs() call or code the orgid here

newRelayServers = ['se.rv.er.01, se.rv.er.02']

networks = Merakiclient.networks.getOrganizationNetworks(orgid)

for network in networks:
print('Processing network: ',network['name'])
vlans = Merakiclient.vlans.getNetworkVlans(network['id'])
for vlan in vlans:
print('Processing Vlan: {} - {}'.format(vlan['id'], vlan['name']))
if vlan['dhcpHandling'] == 'Relay DHCP to another server':
result = Merakiclient.vlans.updateNetworkVlan(network['id'], str(vlan['id']),
dhcpRelayServerIps = newRelayServers)
updatedVlan = Merakiclient.vlans.getNetworkVlan(network['id'], vlan['id'])
print('Vlan {} DHCP Relay Servers after update: {}'.format(updatedVlan['id'],
updatedVlan['dhcpRelayServerIps']))

Larry

Thanks for the reply.

The VLANs API calls works for MX only, since the argument is network-wide (network ID).

This is my guess for it to work with MS switches - DHCP settings or VLAN should have a way to associate with a switch or switch-stack.

Updating the MS Layer 3 interfaces and related routing/DHCP services might be in your near future. Stay tuned for lots of good stuff in Dashboard API v1...

Can Meraki support make these changes? We are migrating dhcp servers and I have over 100 meraki vlan SVI's to change.

looks like the ability is coming in v1 per changelog in beta 10

https://developer.cisco.com/meraki/whats-new/#!v1-0-0-beta-10

V1 is coming ....

(Next week)

Same problem. I have to change the dhcp-relayservers to hundreds of switches. There is no API for this, so it will have to be done manually.

you can do this in API 1.0. latest is 1.7 i believe. that's what i'm using

@Willem_vd_Pas - If you are referring to changing this on Layer 3 switches, it was added in API V1.

https://developer.cisco.com/meraki/api-v1/#!update-device-switch-routing-interface-dhcp

Description: Update a layer 3 interface DHCP configuration for a switch

Larry

zaxanoid
Frequent Visitor
Frequent Visitor

This works for individual switches, but for stacks I get

"'errors': ['This endpoint is not supported for switches in switch stack'

Can't see the relevance the Layer 3 should be defined in 1 place?