This is an old revision of the document!


BGP Peering With An ISP

When you have your own IPv4/IPv6 address space, it's advantageous to announce it via your router to your ISP - especially if you have multiple providers (multi-homing). Even the lowest end EdgeRouters such as the ER-X and ERL can do a full BGP table.

The prefix lists are used to control what routes you get from your ISP, as well as the ones you send (announce).

policy {
    prefix-list BGP-ISP-From {
        rule 10 {
            action permit
            le 24
            prefix 0.0.0.0/0
        }
    }
    prefix-list BGP-ISP-To {
        rule 10 {
            action permit
            prefix 192.0.2.0/24
        }
    }
    prefix-list6 BGP-ISPv6-From {
        rule 10 {
            action permit
            le 64
            prefix 0::/0
        }
    }
    prefix-list6 BGP-ISPv6-To {
        rule 10 {
            action permit
            le 48
            prefix 2001:DB8::/32
        }
    }
}

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.

'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).

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.

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.

policy {
    route-map BGP-ISPv6-From {
        rule 10 {
            action permit
            match {
                ipv6 {
                    address {
                        prefix-list BGP-ISPv6-From
                    }
                }
            }
        }
    }
    route-map BGP-ISPv6-To {
        rule 10 {
            action permit
            match {
                ipv6 {
                    address {
                        prefix-list BGP-ISPv6-To
                    }
                }
            }
        }
    }
    route-map BGP-ISP-From {
        rule 10 {
            action permit
            match {
                ip {
                    address {
                        prefix-list BGP-ISP-From
                    }
                }
            }
        }
    }
    route-map BGP-ISP-To {
        rule 10 {
            action permit
            match {
                ip {
                    address {
                        prefix-list BGP-ISP-To
                    }
                }
            }
        }
    }
}

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.

protocols {
    bgp 65501 {
        address-family {
            ipv6-unicast {
                network 2001:DB8::/32 {
                }
            }
        }
        neighbor 100.64.100.1 {
            remote-as 65502
            route-map {
                export BGP-ISP-To
                import BGP-ISP-From
            }
            soft-reconfiguration {
                inbound
            }
            update-source 100.64.100.2
        }
        neighbor fd00::1 {
            address-family {
                ipv6-unicast {
                    route-map {
                        export BGP-ISPv6-To
                        import BGP-ISPv6-From
                    }
                }
            }
            remote-as 65502
            soft-reconfiguration {
                inbound
            }
            update-source fd00::2
        }
        network 192.0.2.0/24 {
        }
        parameters {
            router-id 100.64.100.2
        }
        redistribute {
            connected {
            }
            kernel {
            }
            static {
            }
        }
    }
}
  • edgerouter/bgp.1526431752.txt.gz
  • Last modified: 2018/05/15 18:49
  • by brielle