You would use local pref and weight to select an outbound path.
You would use AS-Path prepending and MED to influence the inbound traffic.
When you receive a prefix, you can apply a local pref value to it. This is transitive, so other routers will learn what you set. This is used to select the egress point from your network.
Weight is local to a router, so you could use that if a single router has multiple egress links, and you want to prefer one of them.
AS-Path prepending changes the length of the AS-Path on prefixes that you advertise. So, when someone receives your prefixes, they will choose the one with the shorter prefix.
MED is non-transitive, which is why AS-Path is usually preferred.
Can anybody please explain the difference in applying attributes on inbound and outboud prefixes,
AS path prepend
for example check following image:
if you want to go from SWITCH-A to SWITCH-B using the R8, you can use the Local preference or weight (inbound if you set for specific prefix) or set as default local preference which will apply to all inbound, on R8 to be higher so SWITCH-A will prefer it over the path coming from R7, even though you did this, it wouldn't guarantee the return traffic would be coming back from to R8, so in this case what to do? well, you can configure R7 to send fake AS path outbound direction to fool AS45 that the AS path via R4 to R7 is longer and this is done by using route-map as below
set as-path prepend 78 78 78
router bgp 78
neighbor 184.108.40.206 route-map AS-PATH-PREPEND out \\assuming 220.127.116.11 is R4
by this configuration, R4 will start getting prefixes from R7 but with (AS-path 78 78 78) while R8 will get only one AS (78) from prefixes received from R5
by this you have configured how to go out and in from your AS-path
how to set weight:
router bgp 78
nei 18.104.22.168 weight 40000 (default value is 0)
how to set local preference:
bgp default local-preference 1000 (the default is 100)
or use route-map
set local pref 1000
router bgp 78
neighbor 22.214.171.124 route-map LOCAL-PREF in
now regarding the preference of these attributes the following is good table:
Priority Attribute 1 Weight 2 Local Preference 3 Originate 4 AS path length 5 Origin code 6 MED 7 eBGP path over iBGP path 8 Shortest IGP path to BGP next hop 9 Oldest path 10 Router ID 11 Neighbor IP address
source of this table is :networklessons.com
note the path attributes above might be different on other vendors, for example weight is Cisco's proprietary attribute.
I hope you find this helpful.
You are welcome,
Inbound routes are routes which we receive from external routers
outbound are locally generated routes from our lan
Let's say we have R1===iBGP===R2====EBGP===R3===iBGP===R4
basically if we say
#set local-preference 1999
#neighbor 126.96.36.199 route-map LP in configured on R3 BGP and 188.8.131.52 is R2 interface facing R3
this means applying route-map LP inbound direction which means LP will not be sent to 184.108.40.206 but R4 will get the local preference
you can also do the same on R3 outbound if you done #neighbor 220.127.116.11 route-map LP out (18.104.22.168 is R4 interface)
so as you can see, we are talking about the direction of the policy when its applied, and not where the traffic is originated.