[j-nsp] prefix-list: ios 2 junos

Bit Gossip bit.gossip at chello.nl
Sun Feb 22 14:55:28 EST 2009


Ever had to translate 38000 lines of prefix-lists from ios to junos....
I had, and so I wrote this little bash script that does it for you.
Still very basic so it does only permit form and no 'ge' nor 'le'; only
plain form.

Takes from stdin the ios prefix-list as in running-config and spits out
the junos form.
You can pipe to it the entire running-config as it filters by itself the
prefix-lists and discards the rest.

HTH,
Bit.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#!/bin/bash

# Developed by TosoSoft 2009
while read W1 W2 PL_NAME W3 W4 W5 PREFIX; do
 PL_NAME=`echo $PL_NAME | tr 'a-z' 'A-Z'`
 echo $PREFIX | grep -q e
 GOOD=$?
 if [[ $W5 = "permit" ]] && [[ $GOOD = 1 ]]
 then
  if [[ "$PL_NAME" != "$PL_PREVIOUS_NAME" ]]
   then
    if [ -n "$PL_PREVIOUS_NAME" ]
     then
      echo \}
    fi
    echo $W2 $PL_NAME '{'
    echo $PREFIX\;
   else
    echo $PREFIX\;
  fi
  PL_PREVIOUS_NAME="$PL_NAME"
 fi
done
echo \}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Example

$  echo 'ip prefix-list bit-gossip seq 5 permit 1.1.1.0/24'\
| ./prefixlist-2j.sh
prefix-list BIT-GOSSIP {
1.1.1.0/24;
}




More information about the juniper-nsp mailing list