May 05, 2010

IOS to JUNOS Style Configuration Converter Using AWK

Somebody resign.. I'll get extra work to do :) Yes, now I handle node called Content Service Gateway, another thing to learn, just be positive :)

Deep packet inspection configuration is so complex — No, that's hyperbolic, so many rules. The configuration is designed to charge everything necessary so You won't lose Your money. And the important thing is, keep it clean to avoid miss-charging :D

Beyond of that, Cisco IOS "sh run" configuration will make You headache when You read it. I'd like to say "No", I would not read it, better convert it :)


So I wrote this AWK script, that helps me so much. What it would do is display Cisco IOS "sh run" configuration style into Juniper JUNOS "display set" style :)

So, when you input following lines..

IOS sample configuration output

interface GigabitEthernet0/0
no ip address
no keepalive                                                      
standby use-bia                                                   
hold-queue 600 in
line con 0
password 7 123456789012345678
line vty 0 4
access-class telnet-acl in
password 7 123456789012345678

into this script

awk 'BEGIN{map=""; matc="";};
/^[a-z]/{map=$0; matc="";};
/^ [a-z]/{matc=$0;}; 
{if (map && matc){print map,matc;}; matc=""; }'

Will result this..

Cleaner and more readable output

interface GigabitEthernet0/0  no ip address
interface GigabitEthernet0/0  no keepalive
interface GigabitEthernet0/0  standby use-bia
interface GigabitEthernet0/0  hold-queue 600 in
line con 0  password 7 123456789012345678
line vty 0 4  access-class telnet-acl in
line vty 0 4  password 7 123456789012345678

Done! Let's analyze it..

Complex...

... !@#$%^& [HEADACHE]