Re: nmcli and gateway question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020-08-03 02:20, Ed Greshko wrote:
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?

yes.  see below


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.

Hi Ed,

Okay, lets look at this as a network detective.

You start only know that there are two network connections.
One to the to Internet, which I will call the Black connection.
The other one to the internal network, which I will call the
Red connection.  You need to know which is which.

Currently

   $ netstat -rn
   Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 192.168.250.1 0.0.0.0 UG 0 0 0 eno2 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0 192.168.250.0 0.0.0.0 255.255.255.0 U 0 0 0 eno2 192.168.255.0 0.0.0.0 255.255.255.0 U 0 0 0 br0

and

   $ route -n
   Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.250.1 0.0.0.0 UG 100 0 0 eno2 192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0 192.168.250.0 0.0.0.0 255.255.255.0 U 100 0 0 eno2 192.168.255.0 0.0.0.0 255.255.255.0 U 425 0 0 br0


both tell me that "eno2" is the Black connection and "br0" is
the Red connection.  "virbr0" is also Red, but that is
another story.  And that the ONLY connection that has
a gateway is "eno2".  (More that one and all hell breaks
loose.)

In the above, I can determine:

     Red network    = 192.168.255.0/24
     Black network  = 192.168.250.0/24
     Black Gateway  = 192.168.250.1

The giveaway is the "G" flag

So, I do believe you are connect.  "nmcli" can not
tell me who is Red and who is Black.  "route" or
"netstat" are what is initially called for.

AND AFTER I have determined who is Red and Black, then
nmcli is a world of information

-T

And a story for another day, determining the address
of your dhcp server.

:-)
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedoraproject.org/archives/list/users@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux