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:
- username ccie privilege 15 password 0 ccie
- !
- interface FastEthernet0/0
- no ip address
- shutdown
- duplex auto speed auto
- !
- interface FastEthernet0/1
- ip address 11.133.183.251 255.255.255.0
- duplex auto speed auto
- !
- ip classless ip route 0.0.0.0 0.0.0.0 11.133.183.254
- ip http server ip pim bidir-enable
- !
- 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:
- #$language = "VBScript"
- Ubuntu Forum #$interface = "1.0" Sub main ' turn on synchronous mode so we don't miss any data
- crt.Screen.Synchronous = True On Error Resume Next
- crt.session.Connect("/telnet 10.1.1.1") If Err.Number<>0 Then
- crt.session.Connect("/telnet 10.1.1.1") End If
- crt.Screen.WaitForString "Username:" crt.Screen.Send "ccie" & VbCr
- crt.Screen.WaitForString "Password:"
- crt.Screen.Send "ccie " & VbCr
- crt.Screen.WaitForString "Router#"
- crt.Screen.Send "config t" & VbCr
- crt.Screen.WaitForString "Router(config)#"
- crt.Screen.Send "int f0/1" & VbCr
- crt.Screen.WaitForString "Router(config-if)#"
- crt.Screen.Send "no sh" & VbCr
- crt.Screen.WaitForString "Router(config-if)#"
- crt.Screen.Send "end" & VbCr
- crt.Screen.WaitForString "Router#"
- crt.Screen.Send "copy run tftp://10.1.1.10" & VbCr
- crt.Screen.WaitForString "Address or name of remote host [11.133.183.249]" crt.Screen.Send ""& VbCr Cisco Router
- crt.Screen.WaitForString "Destination filename [router-confg]"
- crt.Screen.Send ""& VbCr
- Do while (crt.Screen.WaitForString("--- more ---",1)<>False)
- crt.Screen.Send " " Loop '
- crt.Screen.Send "exit" & VbCr crt.session.disconnect
- 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:
- User Access Verification Username: ccie
- Password: Netscreen Firewall
- Router#config t Enter configuration commands, one per line. End with CNTL/Z.
- Router(config)#int f0/1
- Router(config-if)#no sh Ubuntu Input Method
- Router(config-if)#end
- Router#copy run tftp://11.133.183.249 Address or name of remote host [11.133.183.249]?
- Destination filename [router-confg]? !! 694 bytes copied in 9.60 secs (77 bytes/sec)
- 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】
- In-Depth Analysis of Cisco Router Configuration
- Explaining Cisco Router Configuration Through Examples
- Applied Perspective: A Brief Introduction to Cisco Router Configuration
- How to Set Up Scripts for New Router Firmware
- Detailed Analysis of Cisco Router NAT Address Translation Configuration
- Brief Analysis of Routing Protocols in Cisco Router Configuration