Date created: Thursday, November 3, 2016 3:42:19 PM. Last modified: Friday, January 13, 2017 12:17:57 PM

gRPC on IOS-XR Setup

This is the initial config applied to an IOS-XRv 6.1.1 image:

telnet vrf default ipv4 server max-servers 10
username vagrant
 group root-lr
 group cisco-support
 secret 5 $1$FXeb$aLMudSH4.B8BK1IYlIm.j.
!
tpa
 address-family ipv4
  update-source MgmtEth0/RP0/CPU0/0
 !
!
control-plane
 management-plane
  out-of-band
   interface all
    allow all
   !
  !
 !
!
interface Loopback0
 ipv4 address 1.1.0.10 255.255.255.255
!
interface MgmtEth0/RP0/CPU0/0
 ipv4 address dhcp
!
community-set public_ipv4_prefixes
  65001:4
end-set
!
community-set public_ipv6_prefixes
  65001:6
end-set
!
community-set peering_ipv4_prefixes
  65001:44
end-set
!
community-set peering_ipv6_prefixes
  65001:66
end-set   
!
route-policy public_v4_peering_egress
  if community matches-any public_ipv4_prefixes then
    pass
  else
    drop
  endif
  # Permit prefix with public IPv4 community only
end-policy
!
route-policy public_v6_peering_egress
  if community matches-any public_ipv6_prefixes then
    pass
  else
    drop
  endif
  # Permit prefix with public IPv6 community only
end-policy
!
route-policy public_v4_peering_ingress
  set community peering_ipv4_prefixes
  # Tag ingress public peering v4 prefixes
end-policy
!
route-policy public_v6_peering_ingress
  set community peering_ipv6_prefixes
  # Tag ingress public peering v6 prefixes
end-policy
!
router static
 address-family ipv4 unicast
  0.0.0.0/0 MgmtEth0/RP0/CPU0/0 10.0.2.2
 !
!
router bgp 65001
 bgp router-id 1.1.0.10
 address-family ipv4 unicast
 !
 address-family ipv6 unicast
 !
 neighbor-group public_v4_peers
  address-family ipv4 unicast
   route-policy public_v4_peering_ingress in
   route-policy public_v4_peering_egress out
  !       
 !
 neighbor-group public_v6_peers
  address-family ipv6 unicast
   route-policy public_v6_peering_ingress in
   route-policy public_v6_peering_egress out
  !
 !
!
grpc
 port 57777
 tls
!
xml agent
!
netconf agent tty
!
netconf-yang agent
 ssh
!
ssh server v2
ssh server vrf default
ssh server netconf vrf default
end

Next one can grab the running BGP config serialised as JSON over gRPC using the Cisco gRPC python library, note the Cisco IOS-XR IPv4 BGP YANG model reference is commented out in favour of the OpenConfig model:

(venv) bensley@ubuntu-laptop:~/Python/pyb_xml/ios-xr-grpc-python-master/examples$ cat grpc_example.py 
# Need Cisco GRPC python library
# https://github.com/cisco-grpc-connection-libs/ios-xr-grpc-python
# And this example is using gRPC over TLS so need to SCP certificate
# off of the IOS-XRv device and change the below .pem path
#
# Credit:
# https://github.com/cisco-grpc-connection-libs/ios-xr-grpc-python/blob/master/examples/grpc_example.py


import json
from grpc.framework.interfaces.face.face import AbortionError
import sys
sys.path.insert(0, '../')
from lib.cisco_grpc_client import CiscoGRPCClient

def main():
    '''
    To not use tls we need to do 2 things.
    1. Comment the variables creds and options out
    2. Remove creds and options CiscoGRPCClient
    ex: client = CiscoGRPCClient('11.1.1.10', 57777, 10, 'vagrant', 'vagrant')
    '''
    creds = open('/home/bensley/Python/pyb_xml/IOS-XRv611-grpc.pem').read()
    options = 'ems.cisco.com'
    client = CiscoGRPCClient('127.0.0.1', 57777, 10, 'vagrant', 'vagrant', creds, options)
    #path = '{"Cisco-IOS-XR-ipv4-bgp-cfg:bgp": [null]}'
    path = '{"openconfig-bgp:bgp": [null]}'
    try:
        err, result = client.getconfig(path)
        if err:
            print err
        print json.dumps(json.loads(result), indent=4)
    except AbortionError:
        print(
            'Unable to connect to local box, check your gRPC destination.'
            )

