cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Bookmark
|
Subscribe
|
2509
Views
0
Helpful
15
Replies

broadcast a command to all routers

Dhikra Marghli
Level 5
Level 5

Hello ,

 

I have a cisco metro boucle: ME3800, cisco 3600, ASR903, ASR920....

so i want from expert cisco that help me :

 

i want to add a  commands that broadcast a template to all router  without typing this template conifg  for each router 

 

I wait a reply from expert Metro Cisco 

6 Accepted Solutions

Accepted Solutions

balaji.bandi
Hall of Fame
Hall of Fame
 want to add a  commands that broadcast a template to all router

You mean config push to all the device, you need to bear in mind different devices has different config methods, some command may not work, but you can do basic config across all platforms.

 

i use Phython or any automation tool to do this task.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

View solution in original post

If you know the Python you can with netmiko as example :

 

https://pynet.twb-tech.com/blog/netmiko-python-library.html

 

you need some time to understand how that works and test few commands before you go mass level to deploy.

 

You need Linux or window running Python Library, Router or device do not hold any Python packages.

 

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

View solution in original post

automation tool can you give me example  !!

Automation the one you looking to do, tools can be used depends what works for end user, this can be python, ansible, powershell, bash script to make this to work automated the task.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

View solution in original post

here is script in python allows an example command (SNMP 3 script) broadcast to all routers once without writing the SNMPV3 script to 1000 cisco routers!!! 

not sure if i understand correctly here, you looking to config SNMPv3 config all devices, yes that is possible.

 

If you doing mass 1000 of routers (if the router support netconf - i take the advantage of that)

 

This required some ground work to get all the device information, what you can do what you can not do, if they are new device running IOS XE you have different method to do.

 

if they are IOS, you need to do traditional SSH way.

 

I used Phyton most used case for my work to push the config to 500+ device it works as expected (with multi thread with Phython less than 10minutes).

 

i am explore now using netconf on IOS XE code.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

View solution in original post

yes if the device suppport netconf

 

but easy is Python to push few command to many devices.

 

list all the device in file

list all the commands in file

 

run the script using that inputs. and verify.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

View solution in original post

try 1 or 2 device for testing, before you go mass level.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

View solution in original post

15 Replies 15

balaji.bandi
Hall of Fame
Hall of Fame
 want to add a  commands that broadcast a template to all router

You mean config push to all the device, you need to bear in mind different devices has different config methods, some command may not work, but you can do basic config across all platforms.

 

i use Phython or any automation tool to do this task.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Thanks to reply  

 

but I  want to know what 's  automation tool  can  add commands to all router metro without typing each router ??

 

and also how i can use python for router  Cisco !!!

 

thanks to reply me 

If you know the Python you can with netmiko as example :

 

https://pynet.twb-tech.com/blog/netmiko-python-library.html

 

you need some time to understand how that works and test few commands before you go mass level to deploy.

 

You need Linux or window running Python Library, Router or device do not hold any Python packages.

 

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Ok thanks i will try to understand NETMIKO python how  it work  

 

also for  automation tool can you give me example  !!

 

thanks in advance

automation tool can you give me example  !!

Automation the one you looking to do, tools can be used depends what works for end user, this can be python, ansible, powershell, bash script to make this to work automated the task.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

there is script in python allows an example command (SNMP 3 script) broadcast to all routers once without writing the SNMPV3 script to 1000 cisco routers!!! 

 

i wait your reply 

 

thanks 

here is script in python allows an example command (SNMP 3 script) broadcast to all routers once without writing the SNMPV3 script to 1000 cisco routers!!! 

not sure if i understand correctly here, you looking to config SNMPv3 config all devices, yes that is possible.

 

If you doing mass 1000 of routers (if the router support netconf - i take the advantage of that)

 

This required some ground work to get all the device information, what you can do what you can not do, if they are new device running IOS XE you have different method to do.

 

if they are IOS, you need to do traditional SSH way.

 

I used Phyton most used case for my work to push the config to 500+ device it works as expected (with multi thread with Phython less than 10minutes).

 

i am explore now using netconf on IOS XE code.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

not sure if i understand correctly here, you looking to config SNMPv3 config all devices, yes that is possible.

 

Uyes that's i want to say ...without config  each router with waste of time ... juste i want methode to allow this config  quickly broadcast to all metro routers like ASR903, ME3800, ASR920...

 

so  Bandi , i must use NETCONF in router cisco !! ??

thanks to reply me 

yes if the device suppport netconf

 

but easy is Python to push few command to many devices.

 

list all the device in file

list all the commands in file

 

run the script using that inputs. and verify.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Ok  i will try  because it is the first time to use python 

 

Thanks a lot 

try 1 or 2 device for testing, before you go mass level.

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Hello Bandi

 

i try to connecte switch layer 2 and this switch  have a telnet and login : cisco and password cisco123 

 

from netmiko import ConnectHandler
device = {
"device_type": "cisco_ios",
"host": '10.20.20.2',
"username": "cisco",
"password": "cisco123",
"port":23,# Log in password from getpass
}
connection = ConnectHandler(**device)
connection.enable()

config.send_config_from_fil('ospf.txt')

connection.disconnect()

 

Please i want your help :

 

+ choise of hard is correct or not !!!  switch layer 2 ??

++ if scrpit work with telnet or ssh ??

 

++ "username": "cisco",
"password": "cisco123",   

for equipment cisco or any login and password  !!

 

I wait your reply for these questions!

 

Thanks

If i understand the question - If there is no Manangement IP, then you will not be able to connect device.

 

If the Layer 2 device have management IP you can connect. (if the enable password there, you need to supply that too)

 

The script can work with telnet and SSH depends on requirement.

 

all examples already here : just edit the Python file as per the requirement and test it.

 

https://github.com/ktbyers/netmiko/tree/develop/examples

 

you can do for any equiment automation not limited to cisco :

 

https://github.com/ktbyers/netmiko/tree/develop/netmiko

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

ommon causes of this problem are:
1. Invalid username and password
2. Incorrect SSH-key file
3. Connecting to the wrong device

Device settings: cisco_ios 10.20.20.2:22

 

 

error message show me !!

 

and the  scrpit like that :

 

from netmiko import ConnectHandler
from getpass import getpass

cisco1 = {
"device_type": "cisco_ios",
"host": "10.20.20.2",
"username": "pyclass",
"password": getpass(),
}

# Show command that we execute
command = "show ip int brief"
with ConnectHandler(**cisco1) as net_connect:
output = net_connect.send_command(command)

# Automatically cleans-up the output so that only the show output is returned
print()
print(output)
print()

 

Please  Balaji can you correct me !! this scrpit beacuse the  first time i write pyhton  !

 

Thnaks to reply me