# how to get the enumarated network interface name via command line



## raghavan (Feb 28, 2019)

Hi I  am new to FreeBSD,

My setup is :
I am having FreeBSD 12.0 HOST and BMC(Baseboard mgmt. Controller),  both are connected via USB to Ethernet Interface,
 if I issue an ipmi command from HOST, usb to Ethernet interface gets enumerated in host side as "ue0" ( for now).


Is there a way to get this name(ue0) using a script, using which (script) I should be able to tell this is the specific name of the interface that is enumerated.
Or, is there a way to fix this interface name to ue0 always.

please suggest,
Thanks


----------



## Bobi B. (Feb 28, 2019)

I don't know if that is what you need, but ifconfig(8) will list your network interfaces when given `-l` (lowercase L) command-line switch: `ifconfig -l`. Perhaps it is better do describe what are you trying to do and why. Also, which package/port did you get `ipmi` from?


----------



## raghavan (Feb 28, 2019)

Bobi B. said:


> I don't know if that is what you need, but ifconfig(8) will list your network interfaces when given `-l` (lowercase L) command-line switch: `ifconfig -l`. Perhaps it is better do describe what are you trying to do and why. Also, which package/port did you get `ipmi` from?


at regular intervals communication between BMC and HOST will happen using an automated script/bin
in that script/bin , I need to bringup the USB nic using ipmitool command(which is working ) 
I need  to assign an Ip address to that particular USB to Ethernet Interface as soon as it is up(manually works), else communication between BMC and HOST won't happen,
I can not use mac based because , there are many machines like this, so mac keeps changing for each USB to Ethernet.


----------



## Bobi B. (Feb 28, 2019)

Perhaps you can tell devd(8) to run your script when this internal network interface goes up? See devd.conf(5).


----------



## raghavan (Feb 28, 2019)

Wozzeck.Live said:


> I don't understand your issue
> 
> ue stands for driver for USB to Ethernet ASIX chips based nic (the most used USB chips of the market, Apple Belkin, many others use also ASIX )
> 
> ...


thanks for your reply,


Bobi B. said:


> Perhaps you can tell devd(8) to run your script when this internal network interface goes up? See devd.conf(5).



thanks for that ,
but how to know the Interface name if it is ue1  or ue0 etc ..


----------



## usdmatt (Feb 28, 2019)

Are you actually expecting to have more than one USB Ethernet device connected?


----------



## raghavan (Mar 1, 2019)

usdmatt said:


> Are you actually expecting to have more than one USB Ethernet device connected?


what if customer connects for his/her use,  if so it will be a problem.


----------



## olli@ (Mar 1, 2019)

Well, there is no reliable way to tell which interface is which. Normally the numbers are assigned in the order they're probed, but since USB can be hot-plugged any time, the probe order can be different, and so the numbering of the interfaces may vary.

One way to solve the problem would be to record all the MAC addresses of your ue NICs in a text file. Then your script could look up the MAC address in that text file.

If that's not feasible, the only way is to probe the networks connected to the interfaces. That is, first get the list of interfaces from the output of `ifconfig -l`. Then, for each interface, configure it and try to ping a known IP address (or try a DHCP broadcast, or whatever will work for your situation). If it succeeds, use that interface. If it fails, unconfigure it and try the next one. Once you found out the correct interface, you probably save its MAC address somewhere in a file, so you don't have to do all the probing again next time the script runs.


----------

