- Master
- Getting Started
- Developer Guide
- Introduction
- Open NX-OS and Linux
- Network Programmability Fundamentals
- Model Driven Programming
- Configuration Management and Automation
- Practical Applications of Network Programmability
- Introduction
- Infrastructure Provisioning Automation
- Automating Access Configuration with Ansible
- Workload On-Boarding
- Infrastructure as Code
- Troubleshooting with Linux Capabilities
- Network Monitoring with Splunk
- Network Monitoring with Open Source Tools
- Automating Network Auditing and Compliance
- Automated Network Topology Verification
- Event Based Workload Mobility
- Network Resiliency
- Programmability Tools for Network Engineers
- Development and Testing Tools
- Source Code and Version Control
- Cisco DevNet for Open NX-OS
- Learning and Helpful Resources
- Developer Tooling
- Guest Shell
- Telemetry
- Telemetry Deployment for VXLAN EVPN
- APIs
- Model Driven Programmability with YANG
- NX-API REST
- Python
- Cisco Nexus 9000 Series Python SDK User Guide and API Reference
- ACL Module
- BGP Module
- CLI Module
- FEATURE Module
- INTERFACE Module
- KEY Module
- MAC_ADDRESS_TABLE Module
- OSPFSession Module
- ROUTEMAP Module
- ROUTES Module
- SSH Module
- SYSTEM Module
- TACACS Module
- VLAN Module
- VRF Module
- Running the Python API from the Guest Shell
- Example Scripts
- Day Zero Provisioning
- Extensibility
- Developer Resources
- Community and Support
The BGP module contains methods and functions that allow you to configure Border Gateway Protocol (BGP) on the Nexus 9000 switch.
The BGP module contains two classes:
BGPSession class: Use the BGPSession class to configure the BGP feature.
BGPNeighbor class: Use the BGPNeighbor class to configure a BGP Neighbor.
Note: The BGPNeighbor class is an attribute of the BGPSession class. To use the BGPNeighbor class, you must have an instance of the BGPSession class.
BGPSession Class
Configures the BGP feature.
Copyclass BGPSession(cisco.feature.Feature)
Example:
>>> from cisco.bgp import *
>>> bgp_session = BGPSession()
add_network
Configures an IP prefix to advertise. To remove the IP prefix to advertise, set the optional 'no' argument to True.
Copyadd_network(self, network, **kwargs)
Example:
>>> bgp_session.add_network("192.168.10.0/24")
Arguments:
network: A string representing the IP prefix in either CIDR notation or dotted quad. For example, '192.0.2.0/24' or '192.0.2.0/255.255.255.0'
route-map: Specifies the name of the route-map to modify attributes.
no: Set to True to remove a network
Usage Guidelines:
The IP prefix to advertise is considered for bestpath and advertisement to peers only if a route of equal or more specificity is present in the routing table.
cfg_aggregate_address
Creates a summary address in a Border Gateway Protocol (BGP) routing table. To remove the summary address, set the optional 'no' argument to True.
Copycfg_aggregate_address(self, address, **kwargs)
Example:
>>> bgp_session.cfg_aggregate_address('192.0.2.0/24')
True
Arguments:
- address: A string representing the aggregate IP address and mask in either CIDR notation or dotted quad, such as '192.0.2.0/24' or '192.0.2.0/255.255.255.0'
Optional Arguments:
- advertise_map: A string which specifies the name of the route map used to select attribute information from specific routes. Should be an alphanumeric string up to 63 characters long.
- as_set: A boolean. Set to True to generate the autonomous system set path information and community information from the contributing paths.
- attribute_map: A string which specifies the name of the route map used to set the attribute information for specific routes. Should be an alphanumeric string up to 63 characters long.
- summary_only: A boolean. Set to True to filter all more-specific routes from updates. -*suppress_map: A string which specifies the name of the route map used to conditionally filter more specific routes. Should be an alphanumeric string up to 63 characters.
- no: A boolean. Set to True to remove a summary address.
Returns: True on success
cfg_bestpath
Modifies the default best-path selection algorithm.
Copycfg_bestpath(self, **kwargs)
Examples:
>>> bgp_session.cfg_bestpath(always_compare_med=True)
True
>>> bgp_session.cfg_bestpath(compare_router_id=False)
True
>>> bgp_session.cfg_bestpath(as_path_multipath_relax=True)
True
>>> bgp_session.cfg_bestpath(med_missing_as_worst=True)
True
>>> bgp_session.cfg_bestpath(med_non_deterministic=False)
True
Optional Arguments:
always_compare_med: Boolean. Set to True to compare the Multi-Exit Discriminator (MED) on paths from a different autonomous system (AS). Set to False to remove this configuration.
compare_router_id: Boolean. Set to True to configure a BGP routing process to compare identical routes received from different external peers during the best path selection process and to select the route with the lowest router ID as the best path. Set to False to remove this configuration.
as_path_multipath_relax: Boolean. Set to True to configure a BGP routing process to consider the different autonomous system (AS) paths and load balance multiple paths during best path route selection. Set to False to remove this configuration.
med_missing_as_worst: Boolean. Set to True to assign the value of infinity to received routes that do not carry the MED attribute, making these routes the least desirable. Set to False to remove this configuration.
med_non_deterministic: Boolean. Set to True to specify that the best-MED path among paths is not picked from the same AS. Set to False to remove this configuration.
Returns: True on success
cfg_cli_event_history
Enables saving the NXCLI event history in a buffer.
Copycfg_cli_event_history(self, **kwargs)
Example:
>>> bgp_session.cfg_cli_event_history()
True
Optional arguments:
- size: A string, possible values are: 'small', 'medium', 'large', or 'disable'. The default buffer size is 'small'.
- no: A boolean, set to True to stop saving the NXCLI event history.
Returns: True on success
cfg_cluster_id
Sets the cluster ID on a route reflector in a route reflector cluster. To remove the cluster ID, set the optional 'no' argument to True.
Copycfg_cluster_id(self, cluster_id, **kwargs)
Example:
>>> bgp_session.cfg_cluster_id("2.2.2.2")
True
Arguments:
- cluster_id: Cluster ID of this router acting as a route reflector. Can be specified as an integer ranging from 1 to 4294967295 or as a string in dotted format: 'A.B.C.D'.
Optional Arguments:
- no: Boolean, set to True to remove the specified cluster ID.
Returns: True on success
cfg_confederation_identifier
Specifies a BGP confederation identifier. To remove the confederation identifier, set the optional 'no' argument to True.
Copycfg_confederation_identifier(self, id, **kwargs)
Example:
>>> bgp_session.cfg_confederation_identifier(65111)
True
Arguments:
- id: The autonomous system (AS) number. Can be specified as an integer ranging from 1 to 4294967295 or a string in the following format: '<1-65535>[.<0-65535>]'
Optional Arguments:
- no: A boolean. Set to True to remove the specified confederation ID.
Returns: True on success
Usage Guidelines:
The bgp confederation identifier is used to configure a single autonomous system number to identify a group of smaller autonomous systems as a single confederation.
A confederation can be used to reduce the internal BGP (iBGP) mesh by dividing a large single autonomous system into multiple subautonomous systems and then grouping them into a single confederation. The subautonomous systems within the confederation exchange routing information like iBGP peers. External peers interact with the confederation as if it is a single autonomous system.
Each subautonomous system is fully meshed within itself and has a few connections to other autonomous systems within the confederation. Next hop, Multi Exit Discriminator (MED), and local preference information is preserved throughout the confederation, allowing you to retain a single Interior Gateway Protocol (IGP) for all the autonomous systems.
cfg_configuration_peers
Configures subautonomous systems to belong to a single confederation. To remove an autonomous system from the confederation, set the optional 'no' argument to True.
Copycfg_confederation_peers(self, peers, **kwargs)
Example:
>>> bgp_session.cfg_confederation_peers(65112 65113)
True
Arguments:
- peers: A string of space-separated AS numbers where each ASN=<1-4294967295><1-65535>[.<0-65535>]
Optional arguments:
- no: A boolean, set to True to remove the specified AS numbers from the list of confederation peers.
Returns: True on success
Usage Guidelines:
The bgp confederation peers command is used to configure multiple autonomous systems as a single confederation. The ellipsis (...) in the command syntax indicates that your command input can include multiple values for the as-number argument.
The autonomous systems specified in this command are visible internally to the confederation. Each autonomous system is fully meshed within itself. The bgp confederation identifier command specifies the confederation to which the autonomous systems belong.
cfg_dampening
Enables BGP route dampening or change BGP route dampening settings. To disable the function set the optional 'no' argument to True.
Copycfg_dampening(self, **kwargs)
Example:
>>> bgp_session.cfg_dampening()
True
Optional args:
- half_life: Time (in minutes) after which a penalty is decreased. Once the route has been assigned a penalty, the penalty is decreased by half after the half-life period (which is 15 minutes by default). The process of reducing the penalty happens every 5 seconds. The range of the half-life period is 1 to 45 minutes. The default is 15 minutes.
- reuse_limit: Value to start reusing a route, range is from 1 to 20000.
- suppress_limit: Value to start suppressing a route, range is from 1 to 20000.
- max_suppress_time: Maximum suppress time for a stable route, the range is from 1 to 255.
- route_map: Name of route map that specifies dampening criteria. The name can be any alphanumeric string up to 63 characters.
- no: Set to True to disable the dampening feature.
Returns: True on success
Usage Guidelines:
You can configure route dampening to minimize route flaps propagating through your iBGP network.
cfg_distance
Configures administrative distance for external BGP, internal BGP, and local routes. To set the distances back to the default set the optional 'no' argument to True.
Copycfg_distance(self, ebgp_dist, ibgp_dist, local_dist, **kwargs)
Example:
>>> bgp_session.cfg_distance(244, 234, 224)
True
Arguments:
- ebgp_dist: Distance for eBGP routes, an integer ranging from 1 to 255. The default is 20.
- ibgp_dist: Distance for iBGP routes, an integer ranging from 1 to 255. The default is 200.
- local_dist: Distance for local routes, an integer ranging from 1 to 255. The default is 220.
Optional Arguments:
- no: Set to True to set distances back to the default values.
Returns: True on success
cfg_events_event_history
Enables the events event history to be saved in a buffer. It is enabled by default.
Copycfg_events_event_history(self, **kwargs)
Example:
>>> bgp_session.cfg_events_event_history()
True
Optional arguments:
- size: A string, possible values are: 'small', 'medium', 'large', or'disable'. The default buffer size is 'small'.
- no: A boolean, set to True to stop saving the events event history.
Returns: True on success
cfg_graceful_restart_restart_time
Configures the maximum time for restart that is advertised to peers. To remove a previously configured value set the optional 'no' argument to True.
Copycfg_graceful_restart_restart_time(self, time, **kwargs)
Example:
>>> bgp_session.cfg_graceful_restart_restart_time(10)
True
Arguments:
- time: An integer ranging from 1 to 3600 representing the restart time. The default value is 120 seconds.
Optional Arguments:
- no: A boolean, set to True to delete the existing configuration and set back to the default.
Returns: True on success
cfg_graceful_restart_stalepath_time
Configures the maximum time to keep a restarting peer's stale routes. To remove a previously configured value set the optional 'no' argument to True.
Copycfg_graceful_restart_stalepath_time(self, time, **kwargs)
Example:
>>> bgp_session.cfg_graceful_restart_stalepath_time(10)
True
Arguments:
- time: An integer ranging from 1 to 3600 representing the stalepath time. The default value is 300 seconds.
Optional Arguments:
- no: A boolean, set to True to delete the existing configuration and set back to the default.
Returns: True on success
cfg_ibgp_maximum_paths
Configures the maximum number of parallel routes that the interior Border Gateway Protocol (iBGP) can support. To restore the default number of parallel routes, set the optional 'no' argument to True.
Copycfg_ibgp_maximum_paths(self, max, **kwargs)
Example:
>>> bgp_session.cfg_ibgp_maximum_paths(64)
True
Arguments:
- max: Maximum number of parallel routes that an IP routing protocol installs in a routing table. The range is from 1 to 64.
Optional Arguments:
- no: Set to True to restore the default number of parallel routes
Returns: True on success
cfg_maximum_paths
Configures the maximum number of parallel routes that the BGP can support. To restore the default number of parallel routes, set the optional 'no' argument to True.
Copycfg_maximum_paths(self, max, **kwargs)
Example:
>>> bgp_session.cfg_maximum_paths(64)
True
Arguments:
- max: Maximum number of parallel routes that an IP routing protocol installs in a routing table. The range is from 1 to 64
Optional Arguments:
- no: Set to True to restore the default number of parallel routes
Returns: True on success
cfg_nexthop_routemap
Configures that Border Gateway Protocol (BGP) routes are resolved using only next hops whose routes match specific characteristics. To remove the route map, set the optional 'no' argument to True.
Copycfg_nexthop_routemap(self, route_map, **kwargs)
Example:
>>> bgp_session.cfg_nexthop_routemap("TestMap")
True
Arguments:
- route_map: Route map name. The name can be any alphanumeric string up to 63 characters.
Optional Arguments:
- no: A boolean, set to True to remove a route-map
Returns: True on success
Usage Guidelines:
Use this API to configure route policy filtering for next hops. BGP next-hop filtering allows you to specify that when a next-hop address is checked with the RIB, the underlying route for that next-hop address is passed through the route map. If the route map rejects the route, the next-hop address is treated as unreachable. BGP marks all next hops that are rejected by the route policy as invalid and does not calculate the best path for the routes that use the invalid next-hop address.
cfg_nexthop_trigger_delay
Configures Border Gateway Protocol (BGP) to delay for triggering next-hop calculations. To set the trigger delay to the default value set the optional 'no' argument to True.
Copycfg_nexthop_trigger_delay(self, critical_delay=3000, non_critical_delay=10000, **kwargs)
Example:
>>> bgp_session.cfg_nexthop_trigger_delay()
True
Arguments:
- critical_delay: An integer specifying the critical next-hop trigger delay in milliseconds. The range is from 1 to 4294967295. The default is 3000.
- non_critical_delay: An integer specifying the noncritical next-hop trigger delay in milliseconds. The range is from 1 to 4294967295. The default is 10000.
Optional Arguments:
- no: Set to True in order to set the trigger delay to the default value.
Returns: True on success
Usage Guidelines:
Use this API to modify when BGP processes next-hop address tracking events. The non-critical delay value must always be set to at least equal or greater than the critical delay value. The delay should be slightly higher than the time it takes for the Interior Gateway Protocol (IGP) to settle into a steady state after some event (IGP convergence time).
cfg_periodic_event_history
Enables periodic events history to be saved in a buffer. It is enabled by default.
Copycfg_periodic_event_history(self, **kwargs)
Example:
>>> bgp_session.cfg_periodic_event_history()
True
Optional arguments:
size: A string, possible values are: 'small', 'medium', 'large', or 'disable'. The default buffer size is 'small'.
no: A boolean, set to True to stop saving the periodic event history.
Returns: True on success
cfg_router_id
Specifies the IP address to use as router-id. To remove this configuration set the optional 'no' argument to True.
Copycfg_router_id(self, router_id, **kwargs)
Example:
>>> bgp_session.cfg_router_id("192.0.20.1")
True
Arguments:
- router_id: A string in dotted quad format ('A.B.C.D') representing the IP Address of the router.
Optional Arguments:
- no: A boolean, set to True to remove the router-id.
Returns: True on success
client_to_client_route_reflection
Triggers an automatic soft clear or refresh of BGP neighbor sessions (default setting). This feature is enabled by default. To disable this feature set the optional 'no' argument to True.
Copyclient_to_client_route_reflection(self, **kwargs)
Example:
>>> bgp_session.client_to_client_route_reflection()
True
Optional arguments:
- no: A boolean. Set to True to disable client-to-client route reflection.
Returns: True on success
enforce_first_as
Configures a router to deny updates received from an external BGP peer that does not list its autonomous system (AS) number at the beginning of the AS_PATH in an upcoming update. To disable this behavior, set the optional 'no' argument to True.
Copyenforce_first_as(self, **kwargs)
Example:
>>> bgp_session.enforce_first_as()
True
Optional Arguments:
- no: A boolean, set to True to disable this feature.
Returns: True on success
Usage Guidelines:
The bgp enforce-first-as command is used to deny incoming updates received from eBGP peers that do not list their AS number as the first segment in the AS_PATH attribute. Enabling this command prevents a misconfigured or unauthorized peer from misdirecting traffic (spoofing the local router) by advertising a route as if it was sourced from another autonomous system.
fast_external_fallover
Configures the BGP process to immediately reset the session if the link to a directly connected BGP peer goes down. This is enabled by default. To disable this behavior, set the optional 'no' argument to True.
Copyfast_external_fallover(self, **kwargs)
Example:
>>> bgp_session.fast_external_fallover()
True
Optional arguments:
- no: A boolean, set to True to disable this feature.
Returns: True on success
flush_routes
Flushes routes in RIB when there is a controlled restart.
Copyflush_routes(self, **kwargs)
Example:
>>> bgp_session.flush_routes()
True
Optional arguments:
- no: A boolean, set to True to disable this feature.
Returns: True on success
graceful_restart
Enables graceful restart and graceful restart helper functionality. This is enabled by default.
Copygraceful_restart(self, **kwargs)
Example:
>>> bgp_session.graceful_restart()
True
Optional arguments:
- no: A boolean, set to True to disable this feature.
Returns: True on success
Usage Guidelines:
The graceful-restart command is used to configure or disable the graceful restart capability on a router in a BGP network. If the graceful restart capability is enabled after a BGP session has been established, you will need to restart the session with a soft or hard reset.
The default timer values for this feature are optimal for most network deployments. We recommend that they are adjusted only by experienced network operators. When adjusting the timer values, the restart timer should not be set to a value greater than the hold time that is carried in the OPEN message. If consecutive restart operations occur, routes (from a restarting router) that were previously marked as stale will be deleted.
graceful_restart_helper
Configures graceful restart method functionality.
Copygraceful_restart_helper(self, **kwargs)
Example:
>>> bgp_session.graceful_restart_helper()
True
Optional Arguments:
- no: A boolean, set to True to disable this feature.
Returns: True on success
Usage Guidelines:
The graceful-restart-helper command is used to configure the local BGP router to support the graceful restart of a remote BGP peer.
is_shutdown
Check whether the BGP routing process is shut down.
Copyis_shutdown(self)
Example:
>>> bgp_session.is_shutdown()
False
Arguments: None
Returns:
- True if the BGP process is enabled and shutdown.
- False if the BGP process is running or if BGP is not enabled.
log_neighbor_changes
Configures BGP to log messages for neighbor up/down events.
Copylog_neighbor_changes(self, **kwargs)
Example:
>>> bgp_session.log_neighbor_changes()
True
Optional Arguments:
- no: A boolean, set to True to disable this feature.
Returns: True on success
max_as_limit
Sets a limit to the number of autonomous systems (AS) that are specified with the AS-PATH attribute.
Copymax_as_limit(self, limit, **kwargs)
Example:
>>> bgp_session.max_as_limit(64)
True
Arguments:
- limit: An integer ranging from 1 to 512 representing the number of ASes in the AS-PATH attribute.
Optional Arguments:
- no: A boolean, set to True to disable this feature.
Returns: True on success
redistribute_direct_routes
Injects routes that are directly connected to an interface into the Border Gateway Protocol (BGP). To restore the system to its default condition in which the software does not redistribute routes, set the optional 'no' argument to True.
Copyredistribute_direct_routes(self, route_map, **kwargs)
Example:
>>> bgp_session.redistribute_direct_routes("TestMap")
True
Arguments:
- route_map: An alphanumeric string up to 63 characters specifying the identifier of a configured route map. Use a route map to filter which routes are redistributed into BGP.
Optional Arguments:
- no: A boolean, set to True to remove the configuration.
Returns: True on success
redistribute_eigrp_routes
Injects routes from the EIGRP protocol into the BGP. To restore the system to its default condition in which the software does not redistribute routes, set the optional 'no' argument to True.
Copyredistribute_eigrp_routes(self, instance_tag, route_map, **kwargs)
Example:
>>> bgp_session.redistribute_ospf_routes("100", "TestMap")
True
Arguments:
- instance_tag: Any case-sensitive, alphanumeric string up to 64 characters.
- route_map: Specifies the identifier of a configured route map. Use a route map to filter which routes are redistributed into BGP.
Optional Arguments:
- no: A boolean, set to True to remove the configuration.
Returns: True on success
redistribute_isis_routes
Injects routes from the IS-IS protocol into the BGP. To restore the system to its default condition in which the software does not redistribute routes, set the optional 'no' argument to True.
Copyredistribute_isis_routes(self, instance_tag, route_map, **kwargs)
Example:
>>> bgp_session.redistribute_isis_routes("100", "TestMap")
True
Arguments:
instance_tag: Any case-sensitive, alphanumeric string up to 64 characters.
route_map: Specifies the identifier of a configured route map. Use a route map to filter which routes are redistributed into BGP.
Optional Arguments:
- no: A boolean, set to True to remove the configuration.
Returns: True on success
redistribute_ospf_routes
Injects routes from the IS-IS protocol into the BGP. To restore the system to its default condition in which the software does not redistribute routes, set the optional 'no' argument to True.
Copyredistribute_ospf_routes(self, protocol_tag, route_map, **kwargs)
Example:
>>> bgp_session.redistribute_ospf_routes("100", "TestMap")
True
Arguments:
instance_tag: Any case-sensitive, alphanumeric string up to 64 characters.
route_map: Specifies the identifier of a configured route map. Use a route map to filter which routes are redistributed into BGP.
Optional Arguments:
- no: A boolean, set to True to remove the configuration.
Returns: True on success
redistribute_rip_routes
Injects routes from the RIP protocol into the BGP. To restore the system to its default condition in which the software does not redistribute routes, set the optional 'no' argument to True.
Copyredistribute_rip_routes(self, instance_tag, route_map, **kwargs)
Example:
>>> bgp_session.redistribute_rip_routes("100", "TestMap")
True
Arguments:
instance_tag: Any case-sensitive, alphanumeric string up to 64 characters
route_map: Specifies the identifier of a configured route map. Use a route map to filter which routes are redistributed into BGP.
Optional Arguments:
- no: A boolean, set to True to remove the configuration.
Returns: True on success
redistribute_static_routes
Injects static routes from the RIP protocol into the BGP. To restore the system to its default condition in which the software does not redistribute routes, set the optional 'no' argument to True.
Copyredistribute_static_routes(self, route_map, **kwargs)
Example:
>>> bgp_session.redistribute_static_routes("TestMap")
True
Arguments:
- route_map: Specifies the identifier of a configured route map. Use a route map to filter which routes are redistributed into BGP.
Optional Arguments:
- no: A boolean, set to True to remove the configuration.
Returns: True on success
set_ASN
Specifies an autonomous system (AS) number.
Copyset_ASN(self, ASN)
Example:
>>> bgp_session.set_ASN(65000)
True
Arguments:
- ASN: An integer representing the Autonomous System Number. The range is from 1 to 4294967295.
set_addr_family
Enables an address family for BGP. This API sets the current address-family for use with APIs that configure address-family attributes.
Copyset_addr_family(self, ip_version, transmission_type)
Examples:
>>> bgp_session.set_addr_family("ipv4", "multicast")
True
>>> bgp_session.set_addr_family("ipv6", "unicast")
True
Arguments:
ip_version: A string, possible values are 'ipv4' and 'ipv6'.
transmission_type: A string, possible values are 'unicast' or 'multicast'.
Returns:
True on success.
ValueError if an invalid ip_version or transmission_type is specified.
set_default_metric
Sets the metric used for redistributed routes.
Copyset_default_metric(self, metric, **kwargs)
Example:
>>> bgp_session.set_default_metric(5)
True
Arguments:
- metric: The metric, an integer ranging from 0 to 4294967295.
Optional Arguments:
- no: A boolean, set to True to remove any existing configuration.
Returns: True on success
set_vrf
Sets the VRF context for subsequent API calls on this BGPSession object. Any configuration done on this BGPSession object will be applied to this VRF.
Copyset_vrf(self, vrf)
Example:
>>> bgp_session.set_vrf("default")
Arguments:
- vrf: VRF name (string) or the VRF ID (int).
Returns: Nothing
shutdown
Shuts down the BGP routing process. All existing BGP configurations will be preserved.
Copyshutdown(self)
Example:
>>> bgp_session.shutdown()
True
Arguments: None
Returns: True on success
start
Starts the BGP routing process. If BGP is shutdown this will start it back up. If the BGP feature is disabled this will enable the feature in addition to starting the process.
Copystart(self)
Example:
>>> bgp_session.start()
True
Arguments: None
Returns: True on success
suppress_inactive
Configures the BGP process to advertise active routes to a BGP peer only.
Copysuppress_inactive(self, **kwargs)
Example:
>>> bgp_session.suppress_inactive()
True
Optional Arguments:
- no: A boolean, set to True to remove the configuration.
Returns: True on success
BGPNeighbor Class
Configures a BGP Neighbor.
Note: The BGPNeighbor class is an attribute of the BGPSession class. To use the BGPNeighbor class, you must have an instance of the BGPSession class.
Copyclass BGPNeighbor()
Example:
>>> bgp_session = BGPSession(65000)
>>> bgp_session.start()
>>> neighbor = bgp_session.BGPNeighbor("192.0.2.0/24", ASN=65001)
Arguments:
- ip_address: A string representing the IPv4/IPv6 address or network in either CIDR notation or dotted quad. For example: '192.0.2.0', '192.0.2.0/24' or '192.0.2.0/255.255.255.0'
- vrf: A string or integer representing the VRF that the neighbor should be configured on.
Optional Arguments:
- ASN: An integer representing the Autonomous System (AS) that the neighbor is associated with. The range is from 1 to 4294967295.
Returns: BGPNeighbor object on success
add
Adds the BGP Neighbor to the BGP configuration.
Copyadd(self)
Example:
>>> neighbor.add()
True
Arguments: None
Returns: True on success
allow_as_in
Configures BGP to accept AS paths with this neighbor`s AS present. To remove this configuration set the optional 'no' argument to True.
Copyallow_as_in(self, **kwargs)
Example:
>>> neighbor.allow_as_in()
True
Optional Arguments:
- num_occurrences: Number of occurrences of AS number. Can be an integer ranging from 1 to 10.
- no: A boolean, set to True to remove this configuration.
Returns: True on success
cfg_advertise_map
Configures Border Gateway Protocol (BGP) conditional advertisement. To remove BGP conditional advertisement, set the optional 'no' argument to True.
Copycfg_advertise_map(self, map, **kwargs)
Example:
>>> neighbor.cfg_advertise_map("TestMap")
True
Arguments:
- map: Route map with match statements that the route must pass before BGP passes theroute to the next route map. The map is a case-sensitive, alphanumeric string up to 63 characters.
Optional Arguments:
- exist_map: Specifies a route map with match statements for a prefix list. A prefix in the BGP table must match a prefix in the prefix list before BGP will advertise the route. The exist_map is a case-sensitive, alphanumeric string up to 63 characters.
- non_exist_map: Specifies a route map with match statements for a prefix list. A prefix in the BGP table must not match a prefix in the prefix list before BGP will advertise the route. The non_exist_map is a case-sensitive, alphanumeric string up to 63 characters.
- no: A boolean, set to True to remove BGP conditional advertisement.
Returns: True on success
cfg_ebgp_multihop
Accepts and attempts BGP connections to external peers that reside on networks that are not directly connected.
Copycfg_ebgp_multihop(self, ebgp_ttl=None, **kwargs)
Example:
>>> neighbor.cfg_ebgp_multihop(ebgp_ttl=255)
True
Arguments:
- ebgp_ttl: An integer, the multihop TTL value. Acceptable values are 2-255.
Optional Arguments:
- no: A boolean. Set to true to remove this configuration.
Returns: True on success
cfg_filter_list_in
Apply AS-PATH filter list to incoming routes. To remove this configuration set the optional 'no' argument to True.
Copycfg_filter_list_in(self, filter, **kwargs)
Example:
>>> neighbor.cfg_filter_list_in("TestList")
True
Arguments:
- filter: Name of filter list, an alphanumeric string up to 63 characters.
Optional Arguments:
- no: A boolean, set to True to remove this configuration.
Returns: True on success
cfg_filter_list_out
Apply AS-PATH filter list to outgoing routes. To remove this configuration set the optional 'no' argument to True.
Copycfg_filter_list_out(self, filter, **kwargs)
Example:
>>> neighbor.cfg_filter_list_out("TestList")
True
Arguments:
- filter: Name of filter list, an alphanumeric string up to 63 characters.
Optional Arguments:
- no: A boolean, set to True to remove this configuration.
Returns: True on success
cfg_local_as
Configures a router to appear as a member of a second autonomous system (AS) in addition to the real AS of the device. To remove the local AS configuration, set the optional 'no' argument to True.
Copycfg_local_as(self, ASN=None, **kwargs)
Example:
>>> neighbor.cfg_local_as(ASN=65000)
True
Arguments:
- ASN: A string or integer representing the Autonomous System Number. If integer, range is from 1 to 4294967295. If string, use this format: '<1-4294967295>|<1-65535>[.<0-65535>]'.
Optional Arguments:
- no_prepend: A boolean. Set to True to prevent prepending the local-as number to any routes received from the external Border Gateway Protocol (eBGP) neighbor.
- replace_as: A boolean. Set to True to prepend only the local-as number to updates to the eBGP neighbor.
- dual_as: A boolean. Set to True to configure the eBGP neighbor to establish a peering session using the real autonomous system number (from the local BGP routing process) or by using the autonomous-system number.
- no: A boolean. Set to True to remove the local AS configuration.
Returns: True on success
cfg_maximum_prefix
Configures the maximum number of prefixes from this neighbor. To remove this configuration set the optional 'no' argument to True.
Copycfg_maximum_prefix(self, limit=None, **kwargs)
Example:
>>> neighbor.cfg_maximum_prefix(limit=1)
True
Arguments:
- limit: Max prefix limit. An integer ranging from 1 to 300,000.
Optional Arguments:
- threshold: Threshold percentage at which to generate a warning. An integer ranging from 1 to 100.
- restart_interval: Restart the BGP connection after the limit is exceeded. An integer ranging from 1 to 65535.
- warning_only: A boolean, set to True to only give a warning message when the limit is exceeded.
- no: A boolean, set to True to remove this configuration.
Returns: True on success
cfg_password
Configures a password for this Border Gateway Protocol (BGP) neighbor. To remove a password set the optional 'no' argument to True.
Copycfg_password(self, password=None, **kwargs)
Example:
>>> from cisco.cisco_secret import *
>>> pw = CiscoSecret("Python")
>>> neighbor.cfg_password(password=pw)
True
Arguments:
- password: a CiscoSecret object.
Optional Arguments:
- no: A boolean. Set to True to remove an existing password.
Returns: True on success.
cfg_prefix_list_in
Apply a prefix-list to incoming routes. Set the optional 'no' argument to True to remove this configuration.
Copycfg_prefix_list_in(self, list, **kwargs)
Example:
>>> neighbor.cfg_prefix_list_in("TestList")
True
Arguments:
- list: Name of prefix-list, an alphanumeric string up to 63 characters.
Optional Arguments:
- no: A boolean, set to True to remove this configuration.
Returns: True on success
cfg_prefix_list_out
Apply a prefix-list to outgoing routes. Set the optional 'no' argument to True to remove this configuration.
Copycfg_prefix_list_out(self, list, **kwargs)
Example:
>>> neighbor.cfg_prefix_list_out("TestList")
True
Arguments:
- list: Name of prefix-list, an alphanumeric string up to 63 characters.
Optional Arguments:
- no: A boolean, set to True to remove this configuration.
Returns: True on success
cfg_remote_as
Specifies the autonomous system (AS) number for this neighbor. To remove an AS number set the optional 'no' argument to True.
Copycfg_remote_as(self, ASN=None, **kwargs)
Example:
>>> neighbor.cfg_remote_as(ASN=65001)
True
Arguments:
- ASN: A string or integer representing the Autonomous System Number. If integer, range is from 1 to 4294967295. If string, use this format: '<1-4294967295>|<1-65535>[.<0-65535>]'.
Optional Arguments:
- no: A boolean. Set to True to remove an AS number.
Returns: True on success
cfg_route_map_in
Apply a route-map to incoming routes. Set the optional 'no' argument to True to remove this configuration.
Copycfg_route_map_in(self, map, **kwargs)
Example:
>>> neighbor.cfg_route_map_in("TestMap")
True
Arguments:
- map: Name of the route-map, an alphanumeric string up to 63 characters.
Optional Arguments:
- no: A boolean, set to True to remove this configuration.
Returns: True on success
cfg_route_map_out
Apply a route-map to outgoing routes. Set the optional 'no' argument to True to remove this configuration.
Copycfg_route_map_out(self, map, **kwargs)
Example:
>>> neighbor.cfg_route_map_out("TestMap")
True
Arguments:
- map: Name of the route-map, an alphanumeric string up to 63 characters.
Optional Arguments:
- no: A boolean, set to True to remove this configuration.
Returns: True on success
cfg_timers
Configures keepalive and hold timers in seconds. Default values are 60 seconds for keepalive and 180 seconds for hold time. To set back to the default values set the optional 'no' argument to True.
Copycfg_timers(self, keepalive_interval=60, holdtime=180, **kwargs)
Example:
>>> neighbor.cfg_timers(keepalive_interval=60, holdtime=180)
True
Arguments:
- keepalive_interval: An integer ranging from 0 to 3600.
- holdtime: An integer ranging from 0 3600.
Optional Arguments:
- no: A boolean. Set to True to set the timers back to the default values.
Returns: True on success
cfg_update_source
Specify the source of the BGP session and updates. The Cisco NX-OS software allows BGP sessions to use any operational interface for TCP connections. To restore the interface assignment to the closest interface, which is called the best local address, set the optional 'no' argument to True.
Copycfg_update_source(self, interface=None, **kwargs)
Example:
>>> neighbor.cfg_update_source(interface="Ethernet1/1.2")
True
Arguments:
- interface: A string representing an interface on the switch. Can be ethernet, loopback, port-channel or a vlan in either expanded or short forms. For example: 'e1/1.2', 'Ethernet1/1.2'
Optional Arguments:
- no: A boolean, set to True to restore the interface assignment to the best local address.
Returns: True on success
default_originate
Originate a default toward this neighbor. To remove this configuration set the optional 'no' argument to True.
Copydefault_originate(self, **kwargs)
Example:
>>> neighbor.default_originate()
True
Optional Arguments:
- route_map: Name of route-map that specifies criteria for originating default.
- no: A boolean, set to True to remove this configuration.
Returns: True on success
disable_connected_check
Disables the connection verification for the directly connected peer.
Copydisable_connected_check(self, **kwargs)
Example:
>>> neighbor.disable_connected_check()
True
Arguments: None
Optional Arguments:
- no: A boolean. Set to true to enable the connection verification for the directly connected peer.
Returns: True on success
Usage Guidelines:
Use this API to disable a check for an exterior Border Gateway Protocol (eBGP) peer that is directly connected to the router. BGP triggers a connection check automatically for all eBGP peers that are known to be a single hop away, unless you disable this check with this API. BGP does not bring up sessions if the check fails. BGP considers an eBGP peer as a single hop away if the eBGP peer does not have the ebgp-multihop option configured (that is, the time-to-live (TTL) value is one).
dont_capability_negotiate
Turns off the negotiate capability with this neighbor.
Copydont_capability_negotiate(self, **kwargs)
Example:
>>> neighbor.dont_capability_negotiate()
True
Arguments: None
Optional args:
- no: A boolean. Set to True to turn on the negotiate capability with this neighbor.
Returns: True on success
dynamic_capability
Enables the dynamic capability.
Copydynamic_capability(self, **kwargs)
Example:
>>> neighbor.dynamic_capability()
True
Arguments: None
Optional Arguments:
- no: A boolean. Set to True to disable the dynamic capability.
Returns: True on success
exists
Checks if this BGP Neighbor exists.
Copyexists(self)
Example:
>>> neighbor.exists()
True
Arguments: None
Returns:
- True if this BGP Neighbor exists.
- False if this BGP Neighbor does not exist.
low_memory_exempt
Exempts this Border Gateway Protocol (BGP) neighbor from a low-memory shutdown. To make this BGP neighbor eligible for a low-memory shutdown set the optional 'no' argument to True.
Copylow_memory_exempt(self, **kwargs)
Example:
>>> neighbor.low_memory_exempt()
True
Arguments: None
Optional Arguments:
- no: A boolean. Set to true to make this BGP neighbor eligible for a low-memory shutdown.
Returns: True on success
next_hop_self
Sets our peering address as nexthop. To remove this configuration set the optional 'no' argument to True.
Copynext_hop_self(self, **kwargs)
Example:
>>> neighbor.next_hop_self()
True
Optional Arguments:
- no: A boolean, set to True to remove this configuration.
Returns: True on success
next_hop_third_party
Computes a third-party nexthop if possible. To remove this configuration set the optional 'no' argument to True.
Copynext_hop_third_party(self, **kwargs)
Example:
>>> neighbor.next_hop_third_party()
True
Optional Arguments:
- no: A boolean, set to True to remove this configuration.
Returns: True on success
remove
Removes the BGP Neighbor from the BGP configuration.
Copyremove(self)
Example:
>>> neighbor.remove()
True
Arguments: None
Returns:
- True on success
- ValueError if the neighbor does not exist
remove_private_as
Removes the private Autonomous System (AS) number from outbound updates. To include the private AS number in outbound updates set the optional 'no' argument to True.
Copyremove_private_as(self, **kwargs)
Example:
>>> neighbor.remove_private_as()
True
Arguments: None
Optional Arguments:
- no: A boolean. Set to True to include the private AS number in outbound updates.
Returns: True on success.
route_reflector_client
Configure this neighbor as a route reflector client. To remove this configuration set the optional 'no' argument to True.
Copyroute_reflector_client(self, **kwargs)
Example:
>>> neighbor.route_reflector_client()
True
Optional Arguments:
- no: A boolean, set to True to remove this configuration.
Returns: True on success
send_community
Send the Border Gateway Protocol (BGP) community attribute to this neighbor. To revert back to the defaults, set the optional 'no' argument to True.
Copysend_community(self, **kwargs)
Example:
>>> neighbor.send_community()
True
Optional Argments:
- no: A boolean, set to True to revert back to the defaults.
Returns: True on success
send_community_extended
Send the Border Gateway Protocol (BGP) extended community attribute to this neighbor. To revert back to the defaults, set the optional 'no' argument to True.
Copysend_community_extended(self, **kwargs)
Example:
>>> neighbor.send_community_extended()
True
Optional Argments:
- no: A boolean, set to True to revert back to the defaults.
Returns: True on success
set_addr_family
Enable an address-family for use with BGP. Possible address families are: ipv4 unicast, ipv4 multicast, ipv6 unicast and ipv6 multicast. This API sets the current address-family for use with APIs that configure address-family attributes.
Copyset_addr_family(self, ip_version, transmission_type)
Example:
>>> neighbor.set_addr_family("ipv4", "unicast")
True
Arguments:
- ip_version: A string, possible values are 'ipv4' and 'ipv6'.
- transmission_type: A string, possible values are 'unicast' or 'multicast'.
Returns:
- True on success.
Raises:
- ValueError if an invalid ip_version or transmission_type is specified.
set_description
Sets a descriptive string for this BGP Neighbor.
Copyset_description(self, description=None, **kwargs)
Example:
>>> neighbor.set_description("BGP neighbor S3")
True
Arguments:
- description: An alphanumeric string up to 80 characters long.
Optional Arguments:
- no: A boolean. Set to True to remove any existing description.
Returns: True on success
shutdown
Administratively shuts down this neighbor. All existing configurations will be preserved. To enable this neighbor set the optional 'no' argument to True.
Copyshutdown(self, **kwargs)
Example:
>>> neighbor.shutdown()
True
Arguments: None
Optional Arguments:
- no: A boolean. Set to True to enable this neighbor.
Returns: True on success
soft_reconfiguration_inbound
Configures the switch software to start storing Border Gateway Protocol (BGP) peer updates. To not store received updates, set the optional 'no' argument to True.
Copysoft_reconfiguration_inbound(self, **kwargs)
Example:
>>> neighbor.soft_reconfiguration_inbound()
True
Optional Arguments:
- no: A boolean, set to True to stop storing received updates.
Returns: True on success
Usage Guidelines:
Entering this command starts the storage of updates, which is required to do inbound soft reconfiguration. To use soft reconfiguration, or soft reset, without preconfiguration, both BGP peers must support the soft route refresh capability.
suppress_inactive
Advertises the active routes to a Border Gateway Protocol (BGP) peer only. To remove the restriction, set the optional 'no' argument to True.
Copysuppress_inactive(self, **kwargs)
Example:
>>> neighbor.suppress_inactive()
True
Optional Arguments:
- no: A boolean, set to True to remove this restriction.
Returns: True on success
transport_connection_mode_passive
Allows a passive connection setup only. To remove this restriction, set the optional 'no' argument to True.
Copytransport_connection_mode_passive(self, **kwargs)
Example:
>>> neighbor.transport_connection_mode_passive()
True
Arguments: None
Optional Arguments:
- no: A boolean. Set to True to allow all connection setups.
Returns: True on success