REFERENCE

v6.11.0

BGP

BGP connections, templates, sessions and advertisements (`/routing bgp`).

Tools

list_bgp_instances

List BGP Instances · Risk: read

Read BGP instances and their best-path selection settings, including RouterOS 7.25+ always-compare-med. Use before changing an instance.

No tool-specific parameters.

update_bgp_instance_med_comparison

Set BGP Instance MED Comparison · Risk: write-idempotent

Set RouterOS 7.25+ always-compare-med on one named BGP instance. This changes best-path selection and can reroute traffic; inspect list_bgp_instances and obtain operator approval first.

ParameterRequiredDefinition
nameYesExact BGP instance name {"type":"string","minLength":1}
always_compare_medYes{"type":"boolean"}
confirm_routing_changeYesOperator approved the best-path behavior change {"type":"boolean","const":true}

list_bgp_connections

List BGP Connections · Risk: read

Lists configured BGP peer connections (/routing bgp connection) — the static configuration of each peer or listener, including local/remote AS, addresses, and role. For runtime peering state (established/idle, uptime, prefix counts) use list_bgp_sessions. For shared configuration objects inherited by connections use list_bgp_templates. Optionally filters by connection name substring. Returns all matching connection entries. Requires RouterOS v7 with the routing package.

ParameterRequiredDefinition
name_filterNoSubstring match on connection name {"type":"string"}

get_bgp_connection

Get BGP Connection Details · Risk: read

Fetches full configuration detail for a single BGP connection by name (/routing bgp connection print detail where name="<name>"). Use this to inspect one peer's full settings; to browse all connections use list_bgp_connections. For runtime session status (established, uptime, prefix counts) use list_bgp_sessions. Returns the complete connection record or a not-found message.

ParameterRequiredDefinition
nameYesBGP connection name {"type":"string"}

add_bgp_connection

Add BGP Connection · Risk: write

Creates a BGP peer connection (/routing bgp connection add) — the per-peer configuration that initiates or accepts a BGP session. At minimum supply name, remote_address, and as/local_role for the local side. local_role values: ebgp, ibgp, ebgp-customer, ebgp-provider, ibgp-rr, ibgp-rr-client. For address_families pass a comma-separated list, e.g. "ip" or "ip,ipv6,l2vpn". For hold_time/keepalive_time use RouterOS duration strings, e.g. "3m" or "180s". input_filter/output_filter reference /routing filter chain names. Common settings (AS, filters, timers) can be factored into a template referenced via templates; to create templates use add_bgp_template. To modify an existing connection use update_bgp_connection. Returns the created connection's full detail. Requires RouterOS v7 with the routing package.

