# L3VPN configuration (OSPF as CE-PE protocol)

# URL

frinx-openconfig-network-instance:network-instances/network-instance=

# OPENCONFIG YANG

{
    "network-instance": [
        {
            "name": ""
            "config": {
                "name": ""
                "type": "L3VRF" //matches vpws-instance-type in ietf
                "route-distinguisher": ""
                "enabled-address-families": ""
                "enabled": true
            }
            
            "interfaces": {
                "interface": [
                    {
                        "config": {
                            "id": 
                        }
                    }
                ]
            }
            
            "inter-instance-policies": {
                "apply-policy": {
                    "config": {
                        "import-policy": [
                            "-route-target-import"
                        ]
                    }
                }
            }
            
            "protocols": {
                "protocol": [
                    {
                        "config": {
                            "identifier": "ospf "
                            "enabled": true
                            "frinx-ospf-extension:export-policy": [
                                ""
                            ]
                        }
                        
                        "ospfv2": {
                            "global": {
                                "as": ""
                                "router-id": ""
                            }
                            "areas": {
                                "area": [
                                    {
                                        "config": {
                                            "identifier": ""
                                        }
                                        "interfaces" {
                                            "interface" [
                                                "id": ""
                                                "config": {
                                                    "id": ""
                                                    "network-type": ""
                                                    "frinx-ospf-extension:enabled": ""
                                                    "metric": 
                                                    "priority": 
                                                }
                                                "frinx-bfd-extension:bfd": {
                                                    "config": {
                                                        "multiplier": 
                                                        "min-interval": 
                                                        "min-receive-interval": 
                                                    }
                                                }
                                                "frinx-ospf-extension:authentication": {
                                                    "config": {
                                                        "enabled": ""
                                                        "type": "auth-type:md5"
                                                        "passwords": {
                                                            "password": [
                                                                {
                                                                    "auth-id": ""
                                                                    "config": {
                                                                        "auth-id": ""
                                                                        "auth-password": ""
                                                                    }
                                                                }
                                                            ]
                                                        }
                                                    }
                                                }
                                            ]
                                        }
                                    }
                                ]
                            }
                        }
                    }
                    {
                        "name": ""
                        "identifier": "frinx-openconfig-policy-types:OSPF3"
                        "config": {
                            "name": ""
                            "identifier": "frinx-openconfig-policy-types:OSPF3"
                        }
                        "ospfv3": {
                            "global": {
                                "stub-router": {
                                    "config": {
                                        "set": true
                                        "advertise-lsas-types": "STUB_ROUTER_MAX_METRIC"
                                        "always": true
                                    }
                                }
                            }
                        }
                    }
                    {
                        "config": {
                            "identifier": "bgp"
                            "enabled": true
                        }
                        
                        "bgp": {
                            "global": {
                                "as": ""
                                "afi-safis": {
                                    "afi-safi": [
                                        "config": {
                                            "afi-safi-name": "ipv4"
                                            "enabled": true
                                        }
                                    ]
                                }
                            }
                        }
                    }
                ]
            }
            "tables": {
                "table": [
                    {
                        "config": {
                            "protocol": "ospf "
                        }
                        "address-family": "ipv4"
                    }
                    {
                        "config": {
                            "protocol": "bgp "
                        }
                        "address-family": "ipv4"
                    }
                ]
            }
            "table-connections": {
                "table-connection": [
                    {
                        "config": {
                            "src-protocol": "" = "ospf "
                            "dst-protocol": "" = "bgp "
                        }
                        "address-family": "ipv4"
                    }
                    {
                        "config": {
                            "src-protocol": "" = "bgp "
                            "dst-protocol": "" = "ospf "
                        }
                        "address-family": "ipv4"
                    }
                ]
            }
        }
    ]
}
frinx-openconfig-routing-policy:routing-policy/defined-sets
{
    "bgp-defined-sets" {
        ext-community-sets {
            ext-community-set [
                {            
                    "config": {
                        "ext-community-set-name": "-route-target-export-set"
                        "ext-community-set-member": [
                            
                            
                            
                        ]
                    }
                }
                {            
                    "config": {
                        "ext-community-set-name": "-route-target-import-set"
                        "ext-community-set-member": [
                            
                            
                            
                        ]
                    }
                }
            ]
        }
    }
}
frinx-openconfig-routing-policy:routing-policy/policy-definitions
{
    "policy-definition" [
        {            
            "config": {
                "name": "-route-target-import"
                "statements": {
                    "statement" [
                        {
                            "conditions" {
                                "bgp-conditions" {
                                    "match-ext-community-set" {
                                        "config": {
                                            "ext-community-set": "-route-target-import-set"
                                        }
                                    }
                                }
                            }
                            "actions" {
                                "config": {
                                    "policy-result": "ACCEPT_ROUTE"
                                }
                            }
                        }
                    ]
                }
            }
        }
        {            
            "config": {
                "name": "-route-target-export"
                "statements": {
                    "statement" [
                        {
                            "name": "-route-target-export-statement"
                            "actions" {
                                "bgp-actions" {
                                    "set-ext-community" {
                                        "config": {
                                            "method": "REFERENCE"
                                            "reference" {
                                                "config": {
                                                    "ext-community-set-ref": "-route-target-export-set"
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    ]
                }
            }
        }
    ]
}

# OS Configuration Commands

# CISCO IOS XR (5.1.3) (6.1.2)

# CLI

vrf 
 address-family ipv4 unicast
  import route-target 
   
   
   
  export route-target 
   
   
   

interface 
 vrf 

router ospf 
 vrf 
  router-id 
  
  area 
   interface 
   
router ospfv3 
 vrf 
  stub-router router-lsa max-metric
   always
     
router bgp 
 vrf 
  address-family ipv4 unicast
  
router 
 vrf 
  address-family ipv4 unicast
   redistribute 
   
router 
 vrf 
  address-family ipv4 unicast
   redistribute 

# CISCO IOS XR (6.2.3)

# CLI

interface 
 vrf 

router ospf 
 vrf 
  area 
   interface 
    cost 

# CISCO IOS XR (6.6.1)

# CLI

vrf 
 address-family ipv4 unicast
  import route-target 
   
   
   
  export route-target 
   
   
   

interface 
 vrf 

router ospf 
 vrf 
  area 
   interface 
    cost 
# Unit

Link to github : xr-unit

# Cisco IOS (VIOS 15.6(2)T)

# CLI

ip vrf 
 rd 
 route-target export 
 route-target export 
 route-target export 
 route-target import 
 route-target import 
 route-target import 

interface 
 ip vrf forwarding 
 ip ospf  area 

router  vrf 

router  vrf 
 redistribute b subnets

router 
 address-family ipv4 vrf 
  redistribute  

# Junos 14.1X53-D40.8

# CLI

set routing-instances  instance-type virtual-router
set routing-instances  interface 
set routing-instances  protocols ospf area  interface  interface-type 
set routing-instances  protocols ospf area  interface  metric 
set routing-instances  protocols ospf area  interface  priority 
delete routing-instances  protocols ospf area  interface  disable 
| set routing-instances  protocols ospf area  interface  disable
set routing-instances  protocols ospf area  interface  authentication md5  key 
| delete routing-instances  protocols ospf area  interface  authentication
set routing-instances  protocols ospf area  interface  bfd-liveness-detection minimum-interval 
set routing-instances  protocols ospf area  interface  bfd-liveness-detection minimum-receive-interval 
set routing-instances  protocols ospf area  interface  bfd-liveness-detection multiplier 

virtual-router is a conversion of set L3VRF
delete routing-instances protocols ospf area interface disable is a conversion of set true
set routing-instances protocols ospf area interface disable is a conversion of set false
set routing-instances protocols ospf area interface authentication is a conversion of set true
delete routing-instances protocols ospf area interface authentication is a conversion of set false

set routing-instances  routing-options instance-import -route-target-import
set routing-instances  protocols ospf export 

# Junos 18.2R1-S2.1

# CLI

set routing-instances  interface