if __name__ == '__main__':
    main()


(venv) bensley@ubuntu-laptop:~/Python/pyb_xml/ios-xr-grpc-python-master/examples$ python grpc_example.py 
{
    "openconfig-bgp:bgp": {
        "peer-groups": {
            "peer-group": [
                {
                    "config": {
                        "peer-group-name": "public_v4_peers"
                    }, 
                    "peer-group-name": "public_v4_peers", 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "apply-policy": {
                                    "config": {
                                        "import-policy": [
                                            "public_v4_peering_ingress"
                                        ], 
                                        "export-policy": [
                                            "public_v4_peering_egress"
                                        ]
                                    }
                                }, 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                            }
                        ]
                    }
                }, 
                {
                    "config": {
                        "peer-group-name": "public_v6_peers"
                    }, 
                    "peer-group-name": "public_v6_peers", 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "apply-policy": {
                                    "config": {
                                        "import-policy": [
                                            "public_v6_peering_ingress"
                                        ], 
                                        "export-policy": [
                                            "public_v6_peering_egress"
                                        ]
                                    }
                                }, 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                            }
                        ]
                    }
                }
            ]
        }, 
        "global": {
            "config": {
                "as": 65001, 
                "router-id": "1.1.0.10"
            }, 
            "afi-safis": {
                "afi-safi": [
                    {
                        "config": {
                            "enabled": true, 
                            "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                        }, 
                        "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                    }, 
                    {
                        "config": {
                            "enabled": true, 
                            "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                        }, 
                        "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                    }
                ]
            }
        }
    }
}

Using a previously written script one can now generate BGP configuration derived from OpenConfig YANG models and serialise this as JOSN: /index.php?page=example-2-public-peering-using-openconfig

This is the output from the script showing the JSON config that was generated, the running BGP config before and after:

bensley@ubuntu-laptop:~/Python/pyb_oc$ python peeringdb-example-2.3.py 1016
Open peering networks config:
{
    "openconfig-bgp:bgp": {
        "neighbors": {
            "neighbor": [
                {
                    "neighbor-address": "195.66.228.2", 
                    "config": {
                        "neighbor-address": "195.66.228.2", 
                        "peer-as": 48294, 
                        "peer-group": "public_v4_peers", 
                        "description": "Spectrum Internet Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 35
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "195.66.228.1", 
                    "config": {
                        "neighbor-address": "195.66.228.1", 
                        "peer-as": 59455, 
                        "peer-group": "public_v4_peers", 
                        "description": "Clearstream Technology Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 30
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "2001:7f8:4:4::a6c1:1", 
                    "config": {
                        "neighbor-address": "2001:7f8:4:4::a6c1:1", 
                        "peer-as": 42689, 
                        "peer-group": "public_v6_peers", 
                        "description": "Cablecom Networking Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:ipv6-unicast", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                                }, 
                                "ipv6-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 5
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "195.66.228.25", 
                    "config": {
                        "neighbor-address": "195.66.228.25", 
                        "peer-as": 31595, 
                        "peer-group": "public_v4_peers", 
                        "description": "Datacentres Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 10
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "2001:7f8:4:4::bca6:1", 
                    "config": {
                        "neighbor-address": "2001:7f8:4:4::bca6:1", 
                        "peer-as": 48294, 
                        "peer-group": "public_v6_peers", 
                        "description": "Spectrum Internet Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:ipv6-unicast", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                                }, 
                                "ipv6-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 2
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "195.66.228.230", 
                    "config": {
                        "neighbor-address": "195.66.228.230", 
                        "peer-as": 8714, 
                        "peer-group": "public_v4_peers", 
                        "description": "LINX Route Servers"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 115000
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "2001:7f8:4:4::220a:1", 
                    "config": {
                        "neighbor-address": "2001:7f8:4:4::220a:1", 
                        "peer-as": 8714, 
                        "peer-group": "public_v6_peers", 
                        "description": "LINX Route Servers"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:ipv6-unicast", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                                }, 
                                "ipv6-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 15500
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "195.66.228.14", 
                    "config": {
                        "neighbor-address": "195.66.228.14", 
                        "peer-as": 201353, 
                        "peer-group": "public_v4_peers", 
                        "description": "Net Support UK Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 2
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "195.66.228.31", 
                    "config": {
                        "neighbor-address": "195.66.228.31", 
                        "peer-as": 42689, 
                        "peer-group": "public_v4_peers", 
                        "description": "Cablecom Networking Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 20
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "195.66.228.32", 
                    "config": {
                        "neighbor-address": "195.66.228.32", 
                        "peer-as": 8468, 
                        "peer-group": "public_v4_peers", 
                        "description": "Entanet International Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 500
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "2001:7f8:4:4::2114:1", 
                    "config": {
                        "neighbor-address": "2001:7f8:4:4::2114:1", 
                        "peer-as": 8468, 
                        "peer-group": "public_v6_peers", 
                        "description": "Entanet International Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "afi-safi-name": "openconfig-bgp-types:ipv6-unicast", 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                                }, 
                                "ipv6-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 25
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        }
    }
}

Running BGP config before:
{
    "openconfig-bgp:bgp": {
        "peer-groups": {
            "peer-group": [
                {
                    "config": {
                        "peer-group-name": "public_v4_peers"
                    }, 
                    "peer-group-name": "public_v4_peers", 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "apply-policy": {
                                    "config": {
                                        "import-policy": [
                                            "public_v4_peering_ingress"
                                        ], 
                                        "export-policy": [
                                            "public_v4_peering_egress"
                                        ]
                                    }
                                }, 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                            }
                        ]
                    }
                }, 
                {
                    "config": {
                        "peer-group-name": "public_v6_peers"
                    }, 
                    "peer-group-name": "public_v6_peers", 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "apply-policy": {
                                    "config": {
                                        "import-policy": [
                                            "public_v6_peering_ingress"
                                        ], 
                                        "export-policy": [
                                            "public_v6_peering_egress"
                                        ]
                                    }
                                }, 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                            }
                        ]
                    }
                }
            ]
        }, 
        "global": {
            "config": {
                "as": 65001, 
                "router-id": "1.1.0.10"
            }, 
            "afi-safis": {
                "afi-safi": [
                    {
                        "config": {
                            "enabled": true, 
                            "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                        }, 
                        "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                    }, 
                    {
                        "config": {
                            "enabled": true, 
                            "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                        }, 
                        "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                    }
                ]
            }
        }
    }
}

Running BGP config after:
{
    "openconfig-bgp:bgp": {
        "neighbors": {
            "neighbor": [
                {
                    "neighbor-address": "195.66.228.1", 
                    "config": {
                        "neighbor-address": "195.66.228.1", 
                        "peer-as": 59455, 
                        "peer-group": "public_v4_peers", 
                        "description": "Clearstream Technology Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 30
                                        }
                                    }
                                }, 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "195.66.228.2", 
                    "config": {
                        "neighbor-address": "195.66.228.2", 
                        "peer-as": 48294, 
                        "peer-group": "public_v4_peers", 
                        "description": "Spectrum Internet Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 35
                                        }
                                    }
                                }, 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "195.66.228.14", 
                    "config": {
                        "neighbor-address": "195.66.228.14", 
                        "peer-as": 201353, 
                        "peer-group": "public_v4_peers", 
                        "description": "Net Support UK Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 2
                                        }
                                    }
                                }, 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "195.66.228.25", 
                    "config": {
                        "neighbor-address": "195.66.228.25", 
                        "peer-as": 31595, 
                        "peer-group": "public_v4_peers", 
                        "description": "Datacentres Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 10
                                        }
                                    }
                                }, 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "195.66.228.31", 
                    "config": {
                        "neighbor-address": "195.66.228.31", 
                        "peer-as": 42689, 
                        "peer-group": "public_v4_peers", 
                        "description": "Cablecom Networking Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 20
                                        }
                                    }
                                }, 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "195.66.228.32", 
                    "config": {
                        "neighbor-address": "195.66.228.32", 
                        "peer-as": 8468, 
                        "peer-group": "public_v4_peers", 
                        "description": "Entanet International Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 500
                                        }
                                    }
                                }, 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "195.66.228.230", 
                    "config": {
                        "neighbor-address": "195.66.228.230", 
                        "peer-as": 8714, 
                        "peer-group": "public_v4_peers", 
                        "description": "LINX Route Servers"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "ipv4-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 115000
                                        }
                                    }
                                }, 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "2001:7f8:4:4::2114:1", 
                    "config": {
                        "neighbor-address": "2001:7f8:4:4::2114:1", 
                        "peer-as": 8468, 
                        "peer-group": "public_v6_peers", 
                        "description": "Entanet International Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv6-unicast", 
                                "ipv6-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 25
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "2001:7f8:4:4::220a:1", 
                    "config": {
                        "neighbor-address": "2001:7f8:4:4::220a:1", 
                        "peer-as": 8714, 
                        "peer-group": "public_v6_peers", 
                        "description": "LINX Route Servers"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv6-unicast", 
                                "ipv6-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 15500
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "2001:7f8:4:4::a6c1:1", 
                    "config": {
                        "neighbor-address": "2001:7f8:4:4::a6c1:1", 
                        "peer-as": 42689, 
                        "peer-group": "public_v6_peers", 
                        "description": "Cablecom Networking Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv6-unicast", 
                                "ipv6-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 5
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }, 
                {
                    "neighbor-address": "2001:7f8:4:4::bca6:1", 
                    "config": {
                        "neighbor-address": "2001:7f8:4:4::bca6:1", 
                        "peer-as": 48294, 
                        "peer-group": "public_v6_peers", 
                        "description": "Spectrum Internet Ltd"
                    }, 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv6-unicast", 
                                "ipv6-unicast": {
                                    "prefix-limit": {
                                        "config": {
                                            "shutdown-threshold-pct": 90, 
                                            "restart-timer": 1, 
                                            "max-prefixes": 2
                                        }
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        }, 
        "peer-groups": {
            "peer-group": [
                {
                    "config": {
                        "peer-group-name": "public_v4_peers"
                    }, 
                    "peer-group-name": "public_v4_peers", 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "apply-policy": {
                                    "config": {
                                        "import-policy": [
                                            "public_v4_peering_ingress"
                                        ], 
                                        "export-policy": [
                                            "public_v4_peering_egress"
                                        ]
                                    }
                                }, 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                            }
                        ]
                    }
                }, 
                {
                    "config": {
                        "peer-group-name": "public_v6_peers"
                    }, 
                    "peer-group-name": "public_v6_peers", 
                    "afi-safis": {
                        "afi-safi": [
                            {
                                "apply-policy": {
                                    "config": {
                                        "import-policy": [
                                            "public_v6_peering_ingress"
                                        ], 
                                        "export-policy": [
                                            "public_v6_peering_egress"
                                        ]
                                    }
                                }, 
                                "config": {
                                    "enabled": true, 
                                    "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                                }, 
                                "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                            }
                        ]
                    }
                }
            ]
        }, 
        "global": {
            "config": {
                "as": 65001, 
                "router-id": "1.1.0.10"
            }, 
            "afi-safis": {
                "afi-safi": [
                    {
                        "config": {
                            "enabled": true, 
                            "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                        }, 
                        "afi-safi-name": "openconfig-bgp-types:ipv4-unicast"
                    }, 
                    {
                        "config": {
                            "enabled": true, 
                            "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                        }, 
                        "afi-safi-name": "openconfig-bgp-types:ipv6-unicast"
                    }
                ]
            }
        }
    }
}

Restrictive peering networks:

None.

This is the output on the device console:

RP/0/RP0/CPU0:ios#show run router bgp           
Tue Nov  8 14:41:27.461 UTC
router bgp 65001
 bgp router-id 1.1.0.10
 address-family ipv4 unicast
 !
 address-family ipv6 unicast
 !
 neighbor-group public_v4_peers
  address-family ipv4 unicast
   route-policy public_v4_peering_ingress in
   route-policy public_v4_peering_egress out
  !
 !
 neighbor-group public_v6_peers
  address-family ipv6 unicast
   route-policy public_v6_peering_ingress in
   route-policy public_v6_peering_egress out
  !
 !
!

RP/0/RP0/CPU0:ios#RP/0/RP0/CPU0:Nov  8 14:47:54.509 : emsd[1083]: %MGBL-CONFIG-6-DB_COMMIT : Configuration committed by user 'vagrant'. Use 'show configuration commit changes 1000000041' to view the changes. 

RP/0/RP0/CPU0:ios#show run router bgp           
Tue Nov  8 14:49:02.352 UTC
router bgp 65001
 bgp router-id 1.1.0.10
 address-family ipv4 unicast
 !
 address-family ipv6 unicast
 !
 neighbor-group public_v4_peers
  address-family ipv4 unicast
   route-policy public_v4_peering_ingress in
   route-policy public_v4_peering_egress out
  !
 !
 neighbor-group public_v6_peers
  address-family ipv6 unicast
   route-policy public_v6_peering_ingress in
   route-policy public_v6_peering_egress out
  !
 !
 neighbor 195.66.228.1
  remote-as 59455
  use neighbor-group public_v4_peers
  description Clearstream Technology Ltd
  address-family ipv4 unicast
   maximum-prefix 30 90 restart 1
  !
 !
 neighbor 195.66.228.2
  remote-as 48294
  use neighbor-group public_v4_peers
  description Spectrum Internet Ltd
  address-family ipv4 unicast
   maximum-prefix 35 90 restart 1
  !
 !
 neighbor 195.66.228.14
  remote-as 201353
  use neighbor-group public_v4_peers
  description Net Support UK Ltd
  address-family ipv4 unicast
   maximum-prefix 2 90 restart 1
  !
 !
 neighbor 195.66.228.25
  remote-as 31595
  use neighbor-group public_v4_peers
  description Datacentres Ltd
  address-family ipv4 unicast
   maximum-prefix 10 90 restart 1
  !
 !
 neighbor 195.66.228.31
  remote-as 42689
  use neighbor-group public_v4_peers
  description Cablecom Networking Ltd
  address-family ipv4 unicast
   maximum-prefix 20 90 restart 1
  !
 !
 neighbor 195.66.228.32
  remote-as 8468
  use neighbor-group public_v4_peers
  description Entanet International Ltd
  address-family ipv4 unicast
   maximum-prefix 500 90 restart 1
  !
 !
 neighbor 195.66.228.230
  remote-as 8714
  use neighbor-group public_v4_peers
  description LINX Route Servers
  address-family ipv4 unicast
   maximum-prefix 115000 90 restart 1
  !
 !
 neighbor 2001:7f8:4:4::2114:1
  remote-as 8468
  use neighbor-group public_v6_peers
  description Entanet International Ltd
  address-family ipv6 unicast
   maximum-prefix 25 90 restart 1
  !
 !
 neighbor 2001:7f8:4:4::220a:1
  remote-as 8714
  use neighbor-group public_v6_peers
  description LINX Route Servers
  address-family ipv6 unicast
   maximum-prefix 15500 90 restart 1
  !
 !
 neighbor 2001:7f8:4:4::a6c1:1
  remote-as 42689
  use neighbor-group public_v6_peers
  description Cablecom Networking Ltd
  address-family ipv6 unicast
   maximum-prefix 5 90 restart 1
  !
 !
 neighbor 2001:7f8:4:4::bca6:1
  remote-as 48294
  use neighbor-group public_v6_peers
  description Spectrum Internet Ltd
  address-family ipv6 unicast
   maximum-prefix 2 90 restart 1
  !
 !
!