ParameterRequiredDefinition
nameYesUnique connection name {"type":"string"}
remote_addressYesPeer IP address (remote.address) {"type":"string"}
remote_asNoPeer AS number (remote.as) {"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
remote_portNoPeer TCP port (remote.port) {"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
asNoLocal AS number {"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
local_roleNolocal.role: ebgp, ibgp, ebgp-customer, ebgp-provider, ibgp-rr, ibgp-rr-client, … {"type":"string"}
local_addressNoLocal source address (local.address) {"type":"string"}
local_portNoLocal TCP port (local.port) {"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
router_idNoOverride router-id for this connection {"type":"string"}
cluster_idNoRoute-reflector cluster ID (cluster-id) {"type":"string"}
templatesNoTemplate name(s) to inherit settings from {"type":"string"}
address_familiesNoComma list, e.g. "ip" or "ip,ipv6,l2vpn" {"type":"string"}
hold_timeNoe.g. "3m" or "180s" {"type":"string"}
keepalive_timeNo{"type":"string"}
multihopNoAllow non-directly-connected peers {"type":"boolean"}
nexthop_choiceNodefault, force-self, or propagate {"type":"string"}
use_bfdNoUse BFD for fast failure detection (use-bfd) {"type":"boolean"}
tcp_md5_keyNoTCP MD5 authentication key (tcp-md5-key) {"type":"string"}
connectNoActively initiate the TCP session (connect) {"type":"boolean"}
listenNoAccept incoming TCP session (listen) {"type":"boolean"}
input_filterNoRouting filter chain for inbound routes (input.filter) {"type":"string"}
input_accept_nlriNoAddress list of accepted NLRI prefixes (input.accept-nlri) {"type":"string"}
input_allow_asNoNumber of times own AS may appear in AS-path (input.allow-as) {"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
input_ignore_as_path_lenNoIgnore AS-path length in best-path selection (input.ignore-as-path-len) {"type":"boolean"}
output_filterNoRouting filter chain for outbound routes (output.filter) {"type":"string"}
output_networkNoAddress list of networks to originate/advertise (output.network) {"type":"string"}
output_default_originateNoAdvertise a default route: never, if-installed, or always (output.default-originate) {"type":"string"}
output_redistributeNoComma list of route sources to redistribute, e.g. connected,static (output.redistribute) {"type":"string"}
output_as_overrideNoReplace peer AS in AS-path with local AS (output.as-override) {"type":"boolean"}
output_keep_sent_attributesNoRetain sent path attributes for inspection (output.keep-sent-attributes) {"type":"boolean"}
output_no_client_to_client_reflectionNoDisable route-reflector client-to-client reflection (output.no-client-to-client-reflection) {"type":"boolean"}
routing_tableNoRIB to install learned routes into {"type":"string"}
vrfNo{"type":"string"}
commentNo{"type":"string"}
disabledYes{"default":false,"type":"boolean"}

update_bgp_connection

Update BGP Connection · Risk: write-idempotent

Modifies settings of an existing BGP connection by name (/routing bgp connection set [find name="<name>"]). Only supplied fields are changed; omitted fields are left unchanged. To enable or disable a connection without touching other settings use set_bgp_connection_enabled. To delete a connection use remove_bgp_connection. Returns the full updated connection detail on success.

ParameterRequiredDefinition
nameYesExisting BGP connection name {"type":"string"}
remote_addressNo{"type":"string"}
remote_asNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
remote_portNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
asNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
local_roleNo{"type":"string"}
local_addressNo{"type":"string"}
local_portNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
router_idNo{"type":"string"}
cluster_idNo{"type":"string"}
address_familiesNo{"type":"string"}
hold_timeNo{"type":"string"}
keepalive_timeNo{"type":"string"}
multihopNo{"type":"boolean"}
nexthop_choiceNo{"type":"string"}
use_bfdNo{"type":"boolean"}
tcp_md5_keyNo{"type":"string"}
connectNo{"type":"boolean"}
listenNo{"type":"boolean"}
input_filterNo{"type":"string"}
input_accept_nlriNo{"type":"string"}
input_allow_asNo{"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
input_ignore_as_path_lenNo{"type":"boolean"}
output_filterNo{"type":"string"}
output_networkNo{"type":"string"}
output_default_originateNo{"type":"string"}
output_redistributeNo{"type":"string"}
output_as_overrideNo{"type":"boolean"}
output_keep_sent_attributesNo{"type":"boolean"}
output_no_client_to_client_reflectionNo{"type":"boolean"}
routing_tableNo{"type":"string"}
commentNo{"type":"string"}
disabledNo{"type":"boolean"}

remove_bgp_connection

Remove BGP Connection · Risk: destructive

Permanently deletes a BGP peer connection by name (/routing bgp connection remove [find name="<name>"]), tearing down the peering and removing all its configuration. To only suspend a connection without deleting it use set_bgp_connection_enabled. To remove a shared settings object use remove_bgp_template. The name is the connection name visible in list_bgp_connections.

ParameterRequiredDefinition
nameYesBGP connection name to remove {"type":"string"}

set_bgp_connection_enabled

Enable or Disable BGP Connection · Risk: write-idempotent

Enables or disables a BGP connection by name (/routing bgp connection set [find name="<name>"] disabled=yes/no). Pass enabled=true to bring a peer up, enabled=false to suspend it without deleting its configuration. To change other connection settings use update_bgp_connection. To permanently delete the connection use remove_bgp_connection.

ParameterRequiredDefinition
nameYesBGP connection name {"type":"string"}
enabledYes{"type":"boolean"}

list_bgp_templates

List BGP Templates · Risk: read

Lists BGP template objects (/routing bgp template print detail). Templates hold shared peer settings — AS number, address-families, route filters, timers — that individual connections inherit via their templates field, avoiding repetition across many peers. For per-peer connection configuration use list_bgp_connections. For runtime session state use list_bgp_sessions. Returns all defined templates. Requires RouterOS v7 with the routing package.

No tool-specific parameters.

add_bgp_template

Add BGP Template · Risk: write

Creates a BGP template (/routing bgp template add) to hold shared peer settings (AS, address-families, route filters, routing table) that multiple connections can inherit via their templates field, avoiding repetition across many peers. For address_families pass a comma-separated list, e.g. "ip,ipv6". input_filter/output_filter reference /routing filter chain names. To create a peer that references this template use add_bgp_connection. To remove a template use remove_bgp_template. Returns success confirmation; verify with list_bgp_templates. Requires RouterOS v7 with the routing package.

ParameterRequiredDefinition
nameYesTemplate name {"type":"string"}
asNoLocal AS number {"type":"integer","minimum":-9007199254740991,"maximum":9007199254740991}
router_idNo{"type":"string"}
cluster_idNoRoute-reflector cluster ID (cluster-id) {"type":"string"}
address_familiesNoe.g. "ip,ipv6" {"type":"string"}
hold_timeNoe.g. "3m" or "180s" {"type":"string"}
keepalive_timeNo{"type":"string"}
multihopNoAllow non-directly-connected peers {"type":"boolean"}
nexthop_choiceNodefault, force-self, or propagate {"type":"string"}
use_bfdNoUse BFD for fast failure detection (use-bfd) {"type":"boolean"}
input_filterNo{"type":"string"}
output_filterNo{"type":"string"}
output_networkNoAddress list of networks to originate/advertise (output.network) {"type":"string"}
output_default_originateNoAdvertise a default route: never, if-installed, or always (output.default-originate) {"type":"string"}
output_redistributeNoComma list of route sources to redistribute, e.g. connected,static (output.redistribute) {"type":"string"}
routing_tableNo{"type":"string"}
commentNo{"type":"string"}
disabledYes{"default":false,"type":"boolean"}

remove_bgp_template

Remove BGP Template · Risk: destructive

Permanently deletes a BGP template by name (/routing bgp template remove [find name="<name>"]). Connections that referenced this template lose the inherited settings — review with list_bgp_connections before removing. To remove a peer connection instead use remove_bgp_connection. The name is the template name visible in list_bgp_templates.

ParameterRequiredDefinition
nameYesBGP template name to remove {"type":"string"}

list_bgp_sessions

List BGP Sessions · Risk: read

Lists runtime BGP session state (/routing bgp session print detail) — negotiated peering status (established/idle/active/…), remote AS, uptime, and received/advertised prefix counts. This is the live operational view, not configuration; to view or change peer configuration use list_bgp_connections. Pass established_only=true to filter to established (fully up) sessions only. For prefixes being sent to a peer use list_bgp_advertisements. Returns all matching session entries. Requires RouterOS v7 with the routing package.

ParameterRequiredDefinition
established_onlyYesShow only established sessions {"default":false,"type":"boolean"}

list_bgp_advertisements

List BGP Advertisements · Risk: read

Lists prefixes currently being advertised to BGP peers (/routing bgp advertisements print) after output filters are applied — use this to verify exactly what routes this router is sending to a given peer. Read-only operational data; to see session status (prefix counts, uptime) use list_bgp_sessions. Filter by peer name substring with peer_filter. Returns advertisement entries per peer, or a not-found message. Requires RouterOS v7 with the routing package.

ParameterRequiredDefinition
peer_filterNoSubstring match on the peer name {"type":"string"}

On this page