Difference between revisions of "BGP"

From StarOS Community Wiki
Jump to navigation Jump to search
 
m
 
(10 intermediate revisions by the same user not shown)
Line 6: Line 6:
BGP can be as simple as you want to make it.
BGP can be as simple as you want to make it.


[code]
Current configuration:
!
hostname b2100
password 1234
!
router bgp 15947
bgp router-id 84.203.192.22
bgp log-neighbor-changes
bgp always-compare-med
bgp bestpath med confed
network 194.0.76.0/22


To setup BGP you need to peer with someone else using BGP. This other network is called a "peer"


There are 3 types of neighbour peering relationship you can have on your BGP network.


1. Transit peer - this is a peer which you are paying for bandwidth


neighbor 84.203.192.21 remote-as 31458
With Transit peers they will send you a full routing table or a default route, this routing table allows your network know how to connect to hosts across the Internet
neighbor 84.203.192.21 description Transit to Smart Telecom
neighbor 84.203.192.21 soft-reconfiguration inbound
neighbor 84.203.192.21 prefix-list AS-Transit-Provider-in in
neighbor 84.203.192.21 prefix-list AS-CCB-Smart-out out
neighbor 84.203.192.21 route-map Smart-Transit-in in
neighbor 84.203.192.21 route-map Smart-transit-out out


neighbor 91.142.224.177 remote-as 42090
2. Free Peer - this a peer where two networks connect to share traffic.
neighbor 91.142.224.177 description Peer to Rapid Broadband
neighbor 91.142.224.177 soft-reconfiguration inbound
neighbor 91.142.224.177 prefix-list AS-Transit-Provider-in in
neighbor 91.142.224.177 prefix-list AS-CCB-RapidBB-out out
neighbor 91.142.224.177 route-map Rapid-Transit-in in
neighbor 91.142.224.177 route-map Rapid-Transit-out out


neighbor 91.142.224.179 remote-as 41736
Peers of this nature will usually not provide each other with a full routing table, but will provide each other with the IP Subnet (Networks) they each advertise, therefore you can send traffic to this peer bypassing your paid transit.
neighbor 91.142.224.179 description Peer to Nova Networks
neighbor 91.142.224.179 shutdown
neighbor 91.142.224.179 soft-reconfiguration inbound
neighbor 91.142.224.179 prefix-list AS-NovaNet-in in
neighbor 91.142.224.179 prefix-list AS-CCB-peer-out out
neighbor 91.142.224.179 route-map Nova-peer-in in
neighbor 91.142.224.179 route-map Airport-peer-out out


neighbor 194.0.76.149 remote-as 15947
Peering like this is usually completed at Internet Exchange Points (IX or IXP)
neighbor 194.0.76.149 description Link to B2100
neighbor 194.0.76.149 soft-reconfiguration inbound
neighbor 194.0.76.149 prefix-list AS-ALL-in in
neighbor 194.0.76.149 prefix-list AS-ALL-out out
neighbor 194.0.76.149 route-map ALL-in in
neighbor 194.0.76.149 route-map ALL-out out


neighbor 194.0.77.58 remote-as 15405
3. Customer peer - this is where a customer is paying you for bandwidth.
neighbor 194.0.77.58 description Customer East Cork Broadband
neighbor 194.0.77.58 soft-reconfiguration inbound
neighbor 194.0.77.58 prefix-list AS-ECBB-in in
neighbor 194.0.77.58 prefix-list AS-Customer-out out
neighbor 194.0.77.58 route-map ECBB-cust-in in
neighbor 194.0.77.58 route-map Customer-out out


neighbor 195.28.164.125 remote-as 23456
In this case you are acting as the Transit peer for your customer and you need to provide them with access to all hosts on the Internet (via either default routes or a full routing table)
neighbor 195.28.164.125 description Test to Quagga
 
neighbor 195.28.164.125 ebgp-multihop 255
 
neighbor 195.28.164.125 timers 120 3600
the following example shows a Sample BGP script used with StarOS v3 X86 Server Edition to peer with 1 Transit peer, 1 free peer and 1 customer.
neighbor 195.28.164.125 soft-reconfiguration inbound
 
neighbor 195.28.164.125 prefix-list AS-Quagga-in in
The customer route is prefered, next is the free peer, and last is the transit peer.
neighbor 195.28.164.125 prefix-list AS-CCB-out out
 
neighbor 195.28.164.125 route-map Quagga-test-in in
I've used the following details for this example
neighbor 195.28.164.125 route-map Quagga-test-out out
 
!
1. Our AS Number is AS64512
access-list vtylist permit 127.0.0.1/32
 
