No, you cannot know beforehand what driver will be attached for some mystery hardware configuration. Of course if you're working from a hardware inventory of known configurations and you have pre-determined what what driver will be used for each type of interface in your known systems, then it's pretty deterministic.
On the other hand as the system is booting, or after first boot, the list of known interfaces is given by the command ifconfig -l
.
Of course that still doesn't tell you which interface has an ethernet cable plugged into it, e.g. if your system has multiple interfaces on the motherboard, or multiple ethernet cards installed, or a multi-port card, etc. Some interfaces come up automatically though whenever they negotiate a connection with the switch/hub/whatever and if so then ifconfig -a
will show you all the information about all known interfaces, including which one(s) is(are) active and what media they are using (the status:
and media:
lines, respectively).
However, if your target environment uses DHCP to assign addresses then you can usually get away with just using the following line in /etc/rc.conf
dhclient=YES
as by default it will try to ask for an address on each available (broadcast-capable) interface.