cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
999
Views
0
Helpful
8
Replies

Creating Multiple Subinterfaces (through script)

echelon360
Level 1
Level 1

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?

1 Accepted Solution

Accepted Solutions

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";

}

View solution in original post

8 Replies 8

c.captari
Level 1
Level 1

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.

this will only work for ethernet interfaces,not serial.

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

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."

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";

}

thanks for that!

Ran it and worked as i was hoping for

c.captari
Level 1
Level 1

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

)

paolo bevilacqua
Hall of Fame
Hall of Fame

For scripting in router, try "tclsh".

Although most cisco test engineers uses external tcl scripts on their workstations.

Getting Started

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: