Listing network interfaces as they are recognized by the kernel

I'm looking for a command to list the network interfaces as they are discovered by the kernel without having to use "ifconfig" ( ifconfig -a [plumb|unplumb] )".

The /var/sadm/system/log/sysidtool.log has the initial information that I need, but should another network card get added to the system the sysidtool.log information becomes stale.

I also looked at the /etc/path_to_inst. I could workout known cards, but from a programming point of view I would have to update a script each time a new NIC cards comes out.

I'm looking for something that lists all the possible interfaces (plumbed or not):

bge0

bge1

bge2

bge3

ce0

...

ce3

...

Any suggestions or ideas would be appreciated.

[763 byte] By [Mike_Z] at [2007-11-14]
# 1
I would start with kstat (either the utility or the C API). kstat -c net is a good start. It'll have things in there that aren't interfaces, but by looking at attributes you should be able to tell which are and arent.-- Darren
Darren_Dunham at 2007-7-7 > top of java,Solaris Operating System,Solaris 10 Features...
# 2

Darren - Thank you for your input. I agree, I was looking into the "kstat -c net" and then parsing out the information I needed.

My coworker (W.Wells) further expanded on this an we are now using the following bourne shell function to get the information we need:

getIFList () {

kstat -c net | egrep "module:|name:" | sed -e 's/[ ][ ]*/|/g' | \

nawk '

BEGIN { thismod = "" }

/^module:/ {

split($0,parts,"|")

thismod=parts[2]

}

/^name:/ {

split($0,parts,"|")

if ( parts[2] ~ thismod && parts[2] != "lo0") print parts[2]

} '

}

#getIFList

bge0

bge1

bge2

bge3

ce0

ce1

ce2

ce3

This works well with our JumpStart finish scripts to discover the interfaces at install time.

Regards,

Mike

Mike_Z at 2007-7-7 > top of java,Solaris Operating System,Solaris 10 Features...