# Wiki source code of BGP

Last modified by Jean Franco on 2022/06/23 22:09
Export
Office Formats
Export as PDF Export as ODT Export as RTF
Other Formats

Select the pages to export:

select all/ none

Legend:
  Created Page
  Modified Extension Page
  Clean Extension Page

Export as HTML

Show last authors

author | version | line-number | content
--- | --- | --- | ---
|  | 1 | == The Prefix Lists ==
|  | 2 |
|  | 3 | The prefix lists are used to control what routes you get from your ISP, as well as the ones you send (announce).
|  | 4 |
|  | 5 | {{code language="none"}}
|  | 6 | policy {
|  | 7 | prefix-list BGP-ISP-From {
|  | 8 | rule 10 {
|  | 9 | action permit
|  | 10 | le 24
|  | 11 | prefix 0.0.0.0/0
|  | 12 | }
|  | 13 | }
|  | 14 | prefix-list BGP-ISP-To {
|  | 15 | rule 10 {
|  | 16 | action permit
|  | 17 | prefix 192.0.2.0/24
|  | 18 | }
|  | 19 | }
|  | 20 | prefix-list6 BGP-ISPv6-From {
|  | 21 | rule 10 {
|  | 22 | action permit
|  | 23 | le 64
|  | 24 | prefix 0::/0
|  | 25 | }
|  | 26 | }
|  | 27 | prefix-list6 BGP-ISPv6-To {
|  | 28 | rule 10 {
|  | 29 | action permit
|  | 30 | le 48
|  | 31 | prefix 2001:DB8::/32
|  | 32 | }
|  | 33 | }
|  | 34 | }
|  | 35 | {{/code}}
|  | 36 |
|  | 37 | The -From prefix lists are for routes you receive (imported) from your ISP, while the -To lists are for routes being exported (announced) to your provider. In the case of IPv4, the smallest globally accepted size most if not all providers announce is /24. For IPv6, the smallest globally accepted size is /48.
|  | 38 |
|  | 39 | 'le' means any prefix smaller (ie: 'le 48' won't allow a /64 IPv6 prefix from your ISP's routing table, but it will allow a /32). 'ge' means any prefix greater (ie: 'ge 56' won't allow a /48, but will allow a /56, /64, or even /128).
|  | 40 |
|  | 41 | In the above examples, 192.0.2.0/24 is your IPv4 netblock, and 2001:DB8::/32 is your IPv6 one. 0.0.0.0/0 and 0::/0 means match all.
|  | 42 |
|  | 43 | === Route Maps ===
|  | 44 |
|  | 45 | While you can just use prefix lists with BGP to control routes imported and exported, route maps give you much more flexibility and control, and can even include AS path matching.
|  | 46 |
|  | 47 | {{code language="none"}}
|  | 48 | policy {
|  | 49 | route-map BGP-ISPv6-From {
|  | 50 | rule 10 {
|  | 51 | action permit
|  | 52 | match {
|  | 53 | ipv6 {
|  | 54 | address {
|  | 55 | prefix-list BGP-ISPv6-From
|  | 56 | }
|  | 57 | }
|  | 58 | }
|  | 59 | }
|  | 60 | }
|  | 61 | route-map BGP-ISPv6-To {
|  | 62 | rule 10 {
|  | 63 | action permit
|  | 64 | match {
|  | 65 | ipv6 {
|  | 66 | address {
|  | 67 | prefix-list BGP-ISPv6-To
|  | 68 | }
|  | 69 | }
|  | 70 | }
|  | 71 | }
|  | 72 | }
|  | 73 | route-map BGP-ISP-From {
|  | 74 | rule 10 {
|  | 75 | action permit
|  | 76 | match {
|  | 77 | ip {
|  | 78 | address {
|  | 79 | prefix-list BGP-ISP-From
|  | 80 | }
|  | 81 | }
|  | 82 | }
|  | 83 | }
|  | 84 | }
|  | 85 | route-map BGP-ISP-To {
|  | 86 | rule 10 {
|  | 87 | action permit
|  | 88 | match {
|  | 89 | ip {
|  | 90 | address {
|  | 91 | prefix-list BGP-ISP-To
|  | 92 | }
|  | 93 | }
|  | 94 | }
|  | 95 | }
|  | 96 | }
|  | 97 | }
|  | 98 | {{/code}}
|  | 99 |
|  | 100 | Like the prefix lists, -To and -From are your specific directions in and out (import and export). They're pretty self explanatory and reference the prefix lists used before.
|  | 101 |
|  | 102 | BGP Protocol Information
|  | 103 |
|  | 104 | {{code language="none"}}
|  | 105 | protocols {
|  | 106 | bgp 65501 {
|  | 107 | address-family {
|  | 108 | ipv6-unicast {
|  | 109 | network 2001:DB8::/32 {
|  | 110 | }
|  | 111 | }
|  | 112 | }
|  | 113 | neighbor 100.64.100.1 {
|  | 114 | remote-as 65502
|  | 115 | route-map {
|  | 116 | export BGP-ISP-To
|  | 117 | import BGP-ISP-From
|  | 118 | }
|  | 119 | soft-reconfiguration {
|  | 120 | inbound
|  | 121 | }
|  | 122 | update-source 100.64.100.2
|  | 123 | }
|  | 124 | neighbor fd00::1 {
|  | 125 | address-family {
|  | 126 | ipv6-unicast {
|  | 127 | route-map {
|  | 128 | export BGP-ISPv6-To
|  | 129 | import BGP-ISPv6-From
|  | 130 | }
|  | 131 | }
|  | 132 | }
|  | 133 | remote-as 65502
|  | 134 | soft-reconfiguration {
|  | 135 | inbound
|  | 136 | }
|  | 137 | update-source fd00::2
|  | 138 | }
|  | 139 | network 192.0.2.0/24 {
|  | 140 | }
|  | 141 | parameters {
|  | 142 | router-id 100.64.100.2
|  | 143 | }
|  | 144 | redistribute {
|  | 145 | connected {
|  | 146 | }
|  | 147 | kernel {
|  | 148 | }
|  | 149 | static {
|  | 150 | }
|  | 151 | }
|  | 152 | }
|  | 153 | }
|  | 154 | {{/code}}
|  | 155 |
|  | 156 | In the above example, our local router has the IPv4 address of 100.64.100.2 and the IPv6 address of fd00::2 with an ASN of 65501. The BGP enabled router on our ISP side is 100.64.100.1 and fd00::1 with an ASN of 65502. We are assuming that our routers are connected over a non-shared link within one hop. If the BGP router is more than one hop away, you need to configure 'ebgp-multihop' with the appropriate amount of hops away your ISP's router is.
|  | 157 |
|  | 158 | Show BGP information:
|  | 159 |
|  | 160 | {{code language="none"}}
|  | 161 | user@router1:~$ show ip bgp neighbor
|  | 162 | BGP neighbor is 100.64.100.2, remote AS 65502, local AS 65501, external link
|  | 163 | BGP version 4, remote router ID 100.64.100.2
|  | 164 | BGP state = Established, up for 01w0d05h
|  | 165 | Last read 01w0d05h, hold time is 90, keepalive interval is 30 seconds
|  | 166 | Neighbor capabilities:
|  | 167 | Route refresh: advertised and received (old and new)
|  | 168 | 4-Octet ASN Capability: advertised and received
|  | 169 | Address family IPv4 Unicast: advertised and received
|  | 170 | Address family IPv4 Multicast: received
|  | 171 | Received 2838376 messages, 0 notifications, 0 in queue
|  | 172 | Sent 20788 messages, 0 notifications, 0 in queue
|  | 173 | Route refresh request: received 0, sent 0
|  | 174 | Minimum time between advertisement runs is 30 seconds
|  | 175 | Update source is 100.64.100.1
|  | 176 | For address family: IPv4 Unicast
|  | 177 | BGP table version 6603726, neighbor version 6603716
|  | 178 | Index 2, Offset 0, Mask 0x4
|  | 179 | Inbound soft reconfiguration allowed
|  | 180 | Community attribute sent to this neighbor (both)
|  | 181 | Inbound path policy configured
|  | 182 | Outbound path policy configured
|  | 183 | Route map for incoming advertisements is *BGP-ISP-From
|  | 184 | Route map for outgoing advertisements is *BGP-ISP-To
|  | 185 | 688930 accepted prefixes
|  | 186 | 1 announced prefixes
|  | 187 |
|  | 188 | Connections established 1; dropped 0
|  | 189 | External BGP neighbor may be up to 1 hops away.
|  | 190 | Local host: 100.64.100.2, Local port: 60803
|  | 191 | Foreign host: 100.64.100.1, Foreign port: 179
|  | 192 | Nexthop: 100.64.100.1
|  | 193 | BGP connection: shared network
|  | 194 |
|  | 195 | BGP neighbor is fd00::1, remote AS 65502, local AS 65501, external link
|  | 196 | BGP version 4, remote router ID 100.64.100.1
|  | 197 | BGP state = Established, up for 01w0d05h
|  | 198 | Last read 01w0d05h, hold time is 180, keepalive interval is 60 seconds
|  | 199 | Neighbor capabilities:
|  | 200 | Route refresh: advertised and received (old and new)
|  | 201 | 4-Octet ASN Capability: advertised and received
|  | 202 | Address family IPv4 Unicast: advertised
|  | 203 | Address family IPv6 Unicast: advertised and received
|  | 204 | Received 686685 messages, 0 notifications, 0 in queue
|  | 205 | Sent 10394 messages, 0 notifications, 0 in queue
|  | 206 | Route refresh request: received 0, sent 0
|  | 207 | Minimum time between advertisement runs is 30 seconds
|  | 208 | Update source is fd00::2
|  | 209 | For address family: IPv4 Unicast
|  | 210 | BGP table version 6603726, neighbor version 6603716
|  | 211 | Index 1, Offset 0, Mask 0x2
|  | 212 | Inbound soft reconfiguration allowed
|  | 213 | Community attribute sent to this neighbor (both)
|  | 214 | 0 accepted prefixes
|  | 215 | 0 announced prefixes
|  | 216 |
|  | 217 | For address family: IPv6 Unicast
|  | 218 | BGP table version 858622, neighbor version 858620
|  | 219 | Index 1, Offset 0, Mask 0x2
|  | 220 | Community attribute sent to this neighbor (both)
|  | 221 | Inbound path policy configured
|  | 222 | Outbound path policy configured
|  | 223 | Route map for incoming advertisements is *BGP-ISPv6-From
|  | 224 | Route map for outgoing advertisements is *BGP-ISPv6-To
|  | 225 | 49892 accepted prefixes
|  | 226 | 1 announced prefixes
|  | 227 |
|  | 228 | Connections established 1; dropped 0
|  | 229 | Local host: fd00::2, Local port: 179
|  | 230 | Foreign host: fd00::1, Foreign port: 8044
|  | 231 | Nexthop: 100.64.100.1
|  | 232 | Nexthop global: fd00::1
|  | 233 | BGP connection: shared network
|  | 234 | {{/code}}

# Applications

# Tips

Press the x+x+x+a key combo to toggle the Advanced mode and x+x+x+h to toggle the display of hidden pages.

Maila Networks
XWiki Debian 14.4.1