Showing posts with label load-balancing. Show all posts
Showing posts with label load-balancing. Show all posts

BGP Load Balancing with Cisco IOS and Junos

Today we are going to do some BGP load balancing between a Cisco router and a Juniper router.

We have a very simple topology:


The Juniper router (JUNOS1) is called NewYork and the Cisco router (R1) is called London.

We have two connections between them 1.1.1.1/24 on the Juniper to 1.1.1.2/24 on the Cisco, and 2.2.2.1 on the Juniper to 2.2.2.2 on the Cisco. We will be using AS 65000 for the BGP AS.

For the Juniper basic configuration please check out these two posts:

Juniper router emulation in GNS3
Basic Juniper Router commands

What is BGP Load Balancing?

Load balancing can use two or more connections to send data to the same destination. Load balancing in BGP requires that we enable multi-pathing, so that the router knows that it can use more than one path at a time.

We will start with the basic BGP configuration and from there advertise a loopback network on each side, then we will set up multi-pathing.

Cisco IOS BGP setup

I won't explain all the Cisco steps as they shouldn't be anything new - but there are links to my book here. Shameless plug I know!
London(config)#router bgp 65000
London(config-router)#neighbor 1.1.1.1 remote-as 65000
London(config-router)#neighbor 2.2.2.1 remote-as 65000
London(config-router)#exit
London(config)#exit
London#

Juniper JunOS BGP setup

For the JunOS set up we will create the BGP AS under routing options, and then create a group called Cisco to add the two peerings to the Cisco router to, setting the AS number to match our own, and the type to be internal (iBGP).
root@NewYork> configure
Entering configuration mode

[edit]
root@NewYork# set routing-options autonomous-system 65000
root@NewYork# set protocols bgp group Cisco neighbor 1.1.1.2
root@NewYork# set protocols bgp group Cisco neighbor 2.2.2.2
root@NewYork# set protocols bgp group Cisco peer-as 65000
root@NewYork# set protocols bgp group Cisco type internal
root@NewYork# commit
commit complete

[edit]
root@NewYork#
At this stage our BGP peers should come up:
London#
*Apr 21 13:19:18.087: %BGP-5-ADJCHANGE: neighbor 1.1.1.1 Up
London#
*Apr 21 13:19:22.227: %BGP-5-ADJCHANGE: neighbor 2.2.2.1 Up
London#
We can confirm this by looking at the bgp neighbors on the NewYork router:
root@NewYork> show bgp neighbor
Peer: 1.1.1.2+46617 AS 65000   Local: 1.1.1.1+179 AS 65000
  Type: Internal    State: Established    Flags: 
  Last State: OpenConfirm   Last Event: RecvKeepAlive
  Last Error: None
  Options: 
  Holdtime: 90 Preference: 170
  Number of flaps: 0
  Peer ID: 2.2.2.2         Local ID: 1.1.1.1      Active Holdtime: 90
  Keepalive Interval: 30         Peer index: 0   
  BFD: disabled, down
  NLRI for restart configured on peer: inet-unicast
  NLRI advertised by peer: inet-unicast
  NLRI for this session: inet-unicast
  Peer supports Refresh capability (2)
  Stale routes from peer are kept for: 300
  Peer does not support Restarter functionality
  Peer does not support Receiver functionality
  Peer supports 4 byte AS extension (peer-as 65000)
  Peer does not support Addpath
  Table inet.0 Bit: 10000
    RIB State: BGP restart is complete
    Send state: in sync
    Active prefixes:              1
    Received prefixes:            1     
    Accepted prefixes:            1
    Suppressed due to damping:    0
    Advertised prefixes:          0
  Last traffic (seconds): Received 15   Sent 22   Checked 40  
  Input messages:  Total 8 Updates 2  Refreshes 0  Octets 226
  Output messages: Total 7 Updates 0  Refreshes 0  Octets 173
  Output Queue[0]: 0

Peer: 2.2.2.2+179 AS 65000     Local: 2.2.2.1+51595 AS 65000
  Type: Internal    State: Established    Flags: 
  Last State: OpenConfirm   Last Event: RecvKeepAlive
  Last Error: None
  Options: 
  Holdtime: 90 Preference: 170
  Number of flaps: 0
  Peer ID: 2.2.2.2         Local ID: 1.1.1.1      Active Holdtime: 90
  Keepalive Interval: 30         Peer index: 1   
  BFD: disabled, down
  NLRI for restart configured on peer: inet-unicast
  NLRI advertised by peer: inet-unicast
  NLRI for this session: inet-unicast
  Peer supports Refresh capability (2)
  Stale routes from peer are kept for: 300
  Peer does not support Restarter functionality
  Peer does not support Receiver functionality
  Peer supports 4 byte AS extension (peer-as 65000)
  Peer does not support Addpath
  Table inet.0 Bit: 10000
    RIB State: BGP restart is complete
    Send state: in sync
    Active prefixes:              0
    Received prefixes:            1
    Accepted prefixes:            1
    Suppressed due to damping:    0
    Advertised prefixes:          0
  Last traffic (seconds): Received 13   Sent 21   Checked 35  
  Input messages:  Total 5 Updates 2  Refreshes 0  Octets 135
  Output messages: Total 6 Updates 0  Refreshes 0  Octets 154
  Output Queue[0]: 0

root@NewYork> 

Advertising BGP prefixes in Cisco IOS and Juniper JunOS

Now we can add our loopback interfaces, and advertise them into BGP:
London(config)#int lo0
London(config-if)#ip add 172.20.1.1 255.255.255.0
London(config-if)#router bgp 65000
London(config-router)#network 172.20.1.0 mask 255.255.255.0
London(config-router)#
NewYork sees the route coming from both peering sessions, it prefers the one with the lower IP address (denoted by a *):
root@NewYork> show route
inet.0: 5 destinations, 6 routes (5 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

1.1.1.0/24         *[Direct/0] 01:08:36
                    > via em0.0
1.1.1.1/32         *[Local/0] 01:08:36
                      Local via em0.0
2.2.2.0/24         *[Direct/0] 01:08:36
                    > via em1.0
2.2.2.1/32         *[Local/0] 01:08:36
                      Local via em1.0
172.20.1.0/24      *[BGP/170] 00:01:20, MED 0, localpref 100
                      AS path: I
                    > to 1.1.1.2 via em0.0
                    [BGP/170] 00:01:20, MED 0, localpref 100
                      AS path: I
                    > to 2.2.2.2 via em1.0

root@NewYork>
Now let's add a loopback interface on the NewYork router and advertise it in BGP as well. The process isn't exactly as straight forward in JunOS, all advertisement is done through policy statements, which is then used to export (advertise to BGP neighbors) based on the specified group:
root@NewYork# set int lo0 unit 0 family inet address 192.168.1.1/24
root@NewYork# edit policy-options                                      

[edit policy-options]
root@NewYork# set policy-statement ADVERTISE_LO0 from interface lo0    
root@NewYork# set policy-statement ADVERTISE_LO0 then accept 

[edit policy-options]
root@NewYork# exit 

[edit]
root@NewYork# set protocols bgp group Cisco export ADVERTISE_LO0       

[edit]
root@NewYork# commit 
commit complete

[edit]
root@NewYork# 

And if all is well then the London router should see the new prefix:
London#sh ip route | beg Gate
Gateway of last resort is not set

      1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        1.1.1.0/24 is directly connected, GigabitEthernet1/0
L        1.1.1.2/32 is directly connected, GigabitEthernet1/0
      2.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        2.2.2.0/24 is directly connected, GigabitEthernet2/0
L        2.2.2.2/32 is directly connected, GigabitEthernet2/0
      172.20.0.0/16 is variably subnetted, 2 subnets, 2 masks
C        172.20.1.0/24 is directly connected, Loopback0
L        172.20.1.1/32 is directly connected, Loopback0
B     192.168.1.0/24 [200/0] via 1.1.1.1, 00:00:15
London#
It does, again choosing the router with the lower IP address. Now let's set up load balancing.

Enabling load balancing for BGP in Cisco IOS

Enabling load balancing in BGP on Cisco IOS is as simple as enabling the maximum-paths option.
London(config-router)#maximum-paths ibgp 2
London(config-router)#do sh ip route | beg Gate
Gateway of last resort is not set

      1.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        1.1.1.0/24 is directly connected, GigabitEthernet1/0
L        1.1.1.2/32 is directly connected, GigabitEthernet1/0
      2.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C        2.2.2.0/24 is directly connected, GigabitEthernet2/0
L        2.2.2.2/32 is directly connected, GigabitEthernet2/0
      172.20.0.0/16 is variably subnetted, 2 subnets, 2 masks
C        172.20.1.0/24 is directly connected, Loopback0
L        172.20.1.1/32 is directly connected, Loopback0
B     192.168.1.0/24 [200/0] via 2.2.2.1, 00:00:02
                     [200/0] via 1.1.1.1, 00:00:02
London(config-router)#do sh ip bgp
BGP table version is 5, local router ID is 2.2.2.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale, m multipath, b backup-path, x best-external, f RT-Filter
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 172.20.1.0/24    0.0.0.0                  0         32768 i
*mi192.168.1.0      1.1.1.1                       100      0 i
*>i                 2.2.2.1                       100      0 i
London(config-router)#
So our London router has now installed two paths into the routing table, courtesy of the maximum-paths command. Let's configure the same on the NewYork router.

Enabling load balancing for BGP in Juniper JunOS

Similarly to the Cisco IOS all we need to do with JunOS is to enable multipath under our BGP peer group:
root@NewYork# edit protocols bgp group Cisco
[edit protocols bgp group Cisco]
root@NewYork# set multipath 

[edit protocols bgp group Cisco]
root@NewYork# exit 

[edit]
root@NewYork# commit 
commit complete

[edit]
root@NewYork# exit 
Exiting configuration mode

root@NewYork> show route 172.20.1.0    

inet.0: 7 destinations, 8 routes (7 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both

172.20.1.0/24   *[BGP/170] 00:24:56, MED 0, localpref 100, from 1.1.1.2
                   AS path: I
                   to 1.1.1.2 via em0.0
                 > to 2.2.2.2 via em1.0
                 [BGP/170] 00:11:42, MED 0, localpref 100
                   AS path: 
                 > to 2.2.2.2 via em1.0

root@NewYork> show route 172.20.1.0 detail 

inet.0: 7 destinations, 8 routes (7 active, 0 holddown, 0 hidden)
172.20.1.0/24 (2 entries, 1 announced)
        *BGP    Preference: 170/-101
                Next hop type: Indirect
                Address: 0x9408078
                Next-hop reference count: 2
                Source: 1.1.1.2
                Next hop type: Router, Next hop index: 520
                Next hop: 1.1.1.2 via em0.0
                Next hop type: Router, Next hop index: 554
                Next hop: 2.2.2.2 via em1.0, selected
                Protocol next hop: 1.1.1.2
                Indirect next hop: 9384000 131071
                Protocol next hop: 2.2.2.2
                Indirect next hop: 93840e8 131070
                State: 
                Local AS: 65000 Peer AS: 65000
                Age: 18:57  Metric: 0  Metric2: 0 
                Task: BGP_65000.1.1.1.2+19079
                Announcement bits (2): 0-KRT 3-Resolve tree 1 
                AS path: I
                Accepted Multipath
                Localpref: 100          
                Router ID: 172.20.1.1
         BGP    Preference: 170/-101
                Next hop type: Indirect
                Address: 0x93345f8
                Next-hop reference count: 2
                Source: 2.2.2.2
                Next hop type: Router, Next hop index: 554
                Next hop: 2.2.2.2 via em1.0, selected
                Protocol next hop: 2.2.2.2
                Indirect next hop: 93840e8 131070
                State: 
                Inactive reason: Not Best in its group - Update source
                Local AS: 65000 Peer AS: 65000
                Age: 2:13  Metric: 0  Metric2: 0 
                Task: BGP_65000.2.2.2.2+45024
                AS path: I
                Accepted MultipathContrib
                Localpref: 100
                Router ID: 172.20.1.1

root@NewYork> 
Here we can see that also with just the setting up of multipathing our Juniper router will also now load-balanced - the "show route 172.20.1.0 detail" shows this with it's two next hop addresses and also the line "Accepted Multipath".

We can actually do a lot more with load-balancing, we can use unequal bandwidth to load-balance according to the resources at our disposal, or load-balance on a per-packet basis, but as far as simple load-balancing goes, this is pretty much it. It's not hard to set up as I hope this post has shown.

The BIG lab - Part 1 - Trunking, EtherChannel and Load-Balancing

I kind of feel that I really need to spend more time on my studies at the moment. So while the boys are down for their afternoon nap (but not sleeping) it's a good chance to get some work done.

In the real lab there will be a fairly large selection of switches and routers, and although you will have a number of specific tasks to complete both for the troubleshooting portion and the configuration portion it's important to understand that one task can greatly impact on another.

So instead of having little posts concentrating on one particular topic I have decided to make a number of posts but all sharing the same topology so that the impact of one design decision can be shown throughout the network.

So let's have a look at the things that I want to cover, and start building our topology.

Starting at the top of the CCIE exam topics we can cover:
Now you will have to excuse my drawing skills, I am using a Wacom Bamboo tablet and still getting used to it, but I think we'll end up with something like this:



So we have a number of routing protocols, a bit of frame relay, some trunking, etherchannel, well throw in some dialup technology, tunnelling and some IPv6 as well, and lets throw in some VTP for good measure. I think that this series will be very organic and will change and grow as we progress.

Let's start creating the netmap, as always I start by numbering the devices from left to right. and working out the connections from there. Apart from getting the R10 to SW1 interfaces round the wrong way, once I corrected it I ended up with this:


Cisco IOU netmap



If you are interested, the netmap looks like this:

1:0/0 2:0/0
2:0/1 3:0/0
2:0/2 4:0/0
4:0/1 5:0/0
5:0/1 6:0/0
6:0/1 7:0/1
4:0/2 8:0/0
5:0/2 9:0/0
8:0/1 9:0/1
8:0/2 10:1/0
10:0/1 11:1/1
11:0/0 12:0/0
11:0/1 12:0/1
11:0/2 13:1/0
13:0/0 14:0/0
13:0/1 14:0/1
12:1/0 14:1/0

So lets start at the top of our list and work our way down. I might just cover some trunking today as the kids have not gone to sleep, but they did get up at 8:30 this morning instead of their usual 7am, so it's not surprising really.

Switch basic configuration

Lets start by setting up a VTP domain and have the switches as either a master or a client, along with some different VLANs. If the switches support it we might even get to do some HSRP, but I am not sure if they do. To be honest I don't even know if they do etherchannel, but I guess we'll find out whether this is a limitation of the software (IOU) or not.

Trunking - VTP and 802.1Q trunks

We'll start by creating a bunch of VLANs on SW1, and set up VTP.

So in SW1 we set up a bunch of VLANs, (10,20,30, and 40 using the "vlan 10" etc command), and then set the vtp mode to server (which is the default but I still like to know that I have set it manually), and set the domain from null to 802101:


VTP Server setup cisco switch

Now we can set up a trunk to SW3, we will only use 802.1Q for our trunks because the other trunking protocol (ISL) isnt used much anymore.

We arnt going to do anything fancy with our trunk (at least not yet) so its a basic configuration:


802.1Q trunking on a Cisco Switch

And I have set SW3 as a VTP client for the 802101 domain:


Cisco switch vtp client

Usually its worth heading back to the server to make an amendment to the VLAN database on the server to force it to send the updates to the clients. So I added VLAN 50 on to SW1, and then running "sh vtp status" on SW3 I can see that the two are talking:


cisco vtp status

OK, so thats the link between SW1 and three done. Lets set up SW2 and 4 in the same way:


setting up vtp client and trunking


setting up vtp client and trunking

Now we can set up our etherchannel links between SW1 and SW2 (PAgP) and between SW3 and SW4 (LACP).

EtherChannel - Setting up PAgP and LACP

I said earlier that I wasn't going to bother with ISL for our trunks because it's no longer used much, well the same does not hold true for the etherchannel protocols. Both are used and both have a very good chance of being included in the exam. Therefore I will be doing both. PAgP (Port Aggregation Protocol) is the Cisco standard, whilst LACP is the industry standard. 

For any type of etherchannel to work the settings on the interfaces within the port-channel group must match identically, so you can't mix duplex or speed for example. I prefer to set mine up using the interface range command ("interface range ethernet 0/0 - 1"). First I shut down the interfaces (you don't have to, I just like to know I have got everything set before I try and bring the port-channel up), then set them up as trunks, adding them to the port-channel group 1. I have set SW1 as "auto" for PAgP:


pagp etherchannel cisco

and SW2 as "desirable" for PAgP:


setting up vtp client and trunking

Lastly i did a "no shut" on the interfaces. 

The basic config is:

SW(config)#interface range ethernet 0/0 - 1
SW(config-if-range)#shut
SW(config-if-range)#switchport trunk encapsulation dot1q
SW(config-if-range)#switchport mode trunk
SW(config-if-range)#channel-protocol <protocol>
SW(config-if-range)#channel-group 1 mode <mode>
SW(config-if-range)#no shut

Lets have a look at the last two lines in a bit more detail.

We start by setting the protocol, this is either PAgP or LACP:


cisco etherchannel

And then we set the mode


cisco etherchannel channel group mode

Both sides could have been made desirable for PAgP, or active for LACP, and would have formed a channel-group, but if both were set to auto (PAgP) or passive (LACP) then no channel-group would form, as neither would be actively seeking to make a channel-group.

Here is a sh run from both sides:


port channels and load balancing


port channels and load balancing

And as if by magic if we do a "sh vlan" on SW2 we can see that by the magic of VTP we have our VLANs now:


vtp in action

Now let's turn our attention to SW3 and SW4.

There isn't much different between the setups, the same commands have been used to create the trunk links:


port channels and load balancing


port channels and load balancing

And lastly on SW4 we check to see if our VLANs are all present and correct:


vtp over port channel
And they are.

From now on our port-channel operates pretty much just like any normal interface, We can do a "sh int po 1" and see the following:


show port channel

The interesting thing here is that we can see the members of the port-channel (in the last line).

We can also check on our neighbor switches:


port channels and load balancing neighbor

Load-balancing

I did set up src-dst-mac load balancing on SW1 and SW2, it is a global statement 


port-channel load-balancing
I chose src-dst-mac


port-channel-load-balancing

Load balancing is pretty simple really.

And that about covers it for today. The boys didn't sleep at all this afternoon, so now its half past eight at night and its time for a snack. 

Next up we'll cover the PPP link between R1 and R2.