root@A# set interfaces em0.0 family inet address 10.0.0.1/30
root@A# set interfaces lo0.0 family inet address 1.1.1.1/32
root@A# set routing-options autonomous-system 1111
root@A# set protocols bgp group exter type external
root@A# set protocols bgp group exter local-address 10.0.0.1
root@A# set protocols bgp group exter neighbor 10.0.0.2 peer-as 2222
root@B# set interfaces em0.0 family inet address 10.0.0.2/30
root@B# set routing-options autonomous-system 2222
root@B# set protocols bgp group exter type external local-address 10.0.0.2
root@B# set protocols bgp group exter neighbor 10.0.0.1 peer-as 1111
but,the route B is not learning the loopback 1.1.1.1/32 which was configured on A.
root@B> show route table inet.0
inet.0: 2 destinations, 2 routes (2 active, 0 holddown, 0 hidden)
+ = Active Route, – = Last Active, * = Both
10.0.0.0/30 *[Direct/0] 00:01:18
> via em0.0
10.0.0.2/32 *[Local/0] 00:01:18
Local via em0.0
to accomplish this,lets write export policy on A
root@A# set policy-options policy-statement exp2bgp from protocol direct
root@A# set policy-options policy-statement exp2bgp then accept
root@A# set protocols bgp group exter export exp2bgp
let’s check again on B
root@B> show route table inet.0
inet.0: 3 destinations, 4 routes (3 active, 0 holddown, 0 hidden)
+ = Active Route, – = Last Active, * = Both
1.1.1.1/32 *[BGP/170] 00:00:04, localpref 100
AS path: 1111 I
> to 10.0.0.1 via em0.0
10.0.0.0/30 *[Direct/0] 00:03:30
> via em0.0
[BGP/170] 00:00:04, localpref 100
AS path: 1111 I
> to 10.0.0.1 via em0.0
10.0.0.2/32 *[Local/0] 00:03:30
Local via em0.0
Similarily,we can do for static routes also.
Very helpful. Thank You.