IT技术互动交流平台

juniper利用policy来重分布ospf到static中

作者:Rista  发布日期:2012-07-18 09:33:29

 Juniper中要实现像cisco那样的重分布功能就要通过policy来实现,下面就是我的一个实例:其功能就是把static路由重分布到ospf中,下面是拓扑图

 


 

把R1的默认路由重分布到OSPF中

配置如下:## ## Last changed: 2012-07-18 06:03:09 CST

version 12.1R1.9;
logical-systems {
    r1 {
        interfaces {
            em1 {
                unit 12 {
                    vlan-id 12;
                    family inet {
                        address 10.0.4.5/30;
                    }
                }
                unit 13 {
                    vlan-id 13;
                    family inet {
                        address 10.0.4.14/30;
                    }
                }
                unit 15 {
                    vlan-id 15;        
                    family inet {
                        address 172.30.25.1/30;
                    }
                }
            }
            lo0 {
                unit 1 {
                    family inet {
                        address 10.0.0.1/32;
                    }
                }
            }
        }
        protocols {
            ospf {
                export default-static;//输出policy-options中的策略default-                                          static
                area 0.0.0.0 {
                    interface em1.12;
                    interface em1.13;
                }
            }
        }
        policy-options {
            policy-statement default-static//自定义策略default-static {
                term accept-default-static//自定义term accept-default-                                                  static {
                    from {
                        protocol static;
                        route-filter 0.0.0.0/0 exact;//0.0.0.0/0是要过滤的静态路由条目,exact表示精确匹配
                    }
                    then accept;//行动结果是接受
                }
            }
        }
        routing-options {
            static {
                route 0.0.0.0/0 next-hop 172.30.25.2;
            }
        }
    }
    r2 {
        interfaces {                   
            em2 {
                unit 21 {
                    vlan-id 12;
                    family inet {
                        address 10.0.4.6/30;
                    }
                }
                unit 24 {
                    vlan-id 24;
                    family inet {
                        address 10.0.4.10/30;
                    }
                }
            }
            lo0 {
                unit 2 {
                    family inet {
                        address 10.0.0.2/32;
                    }
                }
            }
        }
        protocols {
            ospf {
                area 0.0.0.0 {
                    interface em2.21;
                    interface em2.24;
                }
            }
        }
    }
    r3 {
        interfaces {
            em3 {
                unit 31 {
                    vlan-id 13;
                    family inet {
                        address 10.0.4.13/30;
                    }
                }
                unit 34 {              
                    vlan-id 34;
                    family inet {
                        address 10.0.2.5/30;
                    }
                }
            }
            lo0 {
                unit 3 {
                    family inet {
                        address 10.0.0.3/32;
                    }
                }
            }
        }
        protocols {
            ospf {
                area 0.0.0.0 {
                    interface em3.31;
                    interface em3.34;
                }
            }
        }
    }
    r4 {
        interfaces {
            em4 {
                unit 42 {
                    vlan-id 24;
                    family inet {
                        address 10.0.4.9/30;
                    }
                }
                unit 43 {
                    vlan-id 34;
                    family inet {
                        address 10.0.2.6/30;
                    }
                }
            }
            lo0 {
                unit 4 {               
                    family inet {
                        address 10.0.0.4/24;
                    }
                }
            }
        }
        protocols {
            ospf {
                area 0.0.0.0 {
                    interface em4.42;
                    interface em4.43;
                }
            }
        }
    }
    r5 {
        interfaces {
            em5 {
                unit 51 {
                    vlan-id 15;
                    family inet {
                        address 172.30.25.2/30;
                    }
                }
            }
        }
        routing-options {
            static {
                route 172.30.25.0/30 next-hop 172.30.25.1;
            }
        }
    }
}
interfaces {
    em0 {
        traceoptions {
            flag all;
        }
        unit 0 {
            family inet {
                address 192.168.1.254/24;
            }
        }
    }
    em1 {
        vlan-tagging;
    }
    em2 {
        vlan-tagging;
    }
    em3 {
        vlan-tagging;
    }
    em4 {
        vlan-tagging;
    }
    em5 {
        vlan-tagging;
    }
}
路由表如下:olive> show route logical-system all 
 
logical-system: r5
 