access-list vtylist deny any
2. Our IP Subnet is 192.168.0.0/24
!
 
ip prefix-list AS-ALL-in seq 10 permit any
3. Our Transit Peer BGP Router is 10.0.0.1
ip prefix-list AS-ALL-out seq 10 permit any
 
ip prefix-list AS-CCB-RapidBB-out seq 10 permit 194.0.76.0/22
 
ip prefix-list AS-CCB-RapidBB-out seq 15 permit 194.0.78.0/23
4. Our IP Address on the Transit Network is 10.0.0.2
ip prefix-list AS-CCB-RapidBB-out seq 20 permit 194.0.77.0/24
 
ip prefix-list AS-CCB-RapidBB-out seq 25 permit 194.0.76.0/24
5. Our Transit's AS Number is AS65513
ip prefix-list AS-CCB-RapidBB-out seq 30 permit 195.2.226.0/23
 
ip prefix-list AS-CCB-RapidBB-out seq 31 permit 195.2.226.0/24
 
ip prefix-list AS-CCB-RapidBB-out seq 32 permit 195.2.227.0/24
6. Our Free Peer BGP Router is 172.16.0.1
ip prefix-list AS-CCB-RapidBB-out seq 40 permit 91.198.244.0/24
 
ip prefix-list AS-CCB-RapidBB-out seq 50 deny any
7. Our IP Address on the Free Peer Network is 172.16.0.2
ip prefix-list AS-CCB-Smart-out seq 10 permit 194.0.76.0/22
 
ip prefix-list AS-CCB-Smart-out seq 30 permit 195.2.226.0/23
8. Our Free Peer's AS Number is AS65514
ip prefix-list AS-CCB-Smart-out seq 31 permit 195.2.226.0/24
 
ip prefix-list AS-CCB-Smart-out seq 32 permit 195.2.227.0/24
9. Our Free Peer's IP Subnet is 192.168.1.0/24
ip prefix-list AS-CCB-Smart-out seq 40 permit 91.198.244.0/24
 
ip prefix-list AS-CCB-Smart-out seq 50 deny any
 
ip prefix-list AS-CCB-out seq 10 permit 194.0.76.0/22
10. Our Customer Peer BGP Router is 192.168.0.3
ip prefix-list AS-CCB-out seq 20 permit 84.203.210.0/23
 
ip prefix-list AS-CCB-out seq 30 permit 195.2.226.0/23
11. Our Customer Peer IP Address on our network is 192.168.0.3
ip prefix-list AS-CCB-out seq 31 permit 195.2.226.0/24
 
ip prefix-list AS-CCB-out seq 32 permit 195.2.227.0/24
12. Our Customer Peer AS Number is AS65515
ip prefix-list AS-CCB-out seq 40 permit 91.198.244.0/24
 
ip prefix-list AS-CCB-out seq 50 deny any
13. Our Customer Peer IP Subnet is 192.168.2.0/24
ip prefix-list AS-CCB-peer-out seq 10 permit 194.0.76.0/22
 
ip prefix-list AS-CCB-peer-out seq 30 permit 195.2.226.0/23
 
ip prefix-list AS-CCB-peer-out seq 31 permit 195.2.226.0/24
router bgp 64512
ip prefix-list AS-CCB-peer-out seq 32 permit 195.2.227.0/24
  bgp router-id 10.0.0.2
ip prefix-list AS-CCB-peer-out seq 40 permit 91.198.244.0/24
  network 192.168.0.0/24
ip prefix-list AS-CCB-peer-out seq 50 deny any
 
