Hands-on tutorial

Tutorials · Routing & Internet

BGP Basics: Connecting to Two Internet Providers With Your Own IP Addresses

Understand when you need BGP, what you need from the registry and the ISPs, and how to announce your prefix, receive routes and filter safely on two providers.

Advanced12 min7 steps

Before you start

  • Your own public IPv4 and/or IPv6 prefix and an AS number (from your regional internet registry or an ISP)
  • Two ISPs that offer BGP sessions
  • A router or firewall that supports BGP with prefix filtering

Step by step

  1. Decide whether you need BGP

    BGP makes sense when public services must stay reachable at the same addresses through either ISP. For outbound internet only, dual-WAN failover is simpler.

  2. Get the resources

    Obtain an AS number and a prefix (a /24 IPv4 or a /48 IPv6 is the smallest normally accepted). Create route objects and RPKI ROAs so ISPs accept your announcement.

  3. Agree the sessions with each ISP

    Each ISP gives you a peer address, its AS number and what it will send: default route only, or full routes. A default route from each is enough for most organisations.

  4. Configure the sessions

    Configure each neighbour, announce only your own prefix, and accept only what you expect.

    router bgp 64512
     neighbor 198.51.100.1 remote-as 65010
     neighbor 203.0.113.1 remote-as 65020
     network 192.0.2.0/24
    
  5. Filter both directions

    Outbound: allow only your prefix, or you may leak other routes to the internet. Inbound: accept only the default route or the routes you expect, and set a maximum-prefix limit.

  6. Choose primary and backup

    Prefer one ISP outbound with local preference, and make the other less attractive inbound by AS-path prepending.

  7. Test failover

    Shut each session in a maintenance window and confirm that your prefix is still reachable from outside, using public looking-glass tools.

Commands are generic, industry-standard examples. Exact syntax and menu names vary by model and firmware; check your device's manual on the Documentation page.

Pro tips

  • Use MD5 or TCP-AO session passwords and GTSM where the ISP supports them.
  • Document the ISP contacts and circuit IDs next to the configuration.
  • Never redistribute your internal routing protocol into BGP.