cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1485
Views
0
Helpful
5
Replies

VLAN Change by IP

joshua izzi
Level 1
Level 1

Hello,

I was hoping someone could please help me with an automated script. The logic seems not so difficult although, I do not have much TCL experience...

I need a way to load a list of IPs (probably 50 at a time), find their associated MAC address, then find the port its on (excluding trunks), and then change its vlan.

Does anyone have any experience with this?

Thank you in advance for any help!

5 Replies 5

Dan Frey
Cisco Employee
Cisco Employee

A previous discussion located at the link below had similar requirements (mac to port mapping) and logic can be added to change the access vlan.

 

https://supportforums.cisco.com/discussion/12141486/create-eem-find-port-mac-address

 

Thanks - I actually saw that response. Unfortunately my knowledge of this is just about nothing and am under a very tight deadline....I cannot seem to figure out how to add that logic in to change the port. It would be nice to ensure it isn't a trunk too but that may be a luxury.

 

Thanks again

What would be the condition that the port changes the access vlan?   When the script changes the vlan on the port what vlan should it assign?   Would there be a reason that the script would not change the vlan (other than the port being a 802.1q trunk)?

 

The condition would be on a list of specific IP addresses. I have a list of IPs that need to be changed to a different VLAN, in which case we can reboot the machines and they will get a new DHCP IP. The vlan is going to be vlan 174 that it needs to be changed to. There is no other reason other than a trunk that it shouldnt be changed.

 

Thanks again for the help - very very much apprecaited!

If you place the attached file on the flash drive of your switch and run this command it should produce the vlan change only on access ports for the list of provided ip addresses.

tclsh flash:resolve_changevlan.tcl <list of ip addresses>

Ex:

Switch_1#tclsh flash:resolve_changevlan.tcl 192.168.0.125 192.168.0.1

192.168.0.252 192.168.0.251 192.168.0.141 192.168.0.142
*** 192.168.0.125 Fa0/12 is not currently an access port ***

*** 192.168.0.1 Fa0/12 is not currently an access port ***

***192.168.0.252 verify vlan change****
Building configuration...

Current configuration : 62 bytes
!
interface FastEthernet0/14
 switchport access vlan 174
end

*******************************

*** 192.168.0.251 not in MAC table***

***192.168.0.141 verify vlan change****
Building configuration...

Current configuration : 78 bytes
!
interface FastEthernet0/2
 description SUN
 switchport access vlan 174
end

*******************************

*** 192.168.0.142 Fa0/19 is not currently an access port ***

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Innovations in Cisco Full Stack Observability - A new webinar from Cisco