Description

Behavior of ping with source and interface options in Junos-Evo. 

Symptoms

Ping might succeed if a non-relevant interface is mentioned along with the source option in the ping command

Solution

This is expected behavior, when source and interface are mentioned simultaneously in the ping command.

 

  The "interface" argument does not restrict the ping to strictly be sent out of the specified interface, instead it is used for ping to help select a source address from the specified interface.
  when only the "interface" argument is provided, the route lookup will happen and only check for source addresses on the specified interface, 
  then since the other end is unreachable out the specified interface, 
  no source address that could be selected will be pingable, and the lookup will fail as expected.

  When the "source" argument is also provided, the route lookup has an explicitly set source address to use, 
  so it doesn't need to do any lookups using the interface argument.  
   
  So in the case where the ping goes through, it is expected to work as the source address has been explicitly set as one that is reachable, 
  and the interface is not considered.

  Essentially, both "interface" and "source" are arguments that can be used to select a source address for the ping, 
  but "source" is more explicit and thus takes precedence over "interface" when both are set.

Please refer the following examples:

user@router> show configuration interfaces ae201 

aggregated-ether-options {

  link-speed mixed;

  lacp {

    active;

  }

}

unit 0 {

  family inet {

    address 129.134.40.170/31;

  }

  family iso;

  family inet6 {

    address 2620:0:1cff:dead:beef::94d1/127;

  }

}


user@router> show configuration interfaces ae205   

aggregated-ether-options {

  link-speed mixed;

  lacp {

    active;

  }

}

unit 0 {

  family inet {

    address 129.134.40.180/31;

  }

  family iso;

  family inet6 {

    address 2620:0:1cff:dead:beef::9001/127;

  }

}



<-- Without source option, if only interface option with incorrect interface is mentioned, ping will fail.  


user@router> ping 129.134.40.171 bypass-routing interface ae205             

/bin/ping: Warning: source address might be selected on device other than: ae205.0

PING 129.134.40.171 (129.134.40.171) from 129.134.83.197 ae205.0: 56(84) bytes of data.

/bin/ping: sendmsg: No route to host

/bin/ping: sendmsg: No route to host

^C

--- 129.134.40.171 ping statistics ---

2 packets transmitted, 0 received, 100% packet loss, time 1005ms


<-- With the above command with source option, ping is succeeding, though the interface is incorrect, because source is present it takes precedence compared to interface.


user@router> ping 129.134.40.171 source 129.134.40.170 bypass-routing interface ae205

PING 129.134.40.171 (129.134.40.171) from 129.134.40.170 ae205.0: 56(84) bytes of data.

64 bytes from 129.134.40.171: icmp_seq=1 ttl=64 time=1.09 ms

64 bytes from 129.134.40.171: icmp_seq=2 ttl=64 time=0.984 ms

64 bytes from 129.134.40.171: icmp_seq=3 ttl=64 time=0.899 ms

64 bytes from 129.134.40.171: icmp_seq=4 ttl=64 time=0.831 ms

^C

--- 129.134.40.171 ping statistics ---

4 packets transmitted, 4 received, 0% packet loss, time 3011ms

rtt min/avg/max/mdev = 0.831/0.951/1.091/0.097 ms


user@router> #


<-- Please note that source and destination addresses doesn't belong to the interface ae205 above

<-- ae201 is the correct interface, ae205 is incorrect interface for the destination IP address. 


user@router> ping 129.134.40.171 source 129.134.40.170 bypass-routing interface ae201  

PING 129.134.40.171 (129.134.40.171) from 129.134.40.170 ae201.0: 56(84) bytes of data.

64 bytes from 129.134.40.171: icmp_seq=1 ttl=64 time=0.959 ms

64 bytes from 129.134.40.171: icmp_seq=2 ttl=64 time=0.964 ms

^C

--- 129.134.40.171 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1000ms

rtt min/avg/max/mdev = 0.959/0.961/0.964/0.002 ms


user@router> ping 129.134.40.171 bypass-routing interface ae201              

/bin/ping: Warning: source address might be selected on device other than: ae201.0

PING 129.134.40.171 (129.134.40.171) from 129.134.83.197 ae201.0: 56(84) bytes of data.

64 bytes from 129.134.40.171: icmp_seq=1 ttl=64 time=1.08 ms

64 bytes from 129.134.40.171: icmp_seq=2 ttl=64 time=0.974 ms

^C

--- 129.134.40.171 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1001ms

rtt min/avg/max/mdev = 0.974/1.028/1.083/0.054 ms


user@router> 


user@router> ping 129.134.40.171 bypass-routing interface ae205   

/bin/ping: Warning: source address might be selected on device other than: ae205.0

PING 129.134.40.171 (129.134.40.171) from 129.134.83.197 ae205.0: 56(84) bytes of data.

/bin/ping: sendmsg: No route to host

^C

--- 129.134.40.171 ping statistics ---

1 packets transmitted, 0 received, 100% packet loss, time 0ms



user@router> ping 129.134.40.171 source 129.134.40.170 bypass-routing interface ae205   

PING 129.134.40.171 (129.134.40.171) from 129.134.40.170 ae205.0: 56(84) bytes of data.

64 bytes from 129.134.40.171: icmp_seq=1 ttl=64 time=0.971 ms

64 bytes from 129.134.40.171: icmp_seq=2 ttl=64 time=0.964 ms

^C

--- 129.134.40.171 ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1001ms

rtt min/avg/max/mdev = 0.964/0.967/0.971/0.003 ms


user@router>

Modification History

2024-07-17 : Article Created