On 2020-08-03 14:22, ToddAndMargo via users wrote:
You are presuming I know anything about several
networks at this point
I think I may have interpreted this incorrectly.
Do you mean your script will run on a system/network for which you have no prior
knowledge?
If that is the case, maybe you should consider tools other than nmcli. While it can be
used, it may not
be easy to tease out information in a way that is simply to correlate.
You can do something like
nmcli -f IP4.ROUTE d show
and get all the ROUTE fields for all the devices but determining which belongs to which is
not
simple.
You may want to consider the ip command.
[egreshko@meimei ~]$ ip -br -4 add show
lo UNKNOWN 127.0.0.1/8
enp2s0 UP 192.168.1.18/24
wlp4s0 UP 192.168.2.127/24
virbr0 UP 192.168.122.1/24
[egreshko@meimei ~]$ ip -br -4 route show
default via 192.168.1.1 dev enp2s0 proto static metric 100
default via 192.168.2.5 dev wlp4s0 proto dhcp metric 600
192.168.1.0/24 dev enp2s0 proto kernel scope link src 192.168.1.18 metric 100
192.168.2.0/24 dev wlp4s0 proto kernel scope link src 192.168.2.127 metric 600
192.168.56.0/24 via 192.168.2.116 dev wlp4s0 proto static metric 600
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1
Tells you everything you need to know about networking on the host meimei.
(Note: I used -4 in the example since I'm also running IPV6 and didn't wish add
complication)
You know that the default route will be via enp2s0 to 192.168.1.1 as long as enp2s0 is
up.
So, you'd naturally ping 192.168.1.1.
You know that if enp2s0 is down then the default route will be via wlp4v0 to 192.168.2.5.
So, if enp2s0 is down you'd naturally ping 192.168.2.5.
--
The key to getting good answers is to ask good questions.