Changing the hostnames on all switches on network with NCM

Hi Guys (and Gals),

Due to a recent change in our network we need to rename all of our cisco switches with a new naming convention.  Our current convention goes like this:






This is spread across the whole campus so new switches have more recent numbers, but can be located in ANY building.  So we have decided to change the naming convention so we know where a switch is based on the hostname.

So the new convention goes something like this:


BA45-002 - All for building A




BG150-002 - All for building G


The numbers represent the final two octets of the IP address of the switch, the first two are predefined. So for example BA45-001 has an IP of and BG150-003 would have a IP of

At the moment I have to rename them manually and after about an hour change the IP address, this is because it takes a while for the hostname to update on the system.

Is there an easier way to do this?

Thank you,



  • There sure is an easy way. Export custom properties including nodeid and caption as excel. Do a find and replace for everything. So if C12 becomes BA150 just do the replace. It's excel so you can get as complicated as you want. Then do an index match to the new ip addresses. After that just write a SQL update statement in a formula like ="update nodes set ip_address='"&A1&"' where nodeid ="&B1

    Copy that formula for every row and put the resulting update statements into SMSS.

    Keep in mind that modifying the database can trash your whole system so take care. The entire change would take a few hours using this process. Let me know if you want some help

    Matthew Hawks

    Loop1 Systems

  • This changes the name in Orion, but doesn't affect the nodes themselves.   As I read the original question, I believe Euan wants to change the actual hostname on the device.

    I have the same need based on similar criteria.  I have a change where all the switches need one letter changed due to a naming standards "realignment".  I have access switches that are named ANxxxxx-## or APxxxxx-## that now need to be ABxxxxx-##.

    Can this be scripted in NCM?

  • First you need to get the new names into a custom property (use excel) and then just use a config change template to apply the name. This may be possible with a standard NCM script, but I personally only use those for things without variables. You could even extract your 3rd and 4th octets into custom proprieties and build the name within the config change template, but that may be more hassle than it is worth since you would have to take steps to ensure that names weren't used twice, but if the information is already in your custom properties it may save you time. Below is a config change template that passes validation that may do what you need (please test and verify everything before using as this was made with the basic information your provided). If you remove the string manipulation you could easily have it just push what is in a custom property. Custom properties I used below are: Campus, Building, Octet3, Octet4. Please let me know if this helps.



        This change template changes the device name in a specific way.


        cisco, eigrp, ios, netflow, routing


        Cisco IOS

    .PARAMETER_LABEL @ContextNode



        The node the template will operate on.  All templates require this by default. The target node is selected during the first part of the wizard so it will not be available for selection when defining values of variables.


    script ChangeName (

                                 NCM.Nodes @ContextNode



        string @NewName = @ContextNode.Campus + @ContextNode.Building

         @NewName = @NewName + @ContextNode.Octet3

         @NewName = @NewName + '-'

         @NewName = @NewName + @ContextNode.Octet4




            configure terminal

            hostname @NewName




  • I wanted to update my response with how I did my name update back in 2018.

    • Using a report, I exported all the pertinent info into a CSV: Node name, IP.
    • I created a new custom property called NewNodeName.
    • Using Excel, I manipulated the names as desired and added the new names into a column: NewNodeName
    • I created a script in NCM to read the value of NewNodeName and apply it as a variable
    1. configure terminal   
    2. hostname ${NewNodeName}   
    3. end 
    4. copy run start
    • Applied it using filters in NCM.

    A couple of points:

    1. NCM will update the hostname in Orion automagically on whatever schedule you have rescans set for.  Patience will out.
    2. I heartily recommend you verify the script works as it is over two years old.

    All in all it was very easy (if a bit tedious) and was an interesting challenge.