才子佳人博客

我的故事我讲述

EX4200上实现routing policy 路由策略 export,import 实例
 
来源:xjh  编辑:xjh  2015-03-17

环境:Juniper EX4200
路由实例:new_instance,new_instance1-4

文章给出EX4200上启动5个路由实例,并实现routing policy 路由策略 export,import 的实例,大致步骤如下:
1.配置路由策略,在policy-options顶层配置
root@ex4200# top
root@ex4200# edit policy-options

{master:0}[edit policy-options]
root@ex4200# show
policy-statement default-static {

term accept-default-static {

from {

protocol static;

route-filter 172.16.1.0/24 exact;

route-filter 192.168.0.0/16 orlonger;

}

then accept;

}
}
policy-statement my-reject-static {

term reject-default-static {

from {

route-filter 172.16.1.0/24 exact;

route-filter 192.168.0.0/16 orlonger;

}

then reject;

}
}
2.在new_instance路由器实例上配置静态路由
{master:0}[edit routing-instances new_instance routing-options]
root@ex4200# set static route 172.16.1.0/24 next-hop 101.7.158.1
root@ex4200# set static route 192.168.2.0/24 next-hop 101.7.156.2
{master:0}[edit routing-instances new_instance routing-options]
root@ex4200# show
static {

route 172.16.1.0/24 next-hop 101.7.158.1;

route 192.168.2.0/24 next-hop 101.7.156.2;
}

3.在new_instance实例的ospf协议层设置导出策略,仅仅把该路由器实例new_instance的静态路由172.16.1.0/24转换成ospf路由,以便其他路由器学习到该条路由,这样就不用重复在其他路由器上配置该静态路由。
{master:0}[edit routing-instances new_instance protocols ospf]
root@ex4200# set export default-static

4.其他实例接受external ospf,但是new_instance4 路由实例拒绝接受 external ospf路由

root@ex4200# edit routing-instances new_instance4 protocols ospf
{master:0}[edit routing-instances new_instance4 protocols ospf]
root@ex4200# set import my-reject-static

{master:0}[edit routing-instances new_instance4]
root@ex4200# show
instance-type virtual-router;
interface ge-0/0/19.0;
interface ge-0/0/21.0;
interface ge-0/0/23.0;
protocols {

ospf {

import my-reject-static;

area 0.0.0.1 {

interface ge-0/0/19.0;

interface ge-0/0/21.0;

interface ge-0/0/23.0;

}

}
}


5.查看其他路由器上从new_instance路由器实例学习到的ospf动态路由,注意external OSPF路由,其权值为 OSPF/150。

new_instance3.inet.0: 13 destinations, 13 routes (13 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both


101.7.152.0/24 *[OSPF/10] 01:21:01, metric 2

> to 101.7.151.1 via ge-0/0/5.0

to 101.7.153.1 via ge-0/0/9.0
101.7.156.0/24 *[OSPF/10] 01:21:01, metric 2

> to 101.7.151.1 via ge-0/0/5.0
101.7.157.0/24 *[OSPF/10] 01:20:51, metric 2

> to 101.7.151.1 via ge-0/0/5.0
101.7.158.0/24 *[OSPF/10] 01:21:01, metric 3

> to 101.7.151.1 via ge-0/0/5.0
172.16.1.0/24 *[OSPF/150] 01:21:01, metric 0, tag 0

> to 101.7.151.1 via ge-0/0/5.0
192.168.2.0/24 *[OSPF/10] 01:21:01, metric 2

> to 101.7.153.1 via ge-0/0/9.0
192.168.50.0/24 *[OSPF/150] 00:54:22, metric 0, tag 0

> to 101.7.151.1 via ge-0/0/5.0
224.0.0.5/32 *[OSPF/10] 01:22:22, metric 1

MultiRecv

6.查看new_instance4路由器实例学习到的ospf动态路由,无external OSPF路由,其权值为 OSPF/150。

new_instance4.inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both


101.7.151.0/24 *[OSPF/10] 01:21:06, metric 2

to 101.7.152.1 via ge-0/0/19.0

> to 101.7.153.2 via ge-0/0/21.0
101.7.156.0/24 *[OSPF/10] 01:21:01, metric 2

> to 101.7.152.1 via ge-0/0/19.0
101.7.157.0/24 *[OSPF/10] 01:20:51, metric 2

> to 101.7.152.1 via ge-0/0/19.0
101.7.158.0/24 *[OSPF/10] 01:21:01, metric 3

> to 101.7.152.1 via ge-0/0/19.0
224.0.0.5/32 *[OSPF/10] 01:22:22, metric 1

MultiRecv


routing_policy_ospf_external.txt

ref:http://junostech.blog.51cto.com/5354467/913053/

All routing protocols store the routes that they learn in the routing table. The routing table uses this collected route information to determine the active routes to destinations. The routing table then installs the active routes into its forwarding table and also exports them back into the routing protocols. It is these exported routes that the protocols advertise.

For each protocol, you control which routes the protocol stores in the routing table and which routes the routing table exports into the protocol by defining a routing policy for that protocol. For information about defining a routing policy, see the JUNOS Policy Framework Configuration Guide.

By default, if a router has multiple OSPF areas, learned routes from other areas are automatically installed into area 0 of the routing table.

To apply routing policies that affect how the routing table exports routes into OSPF, include the export statement:

export [ policy-names ];

OSPF import policy allows users to define policy to prevent adding OSPF routes to the routing table. This filtering happens when OSPF installs the route in the routing table. You can filter the routes, but not LSA flooding. The import policy can filter on any attribute of the OSPF route.

To filter OSPF routes from being added to the routing table, include the import statement:

import [ policy-names ];



分类:网络日志| 查看评论
相关文章
文章点击排行
本年度文章点击排行
发表评论:
  • 昵称: *
  • 邮箱: *
  • 网址:
  • 评论:(最多100字)
  • 验证码: