Bulk set vlans to device interfaces

1,123 views
Skip to first unread message

Claudio Basso

unread,
Aug 31, 2018, 6:51:54 AM8/31/18
to NetBox
Hi,
I've created a device (a Switch) with his 48 ports.
If I select multiple ports and I clic on edit on the bottom/right button, I can set for example the Mode to "Access" to all selected Interfaces in 1 step.
But I can't find the way to assign VLAN settings to multiple ports (I need to assign for example VLAN 10 untagged to ports from 20 to 40).
The only way is edit every single interface and set the VLAN.

Is there any other way to do this?

Thanks

Claudio

Claudio Basso

unread,
Sep 12, 2018, 1:23:26 AM9/12/18
to NetBox
Hi,
no one assign VLAN to Switch ports?

Geert Reijnders

unread,
Sep 12, 2018, 4:27:48 AM9/12/18
to NetBox
Did you take a look at the API possibilities? 

Via the API (and a script) I created all my vlans be added to a device.


Op vrijdag 31 augustus 2018 12:51:54 UTC+2 schreef Claudio Basso:

Jason Lachowsky

unread,
Oct 9, 2018, 4:24:22 PM10/9/18
to NetBox
Would you be willing to share your script?

Geert Reijnders

unread,
Oct 10, 2018, 8:04:42 AM10/10/18
to NetBox
No problem,

#!/bin/bash

while read p; do
echo $p
curl -X POST -H "Authorization: Token <tokencode>" -H "Content-Type: application/json" -H "Accept: application/json; indent=4" http://localhost/api/dcim/interfaces/ --data '{"enabled":true,"device":2,"name":"'$p'","form_factor":0}'
done <invoerlijst.txt





Op dinsdag 9 oktober 2018 22:24:22 UTC+2 schreef Jason Lachowsky:
Reply all
Reply to author
Forward
0 new messages