James,
This does not do exactly what you ask for, but it is how I transform the IPE
configurations to match my personal lab setup. It should give you an idea
of how I tackled a similar problem.
<script>
#!/bin/bash
# tl-checklist
# 2010-07-25 Jud Bishop
# This replaces a checklist I had made to make sure that the initial lab
# configurations match the physical make up of my routers.
LAB=${1}
if [[ $# -ne 1 ]]
then
echo -e "Usage: ${0} LAB-X\n ${0} LAB-1\n"
exit 1
# If the check-list file exists, this script has been run before,
# don't run it again.
elif [[ -e "/tftpboot/VOL-1/${LAB}/check-list" ]]
then
echo -e "\n${0} has been run on this directory before."
echo -e "Please remove /tftpboot/VOL-1/${LAB}/check-list."
echo -e "And run the script again."
exit 1
else
touch "/tftpboot/VOL-1/${LAB}/check-list"
# Copy the whole directory as a backup. Saves time later if you
need to run it again.
if [[ ! (-d /tftpboot/VOL-1/${LAB}.0) ]]
then
cp -r "/tftpboot/VOL-1/${LAB}" "/tftpboot/VOL-1/${LAB}.0"
fi
fi
# Work our way through all of the routers and switches.
for I in R1 R2 R4 R5 R6 R7 R9 Cat1 Cat2 Cat3 Cat4 BB1 BB2 BB3
do
CONF="/tftpboot/VOL-1/${LAB}/INITIAL/${I}.txt"
# The $$ on the end is just in case you run this script multiple
times
# the oldest file in an ls -tlr will be the true original.
SAVE="/tftpboot/VOL-1/${LAB}/INITIAL/${I}.txt.$$"
if [ -e $CONF ]
then
mv $CONF $SAVE
echo $I
case $I in
R1 )
sed 's/^boot.*//g
s/^warm.*//g
s/clock rate 2000000/clock rate 128000/g' $SAVE
>$CONF
;;
R2 )
sed 's/^boot.*//g
s/^warm.*//g
s/clock rate 2000000/clock rate 128000/g
s/Serial0\/2\/0/Serial0\/0/g
s/Serial0\/1\/0/Serial0\/1/g
s/GigabitEthernet0/Ethernet1/g' $SAVE >$CONF
;;
R4 )
sed 's/^boot.*//g
s/^warm.*//g
s/clock rate 2000000/clock rate 128000/g
s/Serial0\/2\/0/Serial0\/0/g' $SAVE >$CONF
;;
R5 )
sed 's/^boot.*//g
s/^warm.*//g
s/clock rate 2000000/clock rate 128000/g
s/Serial0\/2\/0/Serial0\/0\/0/g' $SAVE >$CONF
;;
R6 )
sed 's/^boot.*//g
s/^warm.*//g
s/clock rate 2000000/clock rate 128000/g
s/Serial0\/2\/0/Serial0\/0\/0/g;
s/Serial0\/2\/1/Serial0\/0\/1/g' $SAVE >$CONF
;;
R7 )
sed 's/^boot-start-marker.*/interface
TokenRing2\/0\n shut/g
s/^boot-end-marker.*//g
s/^warm.*//g
s/clock rate 2000000/clock rate 128000/g
s/Serial0\/0\/0/Serial0\/0/g' $SAVE >$CONF
;;
R9 )
sed 's/^boot-start-marker.*/interface
TokenRing0\/0\n shut/g
s/^boot-end-marker.*/interface TokenRing1\/0\n
shut/g
s/^warm.*//g
s/clock rate 2000000/clock rate 128000/g
s/FastEthernet0\/1/FastEthernet1\/0/g
s/Serial0\/2\/0/Serial0\/0/g;
s/Serial0\/2\/1/Serial0\/1/g' $SAVE >$CONF
;;
Cat1 )
sed "s/hostname .*/hostname ${I}/g
s/GigabitEthernet0\/2/FastEthernet0\/12/g" $SAVE
>$CONF
;;
Cat2 | Cat3 )
sed "s/hostname .*/hostname ${I}/g" $SAVE >$CONF
;;
Cat4 )
sed "s/hostname .*/hostname ${I}/g
s/FastEthernet/GigabitEthernet/g" $SAVE >$CONF
;;
BB1 | BB2 )
sed "s/hostname .*/hostname ${I}/g
s/^boot-start-marker.*/interface TokenRing0\/0\n
shut/g
s/^boot-end-marker.*//g
s/Ethernet0\/0/FastEthernet0\/0/g
s/^warm.*//g" $SAVE >$CONF
;;
BB3 )
sed "s/hostname .*/hostname ${I}/g
s/^boot-start-marker.*/interface TokenRing0\/0\n
shut/g
s/^boot-end-marker.*/interface TokenRing2\/0\n
shut/g
s/Ethernet0\/0/FastEthernet0\/0/g
s/^warm.*/interface TokenRing3\/0\n shut/g" $SAVE
>$CONF
;;
esac
fi
done
</script>
On Wed, May 18, 2011 at 8:47 PM, James Roc <[email protected]> wrote:
> Hi,
>
> I am going through IPexpert Vol 1 on dynamips and am looking for the best
> way to modify the CAT switch initial configs to sync with the dyanmips 3725
> NM-16ESW module.
>
> The routers are fairly straight forward with the sed commands below but the
> switches are a bit tricker. Does anyone have some scripts to do this?
>
> Thanks
> James
>
> Re: [OSL | CCIE_RS] Script to clean up IPExpert config files for dynamips
> Tyson Scott
> Mon, 24 May 2010 19:15:51 -0700
>
> If you use linux the fastest way to do this is with sed.
>
> For example. Let's say you download the configuration file to
> /home/jeff/IPExpert/
> You would then have the subfolders
> LAB-1/INITIAL/
> LAB-1/FINAL/
> etc etc...
>
> from the Jeff folder simply type
> sed 's/GigabitEthernet/FastEthernet/g' -i IPexpert/*/*/R2.txt
> sed 's/Serial0\//Serial/g' -i IPexpert/*/*/R2.txt
> sed 's/Serial0\//Serial/g' -i IPexpert/*/*/R4.txt
> sed 's/Serial0\//Serial/g' -i IPexpert/*/*/R5.txt
> sed 's/Serial0\//Serial/g' -i IPexpert/*/*/R6.txt
>
> very simple
>
> You can also take stuff out
> sed 's/memory-size iomem/!/g' -i IPexpert/*/*/*
> sed 's/warm-reboot/!/g' -i IPexpert/*/*/*
> sed 's/scheduler allocate/!/g' -i IPexpert/*/*/*
>
> Those are a few commands that seem to cause problems with Dynamips if you
> don't take them out of the configuration.
>
> Let me know if you have other questions.
>
> Regards,
>
> Tyson Scott - CCIE #13513 R&S, Security, and SP
> Managing Partner / Sr. Instructor - IPexpert, Inc.
> Mailto: [email protected]
> Telephone: +1.810.326.1444, ext. 208
> Live Assistance, Please visit: www.ipexpert.com/chat
> eFax: +1.810.454.0130
>
> IPexpert is a premier provider of Self-Study Workbooks, Video on Demand,
> Audio Tools, Online Hardware Rental and Classroom Training for the Cisco
> CCIE (R&S, Voice, Security & Service Provider) certification(s) with
> training locations throughout the United States, Europe, South Asia and
> Australia. Be sure to visit our online communities at
> www.ipexpert.com/communities and our public website at www.ipexpert.com
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of Matt Hill
> Sent: Monday, May 24, 2010 10:09 PM
> To: jeff m
> Cc: [email protected]
> Subject: Re: [OSL | CCIE_RS] Script to clean up IPExpert config files for
> dynamips
>
> I use copy/replace on my favourite text editing program (gedit in this
> instance).
>
> I modify all startup configs to suit the dynamips topology prior to
> beginning the lab. I also save these files for later use if needed.
>
> Cheers,
> Matt
>
> CCIE #22386
> CCSI #31207
>
> On 25 May 2010 11:54, jeff m <[email protected]> wrote:
> > Subject pretty much says it all, I am trying to get IPExperts volume 1
> > working in dynamips and have run into some issues. Like R2's config
> using
> > gig interfaces instead of fastE(unless I am mistaken dynamips has no
> option
> > for gig interfaces) and using 0/0/0 instead of 0/0. Does anyone have a
> > script to fix these issues across all the files or am I stuck manually
> > editing them?
> >
> > Thanks,
> > Jeff
> >
> > _______________________________________________
> > For more information regarding industry leading CCIE Lab training, please
> > visit www.ipexpert.com
> _______________________________________________
> For more information regarding industry leading CCIE Lab training, please
> visit www.ipexpert.com
>
> Are you a CCNP or CCIE and looking for a job? Check out
> www.PlatinumPlacement.com
>
_______________________________________________
For more information regarding industry leading CCIE Lab training, please visit
www.ipexpert.com
Are you a CCNP or CCIE and looking for a job? Check out
www.PlatinumPlacement.com