Wednesday, June 9, 2010

Pop Quiz: separate odd and even IP numbers

In Juniper JUNOS, ip/mask could be used to separate odd/even IP numbers. similar to wildcard in Cisco IOS.

[edit firewall family inet]
filter Separate-Numbers {
    /* match even IPs 10.10.10.{0,2,4,6,8,...} */
    term Even-Numbers {
        from {
            source-address {
                10.10.10.0/255.255.255.1;
            }
        }
        then {
            xxxxx;
        }
    }
    /* match odd IPs 10.10.10.{1,3,5,7,9,...} */
    term Odd-Numbers {
        from {
            source-address {
                10.10.10.1/255.255.255.1;
            }
        }
        then {
            xxxxx;
        }
    }
}

No comments: