Re: nmcli and gateway question

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

 



On 2020-08-03 03:40, Tom H wrote:
On Mon, Aug 3, 2020 at 3:53 AM ToddAndMargo via users
<users@xxxxxxxxxxxxxxxxxxxxxxx> wrote:
On 2020-08-02 16:30, Ed Greshko wrote:
On 2020-08-03 07:10, ToddAndMargo via users wrote:
On 2020-08-01 19:42, Samuel Sieb wrote:
On 8/1/20 7:20 PM, ToddAndMargo via users wrote:

Is there a way to get nmcli to tell you if an interface
is a gateway like you can with `netstat -rn`?

Very related to the previous question.

# nmcli --fields IP4.GATEWAY d show wlo1
IP4.GATEWAY:                            10.0.1.1

# nmcli --fields IP4.GATEWAY d show lo
IP4.GATEWAY:                            --

Uh Oh!

This tells me "what" the gateway is, but not
"if" the device is a gateway:

$ netstat -rn | grep eno2
0.0.0.0         192.168.250.1   0.0.0.0         UG        0 0          0 eno2
192.168.250.0   0.0.0.0         255.255.255.0   U         0 0          0 eno2

$ nmcli device show eno2
GENERAL.DEVICE:                         eno2
GENERAL.TYPE:                           ethernet
GENERAL.HWADDR:                         AC:1F:6B:62:10:07
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     eno2
GENERAL.CON-PATH: /org/freedesktop/NetworkManager/ActiveCo
nnection/5
WIRED-PROPERTIES.CARRIER:               on
IP4.ADDRESS[1]:                         192.168.250.135/24
IP4.GATEWAY:                            192.168.250.1
IP4.ROUTE[1]:                           dst = 192.168.250.0/24, nh = 0.0.0.0, mt
   = 0
IP4.ROUTE[2]:                           dst = 0.0.0.0/0, nh = 192.168.250.1, mt
= 0
IP4.DNS[1]:                             127.0.0.1
IP6.ADDRESS[1]:                         fe80::ae1f:6bff:fe62:1007/64
IP6.GATEWAY:                            --
IP6.ROUTE[1]:                           dst = fe80::/64, nh = ::, mt = 100
IP6.ROUTE[2]:                           dst = ff0

I don't know what you're trying to determine.

Are you thinking that the G in the netstat output means the
interface is a Gateway? It doesn't. The U means the "route" is
valid and the G means the "route" is to a gateway rather than a
directly connected network or host.

I did not state my question very well. My Bad.

I am not after what the gateway address is, but rather

1) if gateway is up or not

2) if my device connected to the gateway that is up

Note that in this instance, if my device is down,
it is also not connected to a gateway.

I was after a way to get nmcli to also give
me this information.

man netstat:

--route, -r
         Display  the kernel routing tables.

--numeric, -n
         Show numerical addresses instead of trying to determine symbolic
   host,
         port or user names.

man route:
Flags  Possible flags include
                U (route is up)
                H (target is a host)
                G (use gateway)
                R (reinstate route for dynamic routing)
                D (dynamically installed by daemon or redirect)
                M (modified from routing daemon or redirect)
                A (installed by addrconf)
                C (cache entry)
                !  (reject route)

$ route -n | grep -i eno2
0.0.0.0         192.168.250.1   0.0.0.0         UG    0      0        0 eno2
192.168.250.0   0.0.0.0         255.255.255.0   U     0      0        0 eno2


$ netstat -rn | grep -i eno2
0.0.0.0         192.168.250.1   0.0.0.0         UG        0 0          0
eno2
192.168.250.0   0.0.0.0         255.255.255.0   U         0 0          0
eno2

$ ifconfig eno2 | grep "inet "
          inet 192.168.250.135  netmask 255.255.255.0  broadcast
192.168.250.255

$ nmcli connection down eno2
Connection 'eno2' successfully deactivated (D-Bus active path:
/org/freedesktop/NetworkManager/ActiveConnection/5)

$ route -n | grep -i eno2
<nothing>

$ netstat -rn | grep -i eno2
<nothing>

"resolvectl query _gateway" will tell you that the gateway's set to X
ip address, but only if you have "myhostname" in "nsswitch.conf".

You can only check whether the gateway's up with "ping".

If you mean that you want to check whether the NIC's up and you don't
want to trust nmcli's "GENERAL.STATE" property, you can check
"/sys/class/net/ens3/carrier" and/or "/sys/class/net/ens3/operstate".


I think I misunderstand.

$ resolvectl query _gateway
_gateway: resolve call failed: Could not activate remote peer.
_______________________________________________
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