03-11-2009 03:41 PM - edited 03-04-2019 03:54 AM
Hi,
I am attempting to create several subinterfaces on a serial port to simulate customer connections. Given this will be 50-100 subinterfaces, is there a script that can be used for this?
Solved! Go to Solution.
03-11-2009 09:50 PM
Hold on a sec. You actually try to create a variable as a number! that's not allowed
If you want from 50 to 100 subinterfaces, the correct syntax is
#!/usr/bin/perl
for ($i = 50; $i <= 100; $i++)
{
print "int Serial0/0.$i\n";
print "ip address 192.168.1.$i 255.255.255.0\n";
print "no shut\n\n";
}
03-11-2009 07:35 PM
int range fa0/0.1 - FastEthernet 0/0.100
no shut
will create 100 sub interfaces.
Now that won't save you of putting in ip addresses on those. If you need to do that.
03-11-2009 07:48 PM
this will only work for ethernet interfaces,not serial.
03-11-2009 07:58 PM
Yep sorry..you're right.. I did not see you are looking for serial
However here is a script in perl. You need to have perl to run this. (there is a windows version called active perl. or just go on any linux and create this file and name it script.pl and execute it with : perl script.pl
#!/usr/bin/perl
for ($i = 0; $i <= 100; $i++)
{
print "int Serial0/0.$i\n";
print "ip address 192.168.1.$i 255.255.255.0\n";
print "no shut\n\n";
}
____
Modify the iteration of i according to how many ifaces you need
03-11-2009 09:15 PM
I've tried the script on a linux box
#!/usr/bin/perl
for ($50 = 0; $50 <= 100; $50++)
{
print "int Serial0/0.$50\n";
print "ip address 192.168.1.$50 255.255.255.0\n";
print "no shut\n\n";
}
I keep getting the below error
"Modification of a read-only value attempted at subint.pl line 7."
03-11-2009 09:50 PM
Hold on a sec. You actually try to create a variable as a number! that's not allowed
If you want from 50 to 100 subinterfaces, the correct syntax is
#!/usr/bin/perl
for ($i = 50; $i <= 100; $i++)
{
print "int Serial0/0.$i\n";
print "ip address 192.168.1.$i 255.255.255.0\n";
print "no shut\n\n";
}
03-11-2009 10:00 PM
thanks for that!
Ran it and worked as i was hoping for
03-11-2009 08:28 PM
Or there you go mate, an even more simple solution create a cisco.bat file in windows with this content. Play out with the for loop to generate as many interfaces as you need:
ECHO OFF
for /L %%N in (0, 1, 100) do (echo int Serial0/0.%%N
echo ip address 192.168.1.%%N 255.255.255.0
echo no shut
)
03-11-2009 08:55 PM
For scripting in router, try "tclsh".
Although most cisco test engineers uses external tcl scripts on their workstations.
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: