guys we have one switch and two routers (WAN) going to same service provider.......now i have config HSRP on the ethernet and i want that router A shd be primary and if it fails router B shd take over....now its has been done by HSRP config......now how i will influence traffic to come through router A rather then router B....thanks
Your traffic will go to your active HSRP router every time.
You have to make sure that router A and router B both have EBGP sessions with your provider and that they have an IBGP session as well.
If router A EBGP fails, even if traffic comes first to router A (as you have the active HSRP on router A), router A will learn via IBGP that router B has access to the external world and will route the packet to router B
so to summarize:
- make sure you have EBGP and IBGP sessions on both router A and router B
Also as a nice addition, though not necessary for your redundancy to work, HSRP tracking can help you out to switch the active gateway in case the outside interface fails. you may want to have a look at that
if you want a more complex setup you can have a look at PBR Support for Multiple Tracking Options
Basically with this you can modify you active HSRP gateway by checking whether an IP in the internet is reachable from your router. If yes, HSRP active, if not, HSRP goes in standby. I'd stick with the first setup if you don't want to complicate things.
In terms of BGP setup if that was your question, if you have both uplinks to the same provider as you mentioned you can use MED (multiple exit discriminator) to influence the incoming primary path and local preference to influence the outgoing path.
MED = metric (lower is better) Set it lower on router A as opposed to router B (by default med is 0, so you can go to router B and set med to 10 for example which makes it worse than A. )
LOCAL PREFERENCE (higher is better)= Set it higher on router A as opposed to Router B. (by default LP is 100, go to Router A and set it to 110)
use MED setting metric on both router A and routerB with routerA metric value lower.
route-map RAtoisp permit 10
set metric 50
router bgp xx
neigh isp-addr route-map RAtoisp out
route-map RBtoisp permit 10
set metric 100
router bgp xx
neigh isp-addr route-map RBtoisp out
notice about MED: it can even be missing as usually when missing is preferred to any value.
you may want to add also AS path prepending on RB as an attempt to influence return path
Hope to help
Giuseppe. MED influences the return path. As long as ISP allows you to set up med without resetting that value you got yourself a setup for return path. No need for AS Path prepending if you already did MED
Just a note for MED: it is usually used when you have exit points to the same ISP, not usually used when you ebgp with multiple ISPs. In the given case MED will work just fine (once again for return path).
Use local pref for influencing the outbound path
you're absolutely right.
I was in a hurry to go out to come to office and during travel I realized I had given misleading information.
Sorry for that.
Thanks guys for your help Giuseppe and Claudiu.....i guess we guys like me are very lucky that we have guru's like you. Thanks again now guys one more thing i am bit confuse abt the BGP static route i will try to explain it some time we put a static route to null 0....in bgp why is that i mean what is the reason can you please explain in plain language with scenario....thanks again
You need to understand the difference between BGP and other IGP routing protocols like OSPF, EIGRP, RIP etc
You know how in an IGP for example if you want to advertise a network you need to have that network attached to an interface and you can pretty much go into router rip and do network x.y.z.w and that's it.
BGP is different. BGP will not advertise a route if it can't find an exact match into the routing table (bear that in mind as it is very important. BGP cares about the routing table and it does not necessarily need an active interface holding that subnet, like IGP does). So say you want to advertise 10.1.2.0 255.255.255.224 (10.1.2.0/27).
So knowing that a prerequisite for advertising 10.1.2.0 outside is to have that exact entry in the routing table you are basically stuck with 2 options: either you already have it in the routing table , which means you can easily go into router bgp
or second option , if you don't have that into the routing table, you have to put it into the routing table in order to be able to advertise it:
so you do ip route 10.1.2.0 255.255.255.224 Null0 (Null0 is a virtual IOS interface pointing to nothing, to yourself)
now that you are meeting your requirement , you can go into router bgp and advertise that network
with : network 10.1.2.0 mask 255.255.255.224
What you need to understand is that at the end of the day your IGP has to provide a way to reach that route which you artificially put up in your routing table as pointing to Null0.
So whether it's a default route , a summarized block to that network pointing to another hop or whatever else, your router needs to know about a path to that network. Otherwise your traffic will come from outside world and it's just going to get blackholed into Null0 not knowing what path it should take next
hi captari , y r u recomanding to use MED, which as lowest priority.
inbound traffic can well be influenced with ASPATH prepending.
Correct me if i am wrong . :)
For one simple and obvious reason!
If you have exit points to the same ISP (technically to the same AS) it is very clear that all the routes that you receive from the outside world and push out will have the same AS length, no matter which link from the ISP they come in or exit out, isn't it?
So. Considering the BGP path selection algorithm
2. local pref
3. origin code
4. prefer shortest AS-PATH
5. prefer lowest origin code
6. prefer lowest MED
now think about point 4. Whatever will get in and get out will have the same length. So what comes into play next : origin code , which doesn't matter as long as you don't tinker that. so you get down to MED! which comes into play by default and is the ONE who will influence your routing paths in this case (remember! won't work when peering with different ISPs in different AS as this indeed may render different lenghts in AS paths for the same prefix)
Of course, this can be done with AS path prepending as well and it will work just as beautiful, but if you understand the metrics of BGP there is no obvious reason to do AS PATH prepending when peering to the same AS number multiple times.
Definitely MED will help you out in this case.
Otherwise i think it's a question of personal preference.
I like to keep things consistent to Cisco documentation which does recommend using MED when you have uplinks to one single provider