2

(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!

1
  • 2
    I think that some of the things you're asking for aren't necessarily associated with "an interface" : dns servers and gateway for example. You could even say that with a virtual interface a card might have more than one ip address. Consider a linux box acting as a router-- it may have several physical interfaces (let's say 3), but it may have 10 or more other routers that it routes traffic through. DNS should be obtainable from the OS, and the method of obtaining that will be OS dependent. Likewise for dhcp info.
    – unixguy
    Oct 7, 2010 at 22:07

4 Answers 4

1

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.

1
  • I need to check all the IP routing tables, even the deprecated ones, because I need to accommodate older devices. Thanks for the DHCP hint!
    – Irinotecan
    Oct 13, 2010 at 20:19
1

Instead of looking at snmp indexes you really want to use the snmptable program.

For example

/usr/bin/snmptable -v2c -c public $HOST NETAPP-MIB::netifTable

MIBS are actually quite human-readable. For the rest, RedGrittyBrick said it all.

0

What I used to do was use snmpwalk to enumerate the whole tree below a certain point and save the results in a file, you can then search for a value (e.g the IP-address of a DNS server) and find the OIDs associated with it.

I would then know what OIDs to put in my MRTG config file.

Different manufacturers stick info in different places. If you don't have their MIB definitions then this was the best method I could find for reverse engineering OIDs.

0

If windows then

Create your own program in Visual Basic, i would not go for SNMP.

1
  • No, sorry, this relates to scanning non-Windows devices, I need to use SNMP.
    – Irinotecan
    Oct 13, 2010 at 20:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .