10-13-2012 03:16 PM - edited 03-04-2019 05:50 PM
Hello!
I have a question about Local Preference.
As you can see at the picture below i have 2 routers connected via two fastethernet links. Both routers running BGP. R1 (AS 65100) and R2 (AS65000).
R1 got a loopback interface with the IP address 1.1.1.1 255.255.255.255
R2 got two loopback interfaces 2.2.2.2 255.255.255.255 and 3.3.3.3 255.255.255.255.
Let's say that i want the host 3.3.3.3 to go over fa0/1 to reach 1.1.1.1 and rest of the network to go through fa0/0. What can I do to make this possible?
I know how to set Local Preference on an interface... but then all networks will take that specific path.
route-map LP_FA0/1 permit 10
set local-preference 200
neighbor 192.168.2.1 route-map LP_FA0/1 in
Solved! Go to Solution.
10-14-2012 12:55 PM
Hi,
1) you can't use a prefix-list for PBR, you need to use an ACL
2) if traffic is originated from a loopback then it is considered local traffic and so you need to use local PBR:
ip local policy route-map command
3) you said you wanted traffic from 3.3.3.3 to take f0/0 so you must set next-hop to 192.168.1.1 per you initial topology.
Side question:
when influencing outbound traffic path then apply route-map inbound to receive the attribute
when influencing inbound traffic path then apply route-map outbound to send your attribute to neighbour so it influences how it routes towards your prefixes
Regards.
Alain
Don't forget to rate helpful posts.
10-13-2012 03:38 PM
Hello Henrik,
You simply modify the route-map so that it applies only to selected prefixes. For example:
ip prefix-list LocalPref permit 3.3.3.3/32
!
route-map LP_FA0/1 permit 10
match ip address prefix-list LocalPref
set local-preference 200
!
route-map LP_FA0/1 permit 20
And afterwards, you use this route-map just like you do now. The prefix-list is similar to ACLs and performs matching on prefixes and masks. The seemingly empty block 20 of your route-map is necessary to allow all other prefixes without modification (if it was not present in the route-map, all other prefixes would be dropped completely).
Best regards,
Peter
10-13-2012 04:01 PM
Hello Peter!
Thanks for the fast reply!
I tried the prefix-list like you said, but it still doesn't work. If i try to ping 1.1.1.1 from 3.3.3.3 it takes Fa0/0 instead of Fa0/1.
And as you can see below the Local Preference is empty now.
R2#show ip bgp
Network Next Hop Metric LocPrf Weight Path
* 1.1.1.1/32 192.168.2.1 0 0 65100 i
*> 192.168.1.1 0 0 65100 i
*> 2.2.2.2/32 0.0.0.0 0 32768 i
*> 3.3.3.3/32 0.0.0.0 0 32768 i
This is from my config
neighbor 192.168.2.1 route-map LP_FA0/1 in
!
ip prefix-list LocalPref seq 5 permit 3.3.3.3/32
!
route-map LP_FA0/1 permit 10
match ip address prefix-list LocalPref
set local-preference 200
!
route-map LP_FA0/1 permit 20
Thanks,
Henrik
10-13-2012 05:42 PM
Hi Henri
Your destination IP is 1.1.11/32. So you should have applied the local-preference for 1.1.1.1
Modify config as below. This should workneighbor 192.168.2.1 route-map LP_FA0/1 in
!
ip prefix-list LocalPref seq 5 permit 1.1.1.1/32!
route-map LP_FA0/1 permit 10
match ip address prefix-list LocalPref
set local-preference 200
!
route-map LP_FA0/1 permit 20
10-14-2012 03:12 AM
Hello Rajs
Thanks for the reply!
Please, correct me if i'm wrong
But then all traffic to 1.1.1.1 will be filtred through Fa0/1. I just want all traffic that comes from 3.3.3.3 should go through Fa0/1. Shouldn't matter which destination the packet has. Only want the routers to look at the source address, in this case 3.3.3.3.
Just want a rule to say. "All traffic from 3.3.3.3 should go through Fa0/1, rest go through fa0/0.".
I have a MED route-map aswell that says that all traffic that comes from R1 should go via Fa0/0 to get into my AS. But that's what i want anyway. But that one was a bit simpler because then i didnt have to match any ACL or Prefix lists.
I just created the route-map, wrote a set statement for metric and then applied it on fa0/1 to get a higher metric.
10-14-2012 03:35 AM
Hi Henrik,
I don't think you can implement your requirement by modifying BGP attributes
If you want to route based on the source and destination, you can go for policy-based routing using local-policy
I can help with configs if you are looking for that option
/Raju
10-14-2012 03:36 AM
Normal routing is always based on destination.
So if you want to take routing decision using source IP, go for PBR
/Raju
10-14-2012 03:41 AM
Ok I may have an idea then. Thanks I'll get back to you with my results!
10-13-2012 03:43 PM
Hello Henrik
I think what you are speaking about can be done by using Route Maps
for example please the the below :
Configuring the Route-Map for routing traffic by source
Step1: Define the traffic with an access-List
RouterA(config)#access-list 10 3.3.3.3 255.255.255.255.
Step 2: Create a Route-Map with an action
RouterA(config)# route-map Traffic_to_fastetherent0/1
RouterA(config-route-map)#match ip 10
RouterA(config-route-map)#set next hop 192.168.2.1
Step 3: Apply the Route-Map to the router interface that the traffic enters into
RouterA(config)#interface fastetherent 0/1
RouterA(config-int)#ip policy Traffic_to_fastetherent0/1
Traffic from the 3.3.3.3 host will be forced to the router 192.168.2.1 network .
For more information about Route Maps please refer tot he following link :
http://www.ciscopress.com/articles/article.asp?p=1569333&seqNum=4
http://www.cisco.com/en/US/docs/ios/12_3t/12_3t2/feature/guide/gt_brmcs.html
Hope it will Help
Ahmed Sonba
10-13-2012 04:18 PM
Thanks for the reply Ahmed!
I'm gonna try it out tomorrow when i'm at school again.
Thanks,
Henrik
10-14-2012 03:39 AM
Hey Ahmed,
I tried your solution. But it didn't work either.
And to be honoest I don't really understand why.
Because what you wrote, if the traffic match the source address for 3.3.3.3 it should change the next-hop to 192.168.2.1. But it don't...
I tried an prefix list instead of an ACL aswell... but same resualt..
I'm gonna try something else before I talk with my teacher. It's weekend now so he won't look in his mail today I think, so have to check with him tomorrow.
But i apperciate that you all took your time to help me.
Thanks!
Henrik Josefsson
10-14-2012 03:59 AM
If the trafifc is originated from the router you have configured policy-routing, you need to configure
ip local policy route-map < route-map name>
/Raju
10-14-2012 12:24 PM
Hello Rajs,
I tried what you suggest with the policy-routing, but nothing changed. The traffic still went through fa0/0.
I'm just gonna put my conf for R2 here and maybe you can tell me what i have done wrong.
interface Loopback0
ip address 2.2.2.2 255.255.255.255
!
interface Loopback1
ip address 3.3.3.3 255.255.255.255
!
interface FastEthernet0/0
ip address 192.168.1.2 255.255.255.252
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 192.168.2.2 255.255.255.252
ip policy route-map TRAFFIC_TO_FA0/1
duplex auto
speed auto
!
!
!
router bgp 65000
no synchronization
bgp log-neighbor-changes
network 2.2.2.2 mask 255.255.255.255
network 3.3.3.3 mask 255.255.255.255
neighbor 192.168.1.1 remote-as 65100
neighbor 192.168.2.1 remote-as 65100
neighbor 192.168.2.1 route-map MED_FA0/1 out
no auto-summary
!
ip prefix-list TRAFFIC_FROM_3 seq 5 permit 3.3.3.3/32
!
route-map MED_FA0/1 permit 20
set metric 20
!
route-map TRAFFIC_TO_FA0/1 permit 10
match ip address prefix-list TRAFFIC_FROM_3
set ip next-hop 192.168.2.1
Question number 2 (more like a sidequestion)
I think i have confused myself when we're talking about setting "inbound" or "outbound" for route-maps.
neighbor 192.168.2.1 route-map MED_FA0/1 out <--- here i've got a "outbound" for an example... but does anyone have any good tips how i should think when i'm applying route-maps, ACL etc.
What I have been told... I should think that I'm the router. And in this case... i'm sending OUT MED packets so my neighbor knows how to send back packets. But then I got confused with the Local Preference where I use the "IN" statement instead. But if I'm right, inbound means that all packets comming IN to the router will be filtered. But in this case, Local preference statement is generated on this router.
Thanks
Henke
10-14-2012 12:55 PM
Hi,
1) you can't use a prefix-list for PBR, you need to use an ACL
2) if traffic is originated from a loopback then it is considered local traffic and so you need to use local PBR:
ip local policy route-map command
3) you said you wanted traffic from 3.3.3.3 to take f0/0 so you must set next-hop to 192.168.1.1 per you initial topology.
Side question:
when influencing outbound traffic path then apply route-map inbound to receive the attribute
when influencing inbound traffic path then apply route-map outbound to send your attribute to neighbour so it influences how it routes towards your prefixes
Regards.
Alain
Don't forget to rate helpful posts.
10-14-2012 01:14 PM
Hey Cadet!
Thanks a lot. I tried it and it worked.
And thanks for the information about PBR and the side question.
Best regards
Henke
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide