This KB explains the condition when BGP comes up with loopback as source without local-address configuration
BGP establishes without local-address knob present globally, group level or neighbor level
This KB explains the condition when BGP forms peering with loopbacks IPs Scenario1 : >>> When BGP is configured with neighbor address as loopback IPs for both end and no local-address or default-address-selection is configured on either end lo0 ---R1 -----------------R2—lo0 R1 : root@DEVICE> show configuration interfaces | display setJul 13 10:18:27set interfaces ge-0/0/0 unit 0 family inet address 10.0.0.1/24set interfaces lo0 unit 0 family inet address 192.168.1.1/32 root@DEVICE> show configuration protocols | display setJul 13 10:18:34set protocols bgp group internal-peers type internalset protocols bgp group internal-peers neighbor 192.168.1.2set protocols ospf area 0.0.0.0 interface lo0.0 passiveset protocols ospf area 0.0.0.0 interface ge-0/0/0.0 root@DEVICE> show configuration routing-options | display setJul 13 10:18:44set routing-options router-id 192.168.1.1set routing-options autonomous-system 64512 root@DEVICE> show configuration system | display setJul 13 10:18:50set system ports console log-out-on-disconnectroot@DEVICE> R2 : root@DEVICE2> show configuration interfaces | display setJul 13 10:19:35set interfaces ge-0/0/0 unit 0 family inet address 10.0.0.2/24set interfaces lo0 unit 0 family inet address 192.168.1.2/32root@DEVICE2> show configuration protocols | display setJul 13 10:19:42set protocols bgp group internal-peers type internalset protocols bgp group internal-peers neighbor 192.168.1.1set protocols ospf area 0.0.0.0 interface lo0.0 passiveset protocols ospf area 0.0.0.0 interface ge-0/0/0.0 root@DEVICE2> show configuration routing-options | display setJul 13 10:19:50set routing-options router-id 192.168.1.2set routing-options autonomous-system 64512root@DEVICE2> show configuration system | display setJul 13 10:19:56set system ports console log-out-on-disconnectroot@DEVICE2>BGP State: R1 :root@DEVICE> show bgp summaryJul 13 10:20:17Threading mode: BGP I/ODefault eBGP mode: advertise - accept, receive - acceptGroups: 1 Peers: 1 Down peers: 1Table Tot Paths Act Paths Suppressed History Damp State Pendinginet.0 0 0 0 0 0 0Peer AS InPkt OutPkt OutQ Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped...192.168.1.2 64512 1 0 0 0 2:16 Active root@DEVICE> ping 192.168.1.2 source 192.168.1.1 Jul 13 10:20:42PING 192.168.1.2 (192.168.1.2): 56 data bytes64 bytes from 192.168.1.2: icmp_seq=0 ttl=64 time=1.959 ms64 bytes from 192.168.1.2: icmp_seq=1 ttl=64 time=2.174 ms64 bytes from 192.168.1.2: icmp_seq=2 ttl=64 time=2.001 ms64 bytes from 192.168.1.2: icmp_seq=3 ttl=64 time=1.834 ms^C--- 192.168.1.2 ping statistics ---4 packets transmitted, 4 packets received, 0% packet lossround-trip min/avg/max/stddev = 1.834/1.992/2.174/0.122 ms BGP will not come up. Reason: BGP by default use egress IP as source and remote peer is expecting source as loopback IP and hence both peers will stuck in idle/active state Scenario2 : >>> When BGP is configured with neighbor address as loopback IPs for both end and local-address is configured on one end:lo0 ---R1 --(local-address)---------------R2---lo0 R1 : root@DEVICE> show configuration routing-options | display set Jul 13 10:24:01set routing-options router-id 192.168.1.1set routing-options autonomous-system 64512 root@DEVICE> show configuration system | display setJul 13 10:24:07set system ports console log-out-on-disconnect root@DEVICE>Jul 13 10:24:08 root@DEVICE> show configuration protocols bgp | display setJul 13 10:24:17set protocols bgp group internal-peers type internalset protocols bgp group internal-peers local-address 192.168.1.1set protocols bgp group internal-peers neighbor 192.168.1.2 root@DEVICE> R2: root@DEVICE2> show configuration routing-options | display setJul 13 10:24:52set routing-options router-id 192.168.1.2set routing-options autonomous-system 64512 root@DEVICE2> show configuration system | display set Jul 13 10:25:04set system ports console log-out-on-disconnect root@DEVICE2> show configuration protocols bgp | display setJul 13 10:25:15set protocols bgp group internal-peers type internalset protocols bgp group internal-peers neighbor 192.168.1.1 root@DEVICE2> BGP will come up.https://supportportal.juniper.net/s/article/How-to-configure-update-source-interface-for-BGPin-junos-CLINOTE: Although a BGP session can be established when only one of the paired routing devices has local-address configured, we strongly recommend that you configure local-address on both paired routing devices for IBGP and multihop EBGP sessions. The local-address statement ensures that deterministic fixed addresses are used for the BGP session end-points. R1: root@DEVICE> show bgp summary Jul 13 10:26:43Threading mode: BGP I/ODefault eBGP mode: advertise - accept, receive - acceptGroups: 1 Peers: 1 Down peers: 0Table Tot Paths Act Paths Suppressed History Damp State Pendinginet.0 0 0 0 0 0 0Peer AS InPkt OutPkt OutQ Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped...192.168.1.2 64512 9 9 0 0 3:09 Establ inet.0: 0/0/0/0 root@DEVICE> show bgp neighbor 192.168.1.2Jul 13 10:26:54Peer: 192.168.1.2+179 AS 64512 Local: 192.168.1.1+57866 AS 64512 Group: internal-peers Routing-Instance: master Forwarding routing-instance: master Type: Internal State: Established Flags: <Sync> Last State: OpenConfirm Last Event: RecvKeepAlive Last Error: None Options: <LocalAddress Refresh> Options: <GracefulShutdownRcv> Local Address: 192.168.1.1 Holdtime: 90 Preference: 170 Graceful Shutdown Receiver local-preference: 0 Number of flaps: 0 Peer ID: 192.168.1.2 Local ID: 192.168.1.1 Active Holdtime: 90 Keepalive Interval: 30 Group index: 0 Peer index: 0 SNMP index: 0 Scenario3 : >>> [Recommended] When BGP is configured with neighbor address as loopback IPs for both end and local-address is also configured on each end lo0 ---R1 --(local-address)------------(local-address)---R2---lo0 root@DEVICE2> configureJul 13 10:27:56Entering configuration mode [edit]root@DEVICE2# run show configuration protocols bgp | display setJul 13 10:28:05set protocols bgp group internal-peers type internalset protocols bgp group internal-peers neighbor 192.168.1.1 [edit]root@DEVICE2# set protocols bgp group internal-peers local-address 192.168.1.2Jul 13 10:28:20 [edit]root@DEVICE2# show | compareJul 13 10:28:25[edit protocols bgp group internal-peers]+ local-address 192.168.1.2; [edit]root@DEVICE2# commitJul 13 10:28:27commit complete [edit]root@DEVICE2# exitJul 13 10:28:31Exiting configuration mode BGP will come up. Scenario4 : >>> When BGP is configured with neighbor address as loopback IPs for both end and default-address-selection is configured on one end lo0 ---R1 --(default-address-selection)——————---R2—lo0 R1 : {master}root@DEVICE> show version Jul 15 19:45:07Hostname: DEVICEModel: ptx10016Junos: 22.4R2.8JUNOS OS Kernel 64-bit [20230321.be5f9c0_builder_stable_12_224]JUNOS OS libs [20230321.be5f9c0_builder_stable_12_224] {master}root@DEVICE> show configuration interfaces lo0 | display set Jul 15 19:45:33set interfaces lo0 unit 0 family inet filter input FILTER-RE-FIREWALLset interfaces lo0 unit 0 family inet address 127.0.0.1/32set interfaces lo0 unit 0 family inet address 192.168.1.1/32 {master}root@DEVICE> show configuration interfaces ae2 | display set Jul 15 19:45:39set interfaces ae2 aggregated-ether-options link-speed 100gset interfaces ae2 aggregated-ether-options lacp activeset interfaces ae2 aggregated-ether-options lacp periodic slowset interfaces ae2 unit 0 family inet address 10.0.0.1/24 {master}root@DEVICE> show configuration protocols bgp | display set | match internal-peers Jul 15 19:46:28set protocols bgp group internal-peers type internalset protocols bgp group internal-peers neighbor 192.168.1.2 {master}root@DEVICE> show configuration system | display set | match default-address-selection Jul 15 19:46:52set system default-address-selection {master}root@DEVICE> show bgp summary | match est Jul 15 19:47:11192.168.1.2 64512 10 9 0 0 3:13 Establ root@DEVICE> show bgp neighbor 192.168.1.2 Jul 15 19:47:29Peer: 192.168.1.2+179 AS 64512 Local: 192.168.1.1+62064 AS 64512 Group: internal-peers Routing-Instance: master R2 : root@DEVICE2> show version Jul 15 15:18:17Hostname: DEVICE2Model: ptx10001-36mr-kJunos: 24.2R1.18-EVOYocto: 4.0.14Linux Kernel: 5.15.76-yocto-standard-juniper-02085-gce2d521ddcf4JUNOS-EVO OS 64-bit [junos-evo-install-ptx-fixed-x86-64-24.2R1.18-EVO] root@DEVICE2> show configuration interfaces lo0 | display set Jul 15 15:18:36set interfaces lo0 unit 0 family inet address 192.168.1.2/32 root@DEVICE2> show configuration interfaces ae2 | display set Jul 15 15:18:45set interfaces ae2 aggregated-ether-options link-speed 100gset interfaces ae2 aggregated-ether-options lacp activeset interfaces ae2 aggregated-ether-options lacp periodic slowset interfaces ae2 unit 0 family inet address 10.0.0.2/24 root@DEVICE2> show configuration protocols bgp | display set | match internal-peers Jul 15 15:18:59set protocols bgp group internal-peers type internalset protocols bgp group internal-peers neighbor 192.168.1.1 root@DEVICE2> show configuration system | display set | match default-address-selection Jul 15 15:19:13 root@DEVICE2> show bgp summary | match est Jul 15 15:19:20192.168.1.1 64512 15 13 0 0 5:22 Establ root@DEVICE2> show bgp neighbor 192.168.1.1 Jul 15 15:19:29 Warning: License key missing; requires 'BGP' license Peer: 192.168.1.1+62064 AS 64512 Local: 192.168.1.2+179 AS 64512 Group: internal-peers Routing-Instance: master Forwarding routing-instance: master Type: Internal State: Established Flags: <Sync> BGP will come up. https://www.juniper.net/documentation/us/en/software/junos/cli-reference/topics/ref/statement/default-address-selection-edit-system.html Scenario5 : >>> BGP does not flap when the default-address-selection knob is removed from the configuration while BGP is running. lo0 ---R1 -----------------R2---lo0 R1: {master}root@DEVICE> show bgp summary | match est Jul 15 19:53:18192.168.1.2 64512 24 22 0 0 9:20 Establ root@DEVICE> show configuration system | display set | match default-addres Jul 15 19:53:31set system default-address-selection {master}root@DEVICE> configure Jul 15 19:53:34Entering configuration mode {master}[edit]root@DEVICE# delete system default-address-selection Jul 15 19:53:39 {master}[edit]labroot@DEVICE# show | compare Jul 15 19:53:43[edit system]- default-address-selection; {master}[edit]root@DEVICE# commit and-quit Jul 15 19:53:46warning: Could not connect to re1 : Can't assign requested addresswarning: Cannot connect to other RE, ignoring itcommit completeExiting configuration mode {master}root@DEVICE> {master}root@DEVICE> show bgp summary | match est Jul 15 19:54:08192.168.1.2 64512 26 24 0 0 10:10 Establ {master}root@DEVICE> show configuration system | match default-address Jul 15 19:54:44 {master}root@DEVICE> show configuration protocols bgp | display set | match internal-peers Jul 15 19:54:55set protocols bgp group internal-peers type internalset protocols bgp group internal-peers neighbor 192.168.1.2 {master}root@DEVICE> show bgp summary | match est Jul 15 19:57:37192.168.1.2 64512 33 31 0 0 13:39 Establ {master}root@DEVICE> R2 : root@DEVICE2> show configuration system | display set | match default-address Jul 15 15:26:21 root@DEVICE2> Jul 15 15:26:25 root@DEVICE2> show configuration protocols bgp | display set Jul 15 15:26:33set protocols bgp group internal-peers type internalset protocols bgp group internal-peers neighbor 192.168.1.1 root@DEVICE2> show bgp summary | match est Jul 15 15:26:39192.168.1.1 64512 31 29 0 0 12:41 Establ BGP stays up. [unless it is flapped for some other reason] Once BGP goes down , it will not come up unless either local-address or default-address-selection is added on one end