How to Configure Cisco Routers Using Script Configuration

Before performing Cisco router configuration using scripts, you need to be clear about the operations you want to perform and the commands you want to execute, then write the script accordingly. I want to back up the running-configuration. Of course, the device is already configured and the TFTP server is ready. The Cisco router configuration is as follows:

BT wireless network cracking:

  1. username ccie privilege 15 password 0 ccie  
  2. !  
  3. interface FastEthernet0/0  
  4. no ip address  
  5. shutdown  
  6. duplex auto speed auto  
  7. !  
  8. interface FastEthernet0/1  
  9. ip address 11.133.183.251 255.255.255.0  
  10. duplex auto speed auto  
  11. !  
  12. ip classless ip route 0.0.0.0 0.0.0.0 11.133.183.254  
  13. ip http server ip pim bidir-enable  
  14. !  
  15. line vty 0 4 login local 

Then you can follow the steps below for Cisco router configuration:

1. Write the Script:

Create a new file crt.vbs, with the .vbs extension, with the following content:

  1. #$language = "VBScript" 
  2. Ubuntu Forum #$interface = "1.0" Sub main ' turn on synchronous mode so we don't miss any data  
  3. crt.Screen.Synchronous = True On Error Resume Next  
  4. crt.session.Connect("/telnet 10.1.1.1") If Err.Number<>0 Then  
  5. crt.session.Connect("/telnet 10.1.1.1") End If  
  6. crt.Screen.WaitForString "Username:" crt.Screen.Send "ccie" & VbCr  
  7. crt.Screen.WaitForString "Password:"  
  8. crt.Screen.Send "ccie " & VbCr  
  9. crt.Screen.WaitForString "Router#"  
  10. crt.Screen.Send "config t" & VbCr  
  11. crt.Screen.WaitForString "Router(config)#"  
  12. crt.Screen.Send "int f0/1" & VbCr  
  13. crt.Screen.WaitForString "Router(config-if)#"  
  14. crt.Screen.Send "no sh" & VbCr  
  15. crt.Screen.WaitForString "Router(config-if)#"  
  16. crt.Screen.Send "end" & VbCr  
  17. crt.Screen.WaitForString "Router#"  
  18. crt.Screen.Send "copy run tftp://10.1.1.10" & VbCr  
  19. crt.Screen.WaitForString "Address or name of remote host [11.133.183.249]" crt.Screen.Send ""& VbCr Cisco Router  
  20. crt.Screen.WaitForString "Destination filename [router-confg]"  
  21. crt.Screen.Send ""& VbCr  
  22. Do while (crt.Screen.WaitForString("--- more ---",1)<>False)  
  23. crt.Screen.Send " " Loop '  
  24. crt.Screen.Send "exit" & VbCr crt.session.disconnect  
  25. crt.Screen.Synchronous = False End Sub 

I believe friends familiar with VB can easily understand it. The explanations for the above content are as follows:

crt.session.Connect("/telnet 11.133.183.251")–This should be easy to understand, the device to telnet to.

crt.Screen.WaitForString "Username:"–The information returned from the device, i.e., the prompt message.

crt.Screen.Send "ccie" & VbCr–The characters sent to the device, i.e., the commands or characters you would enter during normal operation.

& VbCr ——Enters the characters and hits Enter.

Note: The parts within " " are the places that need corresponding modifications; you just need to modify them according to your specific situation.

2. Apply the Script:

Open the CRT software.

Click the “Script” menu.

Click “RUN”.

In the pop-up menu, find the directory where the script was saved and enter the script name crt.vbs. You will then see the script executing, as follows:

  1. User Access Verification Username: ccie  
  2. Password: Netscreen Firewall  
  3. Router#config t Enter configuration commands, one per line. End with CNTL/Z.  
  4. Router(config)#int f0/1  
  5. Router(config-if)#no sh Ubuntu Input Method  
  6. Router(config-if)#end  
  7. Router#copy run tftp://11.133.183.249 Address or name of remote host [11.133.183.249]?  
  8. Destination filename [router-confg]? !! 694 bytes copied in 9.60 secs (77 bytes/sec)  
  9. Router#Linux Forum Cisco Forum Cisco  

The process of configuring a Cisco router using scripts is as described above. The key lies in the script writing techniques. I hope you will learn more about programming to help you understand the Cisco router configuration process.

【Editor’s Picks】

【Editor in Charge: liyan TEL:(010)68476606】

Leave a Comment

Your email address will not be published.