A customer is looking for an IOS feature called DHCP Server Port-Based Address Allocation. This feature allows the user to preassign an IP address to a port from the DHCP pool. Once a device is plugged into the port, the device will get the assigned IP address.
Our project uses the following logic flow to simulate the same feature on the Meraki platform utilizing the Dashboard APIs.
- Jorge Banegas
- Jason Mah
- Python
- Meraki Dashboard API Python Library - https://github.com/meraki/dashboard-api-python/
- Flask
Option 1:
- Pull down the project into a python virtual environment
git clone https://github.com/gve-sw/meraki_port_based_dhcp.git
- Install required packages
pip install -r requirements.txt
- Launch flask application
python app.py
Option 2:
-
Install Docker - https://docs.docker.com/get-docker/
-
Pull down the project
git clone https://github.com/gve-sw/meraki_port_based_dhcp.git
- Build the project Docker image
docker build --tag merakidhcp:1.0 .
- Run Docker image
docker run --publish 5000:5000 --detach --name dhcp merakidhcp:1.0
Open your browser to http://0.0.0.0:5000
Enter a Meraki API Key from the Meraki API dashboard - https://documentation.meraki.com/zGeneral_Administration/Other_Topics/The_Cisco_Meraki_Dashboard_API#:~:text=Enable%20API%20access,-For%20access%20to&text=After%20enabling%20the%20API%2C%20go,API%20key%20on%20your%20profile.
Enter or create a Webex Teams Bot key - https://developer.webex.com/docs/bots
Enter or create the Webex Teams Room ID - https://developer.webex.com/docs/api/v1/rooms/list-rooms
To setup Meraki Webhook notifications. Navigate in the Meraki Dashboard to Network-wide -> Configure -> Alerts
Under the Switch section of Alerts, select "any port goes down for more than 5 minutes" add your webhook name to the additional recipients.
Under the Webhooks section add the corresponding Http server that will receive the Webhook notification.
In the Meraki Dashboard tag all switches that wish to use with the "media" tag to allow the application to inspect that device.
On the port, add the IP tag that you would like to assign to the port.
To initiate a device capture for the last device plugged into the switch. Navigate to "Initiate Device Capture" on the sidebar.
To scan a network for all switches that may have a "miss match" of tagged IP to current device IP. Navigate to "Scan for New Devices"
Once you select a specific organization and network, the app wil display the mismatched port and client and offer the ability to change the desired ip address of the client
Provided under Cisco Sample Code License, for details see LICENSE
Our code of conduct is available here
See our contributing guidelines here
Please note: This script is meant for demo purposes only. All tools/ scripts in this repo are released for use "AS IS" without any warranties of any kind, including, but not limited to their installation, use, or performance. Any use of these scripts and tools is at your own risk. There is no guarantee that they have been through thorough testing in a comparable environment and we are not responsible for any damage or data loss incurred with their use. You are responsible for reviewing and testing any scripts you run thoroughly before use in any non-testing environment.