Getting Network Card Interface information via SNMP

dhcpdomain-name-systemgatewaysnmp

(Moving this from SuperUser, I realized it's more appropriate here)

Hey all, I need to figure out how to reliably get various pieces of information for network interfaces via SNMP, such as the network card's IP address, Gateway, DNS Search Server list, and if DHCP is enabled on the interface.

Unfortunately I am finding that this information is scattered to the four corners of the (SNMP) globe, and I'm having a heck of a time tracking all of it down. So far I have the IP address, and I think I have figured out how to glean the gateway, though I'd appreciate if someone could proof my "algorithm" for doing so as I am also uncertain about how to do it for IPv6.

I cannot locate:

  • DNS servers search list, per network interface card
  • DHCP Enabled/Disabled (i.e., fixed or variable IP Address), per network interface card

This is the "algorithm" I have come up with to obtain a gateway:

  1. For every entry in the IF MIB ifTable where ifType = Ethernet, get the ifIndex
  2. If the ifIndex can be found in the IP Forward MIB inetCidrRouteTable:
    1. For IPv4 addresses, if inetCidrRouteDest = 0.0.0.0, the gateway is inetCidrRouteNextHop
    2. I do not know what to do for IPv6 addresses???
  3. Otherwise, if the ifIndex can be found in the IP Forward MIB ipCidrRouteTable
    • if ipCidrRouteDest = 0.0.0.0, the gateway is ipCidrRouteNextHop
  4. Otherwise, if the ifIndex can be found in the IP Forward MIB ipForwardTable
    • if ipForwardDest = 0.0.0.0, the gateway is ipForwardNextHop
  5. Otherwise, if the ifIndex can be found in the RFC 1213 MIB ipRouteTable
    • if ipRouteDest = 0.0.0.0, the gateway is ipRouteNextHop

Phew! As you can see, a nasty nightmare. So can anyone proof/complete my gateway algo above, or tell me about DNS/DHCP?

Also just FYI, Unix/Linux shell script alternatives won't cut it — for one I know how to do it that way already, and also I need to interrogate non-*nix devices like Cisco switches & routers, and network printers.

Thanks!

Best Answer

I like using http://tools.cisco.com/Support/SNMP/do/BrowseOID.do to see if an OID is current or deprecated.

Your alg looks good to me. I wish it didn't have to be so complicated. Have you tried, e.g., just checking ipRouteTable?

As for DHCP that is either ipNetToMediaType or ipNetToPhysicalType with a value: INTEGER: dynamic(3).

There is no standard MIB that contains the name servers.