BGP: Whats the difference between these two commands?

Hi,

I execute a couple of commands:

ip route print where "160.119.216.0/22" in dst-address

yields:

Flags: D - DYNAMIC; I - INACTIVE, A - ACTIVE; b - BGP, d - DHCP
Columns: DST-ADDRESS, GATEWAY, DISTANCE
    DST-ADDRESS  GATEWAY               DISTANCE
DIb 0.0.0.0/0    105.27.96.1                 20
DIb 0.0.0.0/0    41.209.53.49                20
DAd 0.0.0.0/0    10.1.200.1@mgmt_vrf1         1

and this command:

 ip route print where dst-address in "160.119.216.0/22"

yields

Flags: D - DYNAMIC; I - INACTIVE, A - ACTIVE; c - CONNECT, s - STATIC, b - BGP
Columns: DST-ADDRESS, GATEWAY, DISTANCE
#     DST-ADDRESS         GATEWAY         DISTANCE
  DIb 160.119.216.0/24    41.209.53.49          20
0  As 160.119.216.0/24                           1
  DAc 160.119.216.32/27   ether1                 0
  DAc 160.119.216.104/32  loopback               0
1  As 160.119.216.111/32  160.119.216.39         1
2  As 160.119.216.112/32  160.119.216.41         1
3  As 160.119.216.114/32  160.119.216.43         1
4  As 160.119.216.124/30  160.119.216.39         1
5  As 160.119.216.128/26  160.119.216.39         1
6  As 160.119.216.192/28  160.119.216.41         1
7  As 160.119.216.224/28  160.119.216.41         1
8  As 160.119.216.240/29  160.119.216.43         1
9  As 160.119.216.248/29  160.119.216.43         1
  DAb 160.119.217.0/24    105.27.96.1           20
  D b 160.119.218.0/24    105.27.96.1           20
  DAb 160.119.218.0/24    41.209.53.49          20
  DAb 160.119.219.0/24    105.27.96.1           20
  D b 160.119.219.0/24    41.209.53.49          20

If I use the GUI I can form the second command, but cannot how to see to form the first command in the GUI:
BGP-Screenshot_2023-10-30_092857.png
I mean, I can see the difference in the output generated, but these commands are so similar I have confused myself.

Which is the correct commands to show the best route to a given destination?

Then what is the second command showing?

Thanks for the help,

Confused.

The second version is the correct one. The first one does not make sense.

First example also makes sense if you want to find all routes that can route 160.119.216.0/22 subnet

No.
The first one is “is the room in you” and the second one is “are you in the room”.

Thank you.

I have been using the second one all along. Came across the first one as its how https://github.com/gmazoyer/looking-glass/tree/main does it.

The first one is showing disabled routes as well, which makes no sense.

I will carry on with the second.

Best,

I think it v6 it worked both ways which is of course a bit silly… “in” suggests that the network on the left is smaller (or same size) than the network on the right.

ip route print where "160.119.216.0/22" in dst-address

Prints all routes that can route “160.119.216.0/22” network

ip route print where dst-address in "160.119.216.0/22"

print all routes which destination is within 160.119.216.0/22 subnet

And of course these will print all matxhed routes including disabled or inactive routes, if you do not want to see inactive or disabled routes you have to add appropriate parameters like

ip route print where "160.119.216.0/22" in dst-address && !inactive

The plot thickens, from a point of view on what to put in the Looking Glass command.

If you put a specific single ip address for the first command then it makes sense. So my take is the second one should be used when looking for routes inside a prefix, and the first when looking for paths for a specific IP address.

/ip route print where 160.119.217.33 in dst-address

yields

Flags: D - DYNAMIC; I - INACTIVE, A - ACTIVE; b - BGP, d - DHCP
Columns: DST-ADDRESS, GATEWAY, DISTANCE
    DST-ADDRESS       GATEWAY               DISTANCE
DIb 0.0.0.0/0         105.27.96.1                 20
DIb 0.0.0.0/0         41.209.53.49                20
DAb 160.119.217.0/24  105.27.96.1                 20
DAd 0.0.0.0/0         10.1.200.1@mgmt_vrf1         1

and

/ip route print where dst-address in 160.119.216.33

yields nothing. which makes sense as its a subnet of exactly one host.

Yes, exactly, you got it right.