闲来无事,在单位做了一个MPLS实验,贴上配置分享大家。Mpls *** Option A.

est@RTE-10.0.3.4# show logical-systems
r4 {
    interfaces {
        fe-0/3/1 {
            unit 230 {
                description TO_r5;
                vlan-id 230;
                family inet {
                    address 21.21.21.1/30;
                }
                family mpls;
            }
        }
        fe-0/3/2 {
            unit 220 {
                description TO_r3;
                vlan-id 220;
                family inet {
                    address 20.20.20.2/30;
                }
                family mpls;
            }
       
        lo0 {
            unit 4 {
                family inet {
                    address 4.4.4.4/32;
                }
            }
        }
    }
    protocols {
        rsvp {
            interface all;
        }
        mpls {
            label-switched-path TO_r2 {
                to 2.2.2.2;
            }
            interface all;
        }
        bgp {
            group r2 {
                type internal;
                local-address 4.4.4.4;
                family inet {
                    unicast;
                }
                family inet-*** {
                    unicast;           
                }
                neighbor 2.2.2.2;
            }
        }
        ospf {
            traffic-engineering;
            area 0.0.0.0 {
                interface fe-0/3/2.220;
                interface lo0.4;
            }
        }
    }
    routing-instances {
        to-r5 {
            instance-type vrf;
            interface fe-0/3/1.230;
            route-distinguisher 2:200;
            vrf-target target:1:100;
            protocols {
                bgp {
                    group r5 {
                        neighbor 21.21.21.2 {
                            peer-as 200;
                        }
                    }
                }
            }
        }
    }
    routing-options {
        autonomous-system 100;
    }
}
r5 {
    interfaces {
        fe-0/3/1 {
            unit 240 {
                description TO_r6;
                vlan-id 240;
                family inet {
                    address 22.22.22.1/30;
                }
                family mpls;
            }
        }
        fe-0/3/2 {
            unit 230 {
                description TO_r4;  
                vlan-id 230;
                family inet {
                    address 21.21.21.2/30;
                }
                family mpls;
            }
        }
        lo0 {
            unit 5 {
                family inet {
                    address 5.5.5.5/32;
                }
            }
        }
    }
    protocols {
        rsvp {
            interface all;
        }
        mpls {
            label-switched-path r7 {
                to 7.7.7.7;
            }
            interface all;
        }
        bgp {
            group r7 {
                type internal;
                local-address 5.5.5.5;
                family inet {
                    unicast;
                }
                family inet-*** {
                    unicast;
                }
                neighbor 7.7.7.7;
            }
        }
        ospf {
            traffic-engineering;
            area 0.0.0.0 {
                interface fe-0/3/1.240;
                interface lo0.5;
            }
        }
    }
    routing-instances {
        to-r4 {                     
            instance-type vrf;
            interface fe-0/3/2.230;
            route-distinguisher 3:300;
            vrf-target target:1:100;
            protocols {
                bgp {
                    group r4 {
                        peer-as 100;
                        neighbor 21.21.21.1;
                    }
                }
            }
        }
    }
    routing-options {
        autonomous-system 200;
    }
}
r1 {
    interfaces {
        fe-0/3/1 {
            unit 200 {
                description TO_r1;
                vlan-id 200;
                family inet {
                    address 18.18.18.1/30;
                }
                family mpls;
            }
        }
        lo0 {
            unit 1 {
                family inet {
                    address 1.1.1.1/32;
                }
            }
        }
    }
    protocols {
        ospf {
            area 0.0.0.2 {
                interface fe-0/3/1.200;
                interface lo0.1;
            }
        }
    }
}
r8 {                                  
    interfaces {
        fe-0/3/2 {
            unit 260 {
                vlan-id 260;
                family inet {
                    address 24.24.24.2/30;
                }
                family mpls;
            }
        }
        lo0 {
            unit 8 {
                family inet {
                    address 8.8.8.8/32;
                }
            }
        }
    }
    protocols {
        bgp {
            export direct;
            group r8 {
                type internal;
                neighbor 24.24.24.1;
            }
        }
    }
    policy-options {
        policy-statement direct {
            term 1 {
                from {
                    protocol direct;
                    interface lo0.8;
                }
                then accept;
            }
        }
    }
    routing-options {
        autonomous-system 20;
    }
}
r3 {
    interfaces {
        fe-0/3/1 {
            unit 220 {
                description TO_r4;
                vlan-id 220;           
                family inet {
                    address 20.20.20.1/30;
                }
                family mpls;
            }
        }
        fe-0/3/2 {
            unit 210 {
                description TO_r2;
                vlan-id 210;
                family inet {
                    address 19.19.19.2/30;
                }
                family mpls;
            }
        }
        lo0 {
            unit 3 {
                family inet {
                    address 3.3.3.3/32;
                }
            }
        }
    }
    protocols {
        rsvp {
            interface all;
        }
        mpls {
            interface all;
        }
        ospf {
            traffic-engineering;
            area 0.0.0.0 {
                interface all;
            }
        }
    }
}
r6 {
    interfaces {
        fe-0/3/1 {
            unit 250 {
                description TO_r7;
                vlan-id 250;
                family inet {
                    address 23.23.23.1/30;
                }                      
                family mpls;
            }
        }
        fe-0/3/2 {
            unit 240 {
                description TO_r5;
                vlan-id 240;
                family inet {
                    address 22.22.22.2/30;
                }
                family mpls;
            }
        }
        lo0 {
            unit 6 {
                family inet {
                    address 6.6.6.6/32;
                }
            }
        }
    }
    protocols {
        rsvp {
            interface all;
        }
        mpls {
            interface all;
        }
        ospf {
            traffic-engineering;
            area 0.0.0.0 {
                interface all;
            }
        }
    }
}
r2 {
    interfaces {
        fe-0/3/1 {
            unit 210 {
                description TO_r3;
                vlan-id 210;
                family inet {
                    address 19.19.19.1/30;
                }
                family mpls;
            }
        }                              
        fe-0/3/2 {
            unit 200 {
                description TO_r1;
                vlan-id 200;
                family inet {
                    address 18.18.18.2/30;
                }
                family mpls;
            }
        }
        lo0 {
            unit 2 {
                family inet {
                    address 2.2.2.2/32;
                }
            }
        }
    }
    protocols {
        rsvp {
            interface all;
        }
        mpls {
            label-switched-path TO_r4 {
                to 4.4.4.4;
            }
            interface all;
        }
        bgp {
            group r2 {
                type internal;
                local-address 2.2.2.2;
                family inet {
                    unicast;
                }
                family inet-*** {
                    unicast;
                }
                neighbor 4.4.4.4;
            }
        }
        ospf {
            traffic-engineering;
            area 0.0.0.0 {
                interface fe-0/3/1.210;
                interface lo0.2;
            }
        }                              
    }
    policy-options {
        policy-statement bgp-ospf {
            term 1 {
                from protocol bgp;
                then accept;
            }
            term 2 {
                then reject;
            }
        }
        policy-statement ***export {
            term 1 {
                from protocol ospf;
                then {
                    community add test_comm;
                    accept;
                }
            }
            term 2 {
                then reject;
            }
        }
        policy-statement ***import {
            term 1 {
                from {
                    protocol bgp;
                    community test_comm;
                }
                then accept;
            }
            term 2 {
                then reject;
            }
        }
        community test_comm members target:1:100;
    }
    routing-instances {
        r1 {
            instance-type vrf;
            interface fe-0/3/2.200;
            route-distinguisher 1:100;
            vrf-import ***import;
            vrf-export ***export;
            protocols {
                ospf {
                    export bgp-ospf;
                    area 0.0.0.2 {     
                        interface fe-0/3/2.200;
                    }
                }
            }
        }
    }
    routing-options {
        autonomous-system 100;
    }
}
r7 {
    interfaces {
        fe-0/3/1 {
            unit 260 {
                description TO_r8;
                vlan-id 260;
                family inet {
                    address 24.24.24.1/30;
                }
                family mpls;
            }
        }
        fe-0/3/2 {
            unit 250 {
                description TO_r6;
                vlan-id 250;
                family inet {
                    address 23.23.23.2/30;
                }
                family mpls;
            }
        }
        lo0 {
            unit 7 {
                family inet {
                    address 7.7.7.7/32;
                }
            }
        }
    }
    protocols {
        rsvp {
            traceoptions {
                file r7-rsvp;
                flag all;
            }
            interface fe-0/3/2.250;
            interface all;             
        }
        mpls {
            label-switched-path r7 {
                to 5.5.5.5;
            }
            interface fe-0/3/2.250;
            interface all;
        }
        bgp {
            group r7 {
                type internal;
                local-address 7.7.7.7;
                family inet {
                    unicast;
                }
                family inet-*** {
                    unicast;
                }
                neighbor 5.5.5.5;
            }
        }
        ospf {
            traffic-engineering;
            area 0.0.0.0 {
                interface fe-0/3/2.250;
                interface lo0.7;
            }
        }
    }
    policy-options {
        policy-statement ***export {
            term 1 {
                from protocol bgp;
                then {
                    community add comm;
                    accept;
                }
            }
            term 2 {
                then reject;
            }
        }
        policy-statement ***import {
            term 1 {
                from {
                    protocol bgp;
                    community comm;
                }                      
                then accept;
            }
            term 2 {
                then reject;
            }
        }
        community comm members target:1:100;
    }
    routing-instances {
        r8 {
            instance-type vrf;
            interface fe-0/3/1.260;
            route-distinguisher 4:400;
            vrf-import ***import;
            vrf-export ***export;
            protocols {
                bgp {
                    group r8 {
                        type internal;
                        local-as 20;
                        neighbor 24.24.24.2;
                    }
                }
            }
        }
    }
    routing-options {
        autonomous-system 200;
    }
}

[edit]
test@RTE-10.0.3.4#

[edit]