cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2137
Views
0
Helpful
1
Replies

Tcl script on Cisco 1941 router to change IP address on interface and to remove/add IP route statements

Can someone please share with me an example of a tcl script to change an IP address on an interface and well as add/remove IP route statements? 

 

Thank you,

Jacob

1 Reply 1

Hello,

 

here is a very simple TCL script to add an IP address (192.168.1.1/24) to an interface (GigabitEthernet0/0) and remove a staic route (ip route 0.0.0.0 0.0.0.0 null 0) and add a static route (ip route 10.10.10.0 255.255.255.0 GigabitEthernet0/1). You can expand that script as you wish:

 

tclsh
set ip_address "192.168.1.1"
set mask "255.255.255.0"
ios_config "interface GigabitEthernet0/0" "ip address $ip_address $mask"
ios_config "no ip route 0.0.0.0 0.0.0.0 null 0"

ios_config "ip route 10.10.10.0 255.255.255.0 GigabitEthernet0/1"

Review Cisco Networking for a $25 gift card