inet.0: 2 destinations, 3 routes (2 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
 
172.30.25.0/30     *[Direct/0] 00:10:57
                    > via em5.51
                    [Static/5] 00:10:57
                    > to 172.30.25.1 via em5.51
172.30.25.2/32     *[Local/0] 00:10:57
                      Local via em5.51
-----
 
logical-system: r1
 
inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
 
0.0.0.0/0          *[Static/5] 00:10:57//静态路由默认管理距离为5
                    > to 172.30.25.2 via em1.15
10.0.0.1/32        *[Direct/0] 11:02:30
                    > via lo0.1
10.0.2.4/30        *[OSPF/10] 00:10:13, metric 2
                    > to 10.0.4.13 via em1.13
10.0.4.4/30        *[Direct/0] 00:10:57
                    > via em1.12
10.0.4.5/32        *[Local/0] 00:10:57
                      Local via em1.12
10.0.4.8/30        *[OSPF/10] 00:10:07, metric 2
                    > to 10.0.4.6 via em1.12
10.0.4.12/30       *[Direct/0] 00:10:57
                    > via em1.13
10.0.4.14/32       *[Local/0] 00:10:57
                      Local via em1.13
172.30.25.0/30     *[Direct/0] 00:10:57
                    > via em1.15
172.30.25.1/32     *[Local/0] 00:10:57
                      Local via em1.15
224.0.0.5/32       *[OSPF/10] 11:02:43, metric 1
                      MultiRecv
-----                                  
 
logical-system: r3
 
inet.0: 9 destinations, 9 routes (9 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
 
0.0.0.0/0          *[OSPF/150] 00:10:13, metric 0, tag 0
                    > to 10.0.4.14 via em3.31//OSPF外部路由默认管理距离为                                                150
10.0.0.3/32        *[Direct/0] 11:02:25
                    > via lo0.3
10.0.2.4/30        *[Direct/0] 00:10:57
                    > via em3.34
10.0.2.5/32        *[Local/0] 00:10:57
                      Local via em3.34
10.0.4.4/30        *[OSPF/10] 00:10:13, metric 2
                    > to 10.0.4.14 via em3.31
10.0.4.8/30        *[OSPF/10] 00:10:12, metric 2
                    > to 10.0.2.6 via em3.34
10.0.4.12/30       *[Direct/0] 00:10:57
                    > via em3.31
10.0.4.13/32       *[Local/0] 00:10:57
                      Local via em3.31
224.0.0.5/32       *[OSPF/10] 11:02:43, metric 1
                      MultiRecv
-----
 www.it165.net
logical-system: r2
 
inet.0: 9 destinations, 9 routes (9 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
 
0.0.0.0/0          *[OSPF/150] 00:10:07, metric 0, tag 0
                    > to 10.0.4.5 via em2.21
10.0.0.2/32        *[Direct/0] 11:02:31
                    > via lo0.2
10.0.2.4/30        *[OSPF/10] 00:10:17, metric 2
                    > to 10.0.4.9 via em2.24
10.0.4.4/30        *[Direct/0] 00:10:57
                    > via em2.21
10.0.4.6/32        *[Local/0] 00:10:57
                      Local via em2.21 
10.0.4.8/30        *[Direct/0] 00:10:57
                    > via em2.24
10.0.4.10/32       *[Local/0] 00:10:57
                      Local via em2.24
10.0.4.12/30       *[OSPF/10] 00:10:07, metric 2
                    > to 10.0.4.5 via em2.21
224.0.0.5/32       *[OSPF/10] 11:02:43, metric 1
                      MultiRecv
-----
 
logical-system: r4
 
inet.0: 10 destinations, 10 routes (10 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
 
0.0.0.0/0          *[OSPF/150] 00:10:07, metric 0, tag 0
                      to 10.0.4.10 via em4.42
                    > to 10.0.2.5 via em4.43
10.0.0.0/24        *[Direct/0] 00:54:19
                    > via lo0.4
10.0.0.4/32        *[Local/0] 00:54:19
                      Local via lo0.4
10.0.2.4/30        *[Direct/0] 00:10:57
                    > via em4.43
10.0.2.6/32        *[Local/0] 00:10:57
                      Local via em4.43
10.0.4.4/30        *[OSPF/10] 00:10:17, metric 2
                    > to 10.0.4.10 via em4.42
10.0.4.8/30        *[Direct/0] 00:10:57
                    > via em4.42
10.0.4.9/32        *[Local/0] 00:10:57
                      Local via em4.42
10.0.4.12/30       *[OSPF/10] 00:10:12, metric 2
                    > to 10.0.2.5 via em4.43
224.0.0.5/32       *[OSPF/10] 00:55:31, metric 1
                      MultiRecv
 

本文出自 “Rista” 博客
 

Tag标签: juniper   policy   ospf  
  • 专题推荐

About IT165 - 广告服务 - 隐私声明 - 版权申明 - 免责条款 - 网站地图 - 网友投稿 - 联系方式
本站内容来自于互联网,仅供用于网络技术学习,学习中请遵循相关法律法规