The local pref works on outgoing direction. You will set local pref to prefix propagated to that neighbor, not to prefix received from that neighbor.
If you want to set local pref to incoming prefix, have to use a import policy.
Look, some output ommited.
I set local pref to 199 on neighbor 10.2.2.2, group RI2.
set routing-instances RI3 protocols bgp group RI2 type internal
set routing-instances RI3 protocols bgp group RI2 local-preference 199
set routing-instances RI3 protocols bgp group RI2 local-address 10.3.3.3
set routing-instances RI3 protocols bgp group RI2 neighbor 10.2.2.2
set routing-instances RI3 protocols bgp group RI4 type internal
set routing-instances RI3 protocols bgp group RI4 local-address 10.3.3.3
set routing-instances RI3 protocols bgp group RI4 neighbor 10.4.4.4
I learn this from this neighbor, but dont see the local pref.
admin@MX> show route receive-protocol bgp 10.2.2.2
RI3.inet.0: 46 destinations, 57 routes (46 active, 0 holddown, 1 hidden)
Prefix Nexthop MED Lclpref AS path
* 10.2.1.0/24 10.2.2.2 100 I
* 10.2.3.0/24 10.2.2.2 100 I
* 10.2.4.0/24 10.2.2.2 100 I
* 12.12.12.0/24 10.2.2.2 100 I
23.23.23.0/24 10.2.2.2 100 I
But i propagate this to this neighbor with local pref 199.
admin@MX> show route advertising-protocol bgp 10.3.3.3
RI3.inet.0: 46 destinations, 57 routes (46 active, 0 holddown, 1 hidden)
Prefix Nexthop MED Lclpref AS path
* 10.3.1.0/24 Self 199 I
* 10.3.2.0/24 Self 199 I
* 10.3.3.0/24 Self 199 I
* 10.3.4.0/24 Self 199 I
* 10.4.1.0/24 10.4.4.4 199 I
* 10.4.2.0/24 10.4.4.4 199 I
* 10.4.3.0/24 10.4.4.4 199 I
* 10.4.4.0/24 10.4.4.4 199 I
* 23.23.23.0/24 Self 199 I
* 34.34.34.0/24 Self 199 I
And what this neighbor receives have local pref 199.
admin@MX> show route receive-protocol bgp 10.3.3.3
RI2.inet.0: 49 destinations, 66 routes (49 active, 0 holddown, 0 hidden)
Prefix Nexthop MED Lclpref AS path
* 10.3.1.0/24 10.3.3.3 199 I
* 10.3.2.0/24 10.3.3.3 199 I
* 10.3.3.0/24 10.3.3.3 199 I
* 10.3.4.0/24 10.3.3.3 199 I
* 10.4.1.0/24 10.4.4.4 199 I
* 10.4.2.0/24 10.4.4.4 199 I
* 10.4.3.0/24 10.4.4.4 199 I
* 10.4.4.0/24 10.4.4.4 199 I
23.23.23.0/24 10.3.3.3 199 I
* 34.34.34.0/24 10.3.3.3 199 I
But on the second group RI4 i dont see any local pref.
RI4.inet.0: 52 destinations, 62 routes (52 active, 0 holddown, 0 hidden)
Prefix Nexthop MED Lclpref AS path
* 10.2.1.0/24 10.2.2.2 100 I
* 10.2.3.0/24 10.2.2.2 100 I
* 10.2.4.0/24 10.2.2.2 100 I
* 10.3.1.0/24 10.3.3.3 100 I
* 10.3.2.0/24 10.3.3.3 100 I
* 10.3.3.0/24 10.3.3.3 100 I
* 10.3.4.0/24 10.3.3.3 100 I
* 12.12.12.0/24 10.2.2.2 100 I
* 23.23.23.0/24 10.3.3.3 100 I
34.34.34.0/24 10.3.3.3 100 I
This is the import policy that will set local pref, and metric to incoming prefixes, from R3 to R4, and from R4 to R3. R3 have ip address 34.34.34.3, and R4 34.34.34.4.
set policy-options policy-statement Set-Pref from protocol bgp
set policy-options policy-statement Set-Pref then metric 777
set policy-options policy-statement Set-Pref then local-preference 177
set policy-options policy-statement Set-Pref then accept
set routing-instances RI3 protocols bgp group RI4 import Set-Pref
set routing-instances RI4 protocols bgp group RI3 import Set-Pref
RI3.inet.0: 46 destinations, 57 routes (46 active, 0 holddown, 1 hidden)
+ = Active Route, - = Last Active, * = Both
A Destination P Prf Metric 1 Metric 2 Next hop AS path
10.4.1.0/24 B 200 177 777 >34.34.34.4 I
10.4.2.0/24 B 200 177 777 >34.34.34.4 I
10.4.3.0/24 B 200 177 777 >34.34.34.4 I
10.4.4.0/24 B 200 177 777 >34.34.34.4 I
34.34.34.0/24 B 200 177 777 >34.34.34.4 I
RI4.inet.0: 52 destinations, 62 routes (52 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
A Destination P Prf Metric 1 Metric 2 Next hop AS path
10.2.1.0/24 B 200 177 777 >34.34.34.3 I
10.2.3.0/24 B 200 177 777 >34.34.34.3 I
10.2.4.0/24 B 200 177 777 >34.34.34.3 I
10.3.1.0/24 B 200 177 777 >34.34.34.3 I
10.3.2.0/24 B 200 177 777 >34.34.34.3 I
10.3.3.0/24 B 200 177 777 >34.34.34.3 I
10.3.4.0/24 B 200 177 777 >34.34.34.3 I
12.12.12.0/24 B 200 177 777 >34.34.34.3 I
23.23.23.0/24 B 200 177 777 >34.34.34.3 I
34.34.34.0/24 B 200 177 777 >34.34.34.3 I