Junos OS

last person joined: yesterday 

Ask questions and share experiences about Junos OS.
  • 1.  Regular Expressions in JUNOS

    Posted 09-22-2010 05:39

    I am trying to work with some regular expressions defining interfaces using groups in JUNOS (specifically the EX2200).

     

    JUNOS is not recognizing piped regex for some reason. 

     

    Here is what works:

     

    groups

    WIRED_VLAN {
        interfaces {
            "<ge-0/0/[0-9]>" {             
                unit 0 {
                    family ethernet-switching {
                        port-mode access;
                        vlan {
                            members WIRED;
                        }
                    }
                }
            }
        }
    }

     

    Here is what dosn't work:

    groups

    WIRED_VLAN{

     interfaces {
        "<ge-0/0/[0-9|[1][0-9]|2[0-1]>" {
            unit 0 {
                family ethernet-switching {
                    port-mode access;
                    vlan {
                        members WIRED;
                     }
                 }
            }
        }
     }

    }



  • 2.  RE: Regular Expressions in JUNOS
    Best Answer

     
    Posted 09-22-2010 08:45
    Hi,

    you are right, there is a reason 🙂
    One is using wildcards and not regex in configuration groups:

    http://www.juniper.net/techpubs/software/junos/junos93/swconfig-cli/using-wildcards-with-JUNOS-configuration-groups.html#jN17A3D

    Pipe is not allowed here.
    jtb


  • 3.  RE: Regular Expressions in JUNOS

    Posted 09-22-2010 10:48

    Ugh.  So there are a few more configuration gymnastics that I need to do in order to make this work.

     

    I see two options:

     

    1. use interface-range groups (the downside is the requirement to update code)

    2. be more verbose with the config

     

    I tried this and it worked but it is obviously not as elegant as what I was trying to achieve.

     

    interfaces {
        "<ge-0/0/1[0-9]>" {
            unit 0 {
                family ethernet-switching {
                    port-mode access;
                    vlan {
                        members WIRED;
                    }
                }
            }
        }
        "<ge-0/0/2[0-1]>" {
            unit 0 {
                family ethernet-switching {
                    port-mode access;
                    vlan {
                        members WIRED;
                    }
                }
            }
        }
        "<ge-0/0/[0-9]>" {
            unit 0 {
                family ethernet-switching {
                    port-mode access;
                    vlan {
                        members WIRED;
                    }
                }
            }
        }
    }