[MX] Which interface counts packet to/from loopback interface?

  [KB34710] Show Article Properties


Summary:

This article describes which interface will count packet to/from loopback interface of a Junos router.

Symptoms:

When a Junos router receives a packet destined to loopback IP address, the packet is counted on the interface toward the next-hop of the source IP address of the packet.

Example topology:

+---------+ ge-           ge-  +---------+  
|    R1   | 0/0/7         0/0/8|    R2   |  
| 1.1.1.1 +--------------------+ 2.2.2.2 |  
|         | .1   192.0.2/24  .2|         |
+---------+                    +---------+
Solution:

In the diagram above, router R2 sends ping packets to loopback IP address of R1.

lab@R2> ping 1.1.1.1 rapid count 10

With this command, the ping is sent with source IP address 192.0.2.2, which is interface IP of ge-0/0/8.0 on R2.

On router R1, the next-hop of 192.0.2.2 is identical to itself since R1 has interface ge-0/0/7.0 which takes part in the subnet 192.0.2.0/24. Hence, the kernel binds to ge-0/0/7.0 receiving and sending interface of ping packet.

lab@R1> show route
inet.0: 11 destinations, 11 routes (11 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
<..snip..>
1.1.1.1/32         *[Direct/0] 10:21:12
                    > via lo0.0
192.0.2.0/24       *[Direct/0] 08:13:13
                    > via ge-0/0/7.0

Lets send ping from R2 to R1 and see if ping packet is really counted on the interface ge-0/0/7.0.

lab@R1> show interfaces ge-0/0/7 extensive | no-more    
Physical interface: ge-0/0/7, Enabled, Physical link is Up
  Interface index: 147, SNMP ifIndex: 525, Generation: 150
  Link-level type: Ethernet, MTU: 1514, MRU: 1522, LAN-PHY mode, Speed: 1000mbps, BPDU Error: None, Loop Detect PDU Error: None, Ethernet-Switching Error: None, MAC-REWRITE Error: None,
  Loopback: Disabled, Source filtering: Disabled, Flow control: Enabled, Auto-negotiation: Enabled, Remote fault: Online
  Pad to minimum frame size: Disabled
  Device flags   : Present Running
  Interface flags: SNMP-Traps Internal: 0x4000
  Link flags     : None
  CoS queues     : 8 supported, 8 maximum usable queues
  Hold-times     : Up 0 ms, Down 0 ms
  Damping        : half-life: 0 sec, max-suppress: 0 sec, reuse: 0, suppress: 0, state: unsuppressed
  Current address: 56:68:a3:1e:5d:cd, Hardware address: 56:68:a3:1e:5d:cd
  Last flapped   : 2019-06-06 10:47:34 PDT (1w5d 09:14 ago)
  Statistics last cleared: 2019-06-18 20:01:54 PDT (00:00:06 ago)
  Traffic statistics:
   Input  bytes  :                    0                    0 bps
   Output bytes  :                    0                    0 bps
   Input  packets:                    0                    0 pps
   Output packets:                    0                    0 pps
<..snip..>
  Logical interface ge-0/0/7.0 (Index 334) (SNMP ifIndex 546) (Generation 149)
    Flags: Up SNMP-Traps 0x4004000 Encapsulation: ENET2
    Traffic statistics:
     Input  bytes  :                    0
     Output bytes  :                    0
     Input  packets:                    0
     Output packets:                    0
    Local statistics:
     Input  bytes  :                    0
     Output bytes  :                    0
     Input  packets:                    0
     Output packets:                    0
    Transit statistics:
     Input  bytes  :                    0                    0 bps
     Output bytes  :                    0                    0 bps
     Input  packets:                    0                    0 pps
     Output packets:                    0                    0 pps
lab@R2> ping 1.1.1.1 rapid count 10  
PING 1.1.1.1 (1.1.1.1): 100 data bytes
!!!!!!!!!!
--- 1.1.1.1 ping statistics ---
10 packets transmitted, 10 packets received, 0% packet loss
round-trip min/avg/max/stddev = 1.587/1.977/3.868/0.637 ms

lab@R1> show interfaces ge-0/0/7 extensive | no-more    
Jun 18 21:45:08
Physical interface: ge-0/0/7, Enabled, Physical link is Up
  Interface index: 147, SNMP ifIndex: 525, Generation: 150
  Link-level type: Ethernet, MTU: 1514, MRU: 1522, LAN-PHY mode, Speed: 1000mbps, BPDU Error: None, Loop Detect PDU Error: None, Ethernet-Switching Error: None, MAC-REWRITE Error: None,
  Loopback: Disabled, Source filtering: Disabled, Flow control: Enabled, Auto-negotiation: Enabled, Remote fault: Online
  Pad to minimum frame size: Disabled
  Device flags   : Present Running
  Interface flags: SNMP-Traps Internal: 0x4000
  Link flags     : None
  CoS queues     : 8 supported, 8 maximum usable queues
  Hold-times     : Up 0 ms, Down 0 ms
  Damping        : half-life: 0 sec, max-suppress: 0 sec, reuse: 0, suppress: 0, state: unsuppressed
  Current address: 56:68:a3:1e:5d:cd, Hardware address: 56:68:a3:1e:5d:cd
  Last flapped   : 2019-06-06 10:47:34 PDT (1w5d 10:57 ago)
  Statistics last cleared: 2019-06-18 21:44:57 PDT (00:00:11 ago)
  Traffic statistics:
   Input  bytes  :                  840                    0 bps
   Output bytes  :                  840                    0 bps
   Input  packets:                   10                    0 pps
   Output packets:                   10                    0 pps
<..snip..>
  Logical interface ge-0/0/7.0 (Index 334) (SNMP ifIndex 546) (Generation 149)
    Flags: Up SNMP-Traps 0x4004000 Encapsulation: ENET2
    Traffic statistics:
     Input  bytes  :                  840
     Output bytes  :                  840
     Input  packets:                   10
     Output packets:                   10
    Local statistics:
     Input  bytes  :                    0
     Output bytes  :                    0
     Input  packets:                    0
     Output packets:                    0
    Transit statistics:
     Input  bytes  :                  840                    0 bps
     Output bytes  :                  840                    0 bps
     Input  packets:                   10                    0 pps
     Output packets:                   10                    0 pps

The interface which counts packet to/from loopback IP address is determined and bound in the same way, even receiving and sending interface is logical, like service interface si.

lab@mx> show route
inet.0: 18 destinations, 18 routes (18 active, 0 holddown, 0 hidden)
+ = Active Route, - = Last Active, * = Both
<..snip..>
203.0.113.0/16      *[Static/5] 06:06:30
                    > via si-4/0/0.2
                      via si-4/1/0.2
                      via si-4/2/0.2
                      via si-4/3/0.2

  Logical interface si-4/0/0.2 (Index 344) (SNMP ifIndex 1195) (Generation 153)
    Flags: Up Point-To-Point SNMP-Traps Encapsulation: Adaptive-Services
    Traffic statistics:
     Input  bytes  :                    0
     Output bytes  :                  640
     Input  packets:                    0
     Output packets:                   10
     IPv6 transit statistics:
     Input  bytes  :                    0
     Output bytes  :                    0
     Input  packets:                    0
     Output packets:                    0
    Local statistics:
     Input  bytes  :                    0
     Output bytes  :                  640
     Input  packets:                    0
     Output packets:                   10
Related Links: