本实验通过olive中的logical-system实现,上面拓扑图用到了r1,r2,r3(属于area 0),r4,r5(属于rip).以下是配置实例
olive# show 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;
}
}
}
lo0 {
unit 1 {
family inet {
address 10.0.0.1/32;
}
}
}
}
protocols {
ospf {
area 0.0.0.0 {
interface em1.12;
interface em1.13;
}
}
}
}
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;
}
}
unit 35 {
vlan-id 35;
family inet {
address 10.0.2.2/30;
}
}
}
lo0 {
unit 3 {
family inet {
address 10.0.0.3/32;
}
}
}
}
protocols {
ospf {
export rip-to-ospf3;
area 0.0.0.0 {
interface em3.31;
interface em3.32;
interface em3.34;
}
}
rip {
group RIP {//RIP为自定义group name,只在本logical-system有效
export ospf-to-rip3;//自定义策略,本logical-system有效
neighbor em3.35;//相当于在这些接口上启用rip
}
}
}
policy-options {
policy-statement ospf-to-rip3 {//自定义策略,本logical-system有效
term 2 {
from interface [ em3.35 em3.31 ];//默认情况下,IS-IS,RIP,OSPF,BGP都自动学习邻居路由,但RIP默认不自动发布从邻居学来的rip信息,所以要通过策略把本地接口em3.31,em3.35通过策略发布到rip中去,而ospf,is-is默认发布从邻居学习到路由。bgp默认将从ebgp学到的路由发布到所有的bgp邻居中去,默认将从ibgp学到的路由发布到ebgp邻居中区
then accept;
}
term 1 {
from protocol ospf;//将r3学到的ospf路由发布到rip中区
then accept;
}
term 3 {
from {
route-filter 10.0.2.4/30 exact;//将路由10.0.2.4/30发布到rip中区,exact代表绝对匹配路由表,其他参数longer表示匹配10.0.2.4/30下所有的子网,但不包括其本身;orlonger表示匹配10.0.2.4/30下所有的子网,同时包括其本身;
}
then accept;
}
}
policy-statement rip-to-ospf3 {
term 2 {
from {
route-filter 10.0.2.4/30 exact;
route-filter 10.0.2.0/30 exact;
}
then accept;
}
term 1 {
from interface em3.31;//将接口em3.31连接的路由发布到ospf中去,相当于本地直连接口重分布
then accept;
}
}
}
}
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;
}
}
unit 45 {
vlan-id 45;
family inet {
address 10.0.2.10/30;
}
}
}
lo0 {
unit 4 {
family inet {
address 10.0.0.4/32;
}
}
}
}
protocols {
ospf {
export rip-to-ospf4;
area 0.0.0.0 {
interface em4.42;
interface em4.43;
}
}
rip {
group RIP {
export ospf-to-rip4;
neighbor em4.45;
}
}
}
policy-options {
policy-statement ospf-to-rip4 {
term 2 {
from interface em4.45;
then accept;
}
}
policy-statement rip-to-ospf4 {
term 1 {
from interface em4.45;/frome,then相当于c/c++中的if/then语句from匹配就执行then的动作,不匹配就执行下一条term
then accept;
}
}
}
}
r5 {
interfaces {
em5 {
unit 53 {
vlan-id 35;
family inet {
address 10.0.2.1/30;
}
}
unit 54 {
vlan-id 45;
family inet {
address 10.0.2.9/30;
}
}
}
lo0 {
unit 5 {
family inet {
address 10.0.0.5/32;
}
}
}
}
protocols {
rip {
group RIP {
export rip5;
neighbor em5.53;
neighbor em5.54;
}
}
}
policy-options {
policy-statement rip5 {
term 2 {
from interface [ em5.53 em5.54 ];
then accept;
}
}
}
}
olive# run show route logical-system r1 protocol ospf
inet.0: 10 destinations, 10 routes (10 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
10.0.2.0/30 *[OSPF/150] 00:42:05, metric 0, tag 0
> to 10.0.4.13 via em1.13//150表示是ospf外部学习的路由
内部默认为10
10.0.2.4/30 *[OSPF/10] 00:42:05, metric 2
> to 10.0.4.13 via em1.13
10.0.2.8/30 *[OSPF/150] 00:42:05, metric 0, tag 0
> to 10.0.4.6 via em1.12
to 10.0.4.13 via em1.13
10.0.4.8/30 *[OSPF/10] 00:42:11, metric 2
> to 10.0.4.6 via em1.12
224.0.0.5/32 *[OSPF/10] 06:02:53, metric 1
MultiRecv
olive# run show route logical-system r2 protocol ospf
inet.0: 10 destinations, 10 routes (10 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
10.0.2.0/30 *[OSPF/150] 00:44:21, metric 0, tag 0
to 10.0.4.5 via em2.21
> to 10.0.4.9 via em2.24
10.0.2.4/30 *[OSPF/10] 00:44:30, metric 2
> to 10.0.4.9 via em2.24
10.0.2.8/30 *[OSPF/150] 00:44:30, metric 0, tag 0
> to 10.0.4.9 via em2.24
10.0.4.12/30 *[OSPF/10] 00:44:26, metric 2
> to 10.0.4.5 via em2.21
224.0.0.5/32 *[OSPF/10] 06:05:08, metric 1
MultiRecv
[edit]
olive# run show route logical-system r5 protocol rip
inet.0: 10 destinations, 10 routes (10 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
10.0.2.4/30 *[RIP/100] 00:46:03, metric 2, tag 0
> to 10.0.2.2 via em5.53
10.0.4.4/30 *[RIP/100] 00:45:14, metric 2, tag 0
> to 10.0.2.2 via em5.53//rip无论从内外部学习的路由都默认为100
10.0.4.8/30 *[RIP/100] 00:45:14, metric 2, tag 0
> to 10.0.2.2 via em5.53
10.0.4.12/30 *[RIP/100] 00:46:00, metric 2, tag 0
> to 10.0.2.2 via em5.53
224.0.0.9/32 *[RIP/100] 00:46:03, metric 1
MultiRecv
转载于:https://blog.51cto.com/rista/936921