On Fri, Aug 7, 2020 at 1:34 PM Ed Greshko <ed.greshko(a)greshko.com> wrote:
On 2020-08-07 18:44, Tom H wrote:
> On Wed, Aug 5, 2020 at 3:49 PM Ed Greshko <ed.greshko(a)greshko.com>
> wrote:
>> On 2020-08-05 21:02, Tom H wrote:
>>> Hopefully Todd, the OP, realized that you were implying
that he
>>> might not have "systemd-resolved" running...
>>
>> Hopefully....
>>
>> I may be dense, but it seems to me there is no particular advantage
>> to using resolvectl, or getent over the "ip route" command to learn
>> the IP address of the gateway. For my $ those give too little info
>> to understand how traffic may be routed. And that is what I am
>> normally also wanting to know when looking at a gateway. But that
>> may just be me.
> The complaint was that the iproute tools spit out too much
> information.
Oh, I thought the complaint was that nmcli, at least the command I
used, gave too much info. Granted, I was giving a command which
returned all the info I though the OP wanted.
I remember that someone proposed "ip a" and/or "ip r", but the Todd
said it was too verbose; "nmcli" too.
FWIW, I only use nmcli to create, edit, control connections/devices
under the control of NetworkManager. I don't use, and wouldn't use,
nmcli to search/determine how things are configured on a system I'm
not familiar with.
If a system's using NM, I definitely use "nmcli" to find out what's
going on, whether I've set it up or not. But, unless I'm setting up a
bridge or a bond, I write out the config under
"/etc/NetworkManager/system-connections".
Each tool has some "drawbacks" unless you are aware of
their use
cases or have a clear understanding of what you need/want to know.
For example,
[egreshko@meimei ~]$ resolvectl query _gateway
_gateway: 192.168.1.1 -- link: enp2s0
192.168.2.5 -- link: wlp4s0
2001:b030:112f::1 -- link: enp2s0
Returns a list of "default gateways". But, it doesn't tell you which
will actually be used.
This is abusing "resolvectl"! LOL
It's not meant for displaying routing tables. But a bug report with
the output above might convince the systemd developers to add "metric"
in the case of a gateway, or, simply, in the case of "_gateway".
[egreshko@meimei ~]$ ip -br -4 route show | grep default
default via 192.168.1.1 dev enp2s0 proto static metric 100
default via 192.168.2.5 dev wlp4s0 proto dhcp metric 600
Tells one the same, but does have the metric so you know which route
would be used first. But you can't, at least I've not found a way, to
list both IPv4 and IPv6 routes with the same command.
And even both of those, as written, don't show Host routes which also
need a "gateway" but not one which is "default"
But you're grepping for "default".
netstat -rn is sorta fine for IPv4, but spits out too much for my
taste with IPv6. I don't normally care about scope link info. It
also has a Flag of U which can confuse since some docs say "route is
up" and other documentation say "route is valid". It can lead some to
think that it may mean the physical gateway device is "up" and
working. It also lacks a metric....but I suppose most setups are
rather straight-forward.
I've never seen "valid". It's "usable" in BSD-land. But
"man route"
says that it's "up" in Linux-land.
Like "ip r", "route -n"/"netstat -nr" only show one family
at a time,
"inet" by default. Could it be a Linux limitation, one family at a
time?! On OpenBSD, the inet and inet6 families are displayed by
default.