ip prefix-list AS-Customer-nodefault-out seq 10 deny 0.0.0.0/0
neighbor 10.0.0.1 remote-as 65513
ip prefix-list AS-Customer-nodefault-out seq 20 permit any
neighbor 10.0.0.1 description Transit Peer
ip prefix-list AS-Customer-onlydefault-out seq 10 permit 0.0.0.0/0
neighbor 10.0.0.1 soft-reconfiguration inbound
ip prefix-list AS-Customer-onlydefault-out seq 20 deny any
neighbor 10.0.0.1 prefix-list IP-Transit-in in
ip prefix-list AS-Customer-out seq 10 permit any
neighbor 10.0.0.1 prefix-list IP-out out
ip prefix-list AS-ECBB-in seq 10 permit 195.2.226.0/23
neighbor 10.0.0.1 route-map AS-Transit-in in
ip prefix-list AS-ECBB-in seq 11 permit 195.2.226.0/24
neighbor 10.0.0.1 route-map AS-out out
ip prefix-list AS-ECBB-in seq 12 permit 195.2.227.0/24
neighbor 172.16.0.1 remote-as 65514
ip prefix-list AS-ECBB-in seq 20 permit 91.198.244.0/24
neighbor 172.16.0.1 description Free Peer
ip prefix-list AS-ECBB-in seq 30 deny any
neighbor 172.16.0.1 soft-reconfiguration inbound
ip prefix-list AS-NovaNet-in seq 10 permit 91.142.110.0/20
neighbor 172.16.0.1 prefix-list IP-Free-Peer-in in
ip prefix-list AS-NovaNet-in seq 20 deny any
neighbor 172.16.0.1 prefix-list IP-out out
ip prefix-list AS-Quagga-in seq 10 deny any
neighbor 172.16.0.1 route-map AS-Free-Peer-in in
ip prefix-list AS-RapidBB-in seq 10 permit 91.142.224.0/20
neighbor 172.16.0.1 route-map AS-out out
ip prefix-list AS-RapidBB-in seq 20 permit 92.60.192.0/20
neighbor 192.168.0.3 remote-as 65514
ip prefix-list AS-RapidBB-in seq 40 permit any
neighbor 192.168.0.3 description Customer
ip prefix-list AS-Transit-Provider-in seq 5 permit any
neighbor 192.168.0.3 soft-reconfiguration inbound
!
neighbor 192.168.0.3 prefix-list IP-Customer-in in
ip as-path access-list 1 permit .*
neighbor 192.168.0.3 prefix-list IP-Customer-out out
ip as-path access-list 2 permit ^$
neighbor 192.168.0.3 route-map AS-Customer-in in
ip as-path access-list 3 permit ^15405$
neighbor 192.168.0.3 route-map AS-Customer-out out
ip as-path access-list 3 permit ^15947$
 
ip as-path access-list 3 permit ^$
ip prefix-list IP-Transit-in seq 10 permit any
ip as-path access-list 15405 permit ^15405$
ip prefix-list IP-out seq 10 permit 192.168.0.0/24
ip as-path access-list 15947 permit ^15947$
ip prefix-list IP-out seq 20 permit 192.168.2.0/24
ip as-path access-list 23456 permit ^23456$
ip prefix-list IP-Free-Peer-in seq 10 permit 192.168.1.0/24
ip as-path access-list 31458 permit ^31458$
ip prefix-list IP-Free-Peer-in seq 10 deny any
ip as-path access-list 41736 permit ^41736$
ip prefix-list IP-Customer-in seq 10 permit 192.168.2.0/24
ip as-path access-list 42090 permit ^42090$
ip prefix-list IP-Customer-in seq 20 deny any
!
ip prefix-list IP-Customer-out seq 10 permit any
route-map Nova-peer-in permit 10
 
  match as-path 41736
ip as-path access-list 1 permit .*
set local-preference 100
ip as-path access-list 2 permit ^65512$
!
ip as-path access-list 2 permit ^65514$
route-map Rapid-peer-in permit 10
ip as-path access-list 2 permit ^$
match as-path 1
ip as-path access-list 65513 permit ^65513$
set local-preference 80
ip as-path access-list 65514 permit ^65514$
!
 
route-map ECBB-cust-in permit 10
 
match as-path 15405
  route-map AS-Transit-in permit 10
  set local-preference 120
  match as-path 1
!
  set local-preference 80
route-map Quagga-test-in permit 10
route-map AS-out permit 10
match as-path 23456
  match as-path 2
set local-preference 10
  route-map AS-Free-Peer-in permit 10
!
  match as-path 65513
route-map Smart-transit-out permit 10
  set local-preference 100
  match as-path 3
  route-map AS-Customer-in permit 10
!
  match as-path 65514
route-map Quagga-test-out permit 10
  set local-preference 120
match as-path 3
  route-map AS-Customer-out permit 10
!
  match as-path 1
route-map Airport-peer-out permit 10
match as-path 3
!
route-map Customer-out permit 10
match as-path 1
!
route-map Transit-Provider-in permit 10
match as-path 1
set local-preference 80
!
route-map ALL-in permit 10
  match as-path 1
!
route-map ALL-out permit 10
match as-path 1
!
route-map Rapid-Transit-out permit 10
match as-path 3
!
route-map Rapid-Transit-in permit 10
match as-path 1
set local-preference 80
!
route-map Smart-Transit-in permit 10
match as-path 1
set local-preference 80
!
line vty
access-class vtylist
!
end
[/code]

Latest revision as of 18:40, 6 July 2009

BGP is oriented toward the largest scale, such as the entire Internet. It might be used by an ISP who has multiple attachment points to the Internet from different upstream providers.


To use BGP to peer on the Internet you must have an AS Number and a public IP Subnet assigned to you.

BGP can be as simple as you want to make it.


To setup BGP you need to peer with someone else using BGP. This other network is called a "peer"

There are 3 types of neighbour peering relationship you can have on your BGP network.

1. Transit peer - this is a peer which you are paying for bandwidth

With Transit peers they will send you a full routing table or a default route, this routing table allows your network know how to connect to hosts across the Internet

2. Free Peer - this a peer where two networks connect to share traffic.

Peers of this nature will usually not provide each other with a full routing table, but will provide each other with the IP Subnet (Networks) they each advertise, therefore you can send traffic to this peer bypassing your paid transit.

Peering like this is usually completed at Internet Exchange Points (IX or IXP)

3. Customer peer - this is where a customer is paying you for bandwidth.

In this case you are acting as the Transit peer for your customer and you need to provide them with access to all hosts on the Internet (via either default routes or a full routing table)


the following example shows a Sample BGP script used with StarOS v3 X86 Server Edition to peer with 1 Transit peer, 1 free peer and 1 customer.

The customer route is prefered, next is the free peer, and last is the transit peer.

I've used the following details for this example

1. Our AS Number is AS64512

2. Our IP Subnet is 192.168.0.0/24

3. Our Transit Peer BGP Router is 10.0.0.1


4. Our IP Address on the Transit Network is 10.0.0.2

5. Our Transit's AS Number is AS65513


6. Our Free Peer BGP Router is 172.16.0.1

7. Our IP Address on the Free Peer Network is 172.16.0.2

8. Our Free Peer's AS Number is AS65514

9. Our Free Peer's IP Subnet is 192.168.1.0/24


10. Our Customer Peer BGP Router is 192.168.0.3

11. Our Customer Peer IP Address on our network is 192.168.0.3

12. Our Customer Peer AS Number is AS65515

13. Our Customer Peer IP Subnet is 192.168.2.0/24


router bgp 64512
 bgp router-id 10.0.0.2
 network 192.168.0.0/24
neighbor 10.0.0.1 remote-as 65513
neighbor 10.0.0.1 description Transit Peer
neighbor 10.0.0.1 soft-reconfiguration inbound
neighbor 10.0.0.1 prefix-list IP-Transit-in in
neighbor 10.0.0.1 prefix-list IP-out out
neighbor 10.0.0.1 route-map AS-Transit-in in
neighbor 10.0.0.1 route-map AS-out out
neighbor 172.16.0.1 remote-as 65514
neighbor 172.16.0.1 description Free Peer
neighbor 172.16.0.1 soft-reconfiguration inbound
neighbor 172.16.0.1 prefix-list IP-Free-Peer-in in
neighbor 172.16.0.1 prefix-list IP-out out
neighbor 172.16.0.1 route-map AS-Free-Peer-in in
neighbor 172.16.0.1 route-map AS-out out
neighbor 192.168.0.3 remote-as 65514
neighbor 192.168.0.3 description Customer
neighbor 192.168.0.3 soft-reconfiguration inbound
neighbor 192.168.0.3 prefix-list IP-Customer-in in
neighbor 192.168.0.3 prefix-list IP-Customer-out out
neighbor 192.168.0.3 route-map AS-Customer-in in
neighbor 192.168.0.3 route-map AS-Customer-out out
ip prefix-list IP-Transit-in seq 10 permit any
ip prefix-list IP-out seq 10 permit 192.168.0.0/24
ip prefix-list IP-out seq 20 permit 192.168.2.0/24
ip prefix-list IP-Free-Peer-in seq 10 permit 192.168.1.0/24
ip prefix-list IP-Free-Peer-in seq 10 deny any
ip prefix-list IP-Customer-in seq 10 permit 192.168.2.0/24
ip prefix-list IP-Customer-in seq 20 deny any
ip prefix-list IP-Customer-out seq 10 permit any
ip as-path access-list 1 permit .*
ip as-path access-list 2 permit ^65512$
ip as-path access-list 2 permit ^65514$
ip as-path access-list 2 permit ^$
ip as-path access-list 65513 permit ^65513$
ip as-path access-list 65514 permit ^65514$


route-map AS-Transit-in permit 10
 match as-path 1
 set local-preference 80
route-map AS-out permit 10
 match as-path 2
route-map AS-Free-Peer-in permit 10
 match as-path 65513
 set local-preference 100
route-map AS-Customer-in permit 10
 match as-path 65514
 set local-preference 120
route-map AS-Customer-out permit 10
 match as-path 1