# Network interface names



## balanga (May 17, 2017)

How does FreeBSD associate names for network interfaces? On most of my systems em0 is associated with my NIC although I have igb0 on one system?

The problem I'm trying to resolve is that I have a USB modem which can be configured as an NDIS device and I can't work out what interface name it would have.... `ifconfig` does not display it, so, presumably it has not been configured as a network interface even though `usbconfig` identifies it as a network device.

How do I confirm whether it is a network device, and if it is should `ifconfig` try to assign a network address?


----------



## Eric A. Borisch (May 17, 2017)

Names are based on the driver; em0 = first device created using the em(4) driver.

Haven't used it myself, but I would start by reading the ndis(4) man page.


----------



## forquare (May 17, 2017)

balanga said:


> The problem I'm trying to resolve is that I have a USB modem which can be configured as an NDIS device and I can't work out what interface name it would have.... `ifconfig` does not display it, so, presumably it has not been configured as a network interface even though `usbconfig` identifies it as a network device.



Does it show up with `ifconfig -a`

From the man page:


> Optionally, the -a flag may be used instead of an interface name.  This flag instructs ifconfig to display information about all interfaces in the system.


----------



## Phishfry (May 18, 2017)

Instead of adding the device to your /etc/rc.conf try this instead:

`ifconfig_DEFAULT="DHCP"`

I am assuming this is related to your thumbdrive project.


----------



## Phishfry (May 18, 2017)

Sorry the above advice is not what you needed. But for a NDIS modem you could have either a ue0 device or it could be found as cdc_ether.
I suggest you study your dmesg output and look hard tword the end of the devices. It should show up there. Maybe do a `dmesg | grep HUAWEI` and maybe do `usbconfig` for clues.


----------



## SirDice (May 18, 2017)

Modems are not network devices. So there's no "network" interface. Modems typically have a serial connection. On top of this serial connection you usually run ppp(8), and it's ppp(8) that provides the network interface. And yes, this is also valid for those wireless 3G/4G modems.


----------



## Phishfry (May 18, 2017)

Actually some of these Huawei devices have ue0 networking like tethered devices use.
It might needusb_modeswitch to get the right mode for FreeBSD.
Sometimes changing the PID does it.
I am pretty sure I pointed to the pfSense post with all the details already for this topic for the same guy.

Huawei NDIS mode sometimes show up like this:
https://www.freebsd.org/cgi/man.cgi?query=cdce
https://lists.freebsd.org/pipermail/freebsd-wireless/2016-April/006656.html


----------



## balanga (May 18, 2017)

SirDice said:


> Modems are not network devices. So there's no "network" interface. Modems typically have a serial connection. On top of this serial connection you usually run ppp(8), and it's ppp(8) that provides the network interface. And yes, this is also valid for those wireless 3G/4G modems.



When I use this modem on Windows it installs a program called Mobile Partner and it configures the modem as an NDIS device. I'm still trying to figure out how to do this on FreeBSD.


----------



## Phishfry (May 18, 2017)

Umm yea you already said that here
https://forums.freebsd.org/threads/60541/#post-348512

Did you look at the pfSense page?

The firmware can be changed on these devices and you have HiLink or NDIS.


----------



## balanga (May 18, 2017)

Phishfry said:


> Sorry the above advice is not what you needed. But for a NDIS modem you could have either a ue0 device or it could be found as cdc_ether.
> I suggest you study your dmesg output and look hard tword the end of the devices. It should show up there. Maybe do a `dmesg | grep HUAWEI` and maybe do `usbconfig` for clues.


`dmesg`

```
ugen0.4: <HUAWEIMOBILE> at usbus0
u3g0: <HUAWEIMOBILE HUAWEIMOBILE, class 0/0, rev 2.10/1.02, addr 4> on usbus0
u3g0: Found 2 ports.
```
`usbconfig dump_device_desc`

```
ugen0.4: <HUAWEIMOBILE HUAWEIMOBILE> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (2mA)

  bLength = 0x0012 
  bDescriptorType = 0x0001 
  bcdUSB = 0x0210 
  bDeviceClass = 0x0000  <Probed by interface class>
  bDeviceSubClass = 0x0000 
  bDeviceProtocol = 0x0000 
  bMaxPacketSize0 = 0x0040 
  idVendor = 0x12d1 
  idProduct = 0x1506 
  bcdDevice = 0x0102 
  iManufacturer = 0x0001  <HUAWEI_MOBILE>
  iProduct = 0x0002  <HUAWEI_MOBILE>
  iSerialNumber = 0x0000  <no string>
  bNumConfigurations = 0x0001
```
`usbconfig dump_all_config_desc`

```
ugen0.4: <HUAWEIMOBILE HUAWEIMOBILE> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (2mA)


 Configuration index 0

    bLength = 0x0009 
    bDescriptorType = 0x0002 
    wTotalLength = 0x00dd 
    bNumInterfaces = 0x0005 
    bConfigurationValue = 0x0001 
    iConfiguration = 0x0000  <no string>
    bmAttributes = 0x0080 
    bMaxPower = 0x0001 

    Interface 0
      bLength = 0x0009 
      bDescriptorType = 0x0004 
      bInterfaceNumber = 0x0000 
      bAlternateSetting = 0x0000 
      bNumEndpoints = 0x0002 
      bInterfaceClass = 0x00ff  <Vendor specific>
      bInterfaceSubClass = 0x0003 
      bInterfaceProtocol = 0x0012 
      iInterface = 0x0000  <no string>

      Additional Descriptor

      bLength = 0x05
      bDescriptorType = 0x24
      bDescriptorSubType = 0x00
       RAW dump: 
       0x00 | 0x05, 0x24, 0x00, 0x10, 0x01


      Additional Descriptor

      bLength = 0x04
      bDescriptorType = 0x24
      bDescriptorSubType = 0x02
       RAW dump: 
       0x00 | 0x04, 0x24, 0x02, 0x02


      Additional Descriptor

      bLength = 0x05
      bDescriptorType = 0x24
      bDescriptorSubType = 0x01
       RAW dump: 
       0x00 | 0x05, 0x24, 0x01, 0x00, 0x00


      Additional Descriptor

      bLength = 0x05
      bDescriptorType = 0x24
      bDescriptorSubType = 0x06
       RAW dump: 
       0x00 | 0x05, 0x24, 0x06, 0x00, 0x00


     Endpoint 0
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0082  <IN>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200 
        bInterval = 0x0000 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 

     Endpoint 1
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0002  <OUT>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200 
        bInterval = 0x0000 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 


    Interface 1
      bLength = 0x0009 
      bDescriptorType = 0x0004 
      bInterfaceNumber = 0x0001 
      bAlternateSetting = 0x0000 
      bNumEndpoints = 0x0003 
      bInterfaceClass = 0x00ff  <Vendor specific>
      bInterfaceSubClass = 0x0003 
      bInterfaceProtocol = 0x0001 
      iInterface = 0x0000  <no string>

      Additional Descriptor

      bLength = 0x05
      bDescriptorType = 0x24
      bDescriptorSubType = 0x00
       RAW dump: 
       0x00 | 0x05, 0x24, 0x00, 0x10, 0x01


      Additional Descriptor

      bLength = 0x04
      bDescriptorType = 0x24
      bDescriptorSubType = 0x02
       RAW dump: 
       0x00 | 0x04, 0x24, 0x02, 0x02


      Additional Descriptor

      bLength = 0x05
      bDescriptorType = 0x24
      bDescriptorSubType = 0x01
       RAW dump: 
       0x00 | 0x05, 0x24, 0x01, 0x00, 0x01


      Additional Descriptor

      bLength = 0x05
      bDescriptorType = 0x24
      bDescriptorSubType = 0x06
       RAW dump: 
       0x00 | 0x05, 0x24, 0x06, 0x00, 0x00


     Endpoint 0
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0084  <IN>
        bmAttributes = 0x0003  <INTERRUPT>
        wMaxPacketSize = 0x000a 
        bInterval = 0x0009 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 

     Endpoint 1
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0083  <IN>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200 
        bInterval = 0x0000 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 

     Endpoint 2
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0003  <OUT>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200 
        bInterval = 0x0000 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 


    Interface 2
      bLength = 0x0009 
      bDescriptorType = 0x0004 
      bInterfaceNumber = 0x0002 
      bAlternateSetting = 0x0000 
      bNumEndpoints = 0x0001 
      bInterfaceClass = 0x00ff  <Vendor specific>
      bInterfaceSubClass = 0x0003 
      bInterfaceProtocol = 0x0016 
      iInterface = 0x0008  <NCM Network Control Model>

      Additional Descriptor

      bLength = 0x05
      bDescriptorType = 0x24
      bDescriptorSubType = 0x00
       RAW dump: 
       0x00 | 0x05, 0x24, 0x00, 0x10, 0x01


      Additional Descriptor

      bLength = 0x06
      bDescriptorType = 0x24
      bDescriptorSubType = 0x1a
       RAW dump: 
       0x00 | 0x06, 0x24, 0x1a, 0x00, 0x01, 0x1f


      Additional Descriptor

      bLength = 0x0d
      bDescriptorType = 0x24
      bDescriptorSubType = 0x0f
       RAW dump: 
       0x00 | 0x0d, 0x24, 0x0f, 0x0a, 0x0f, 0x00, 0x00, 0x00, 
       0x08 | 0xea, 0x05, 0x03, 0x00, 0x01


      Additional Descriptor

      bLength = 0x05
      bDescriptorType = 0x24
      bDescriptorSubType = 0x06
       RAW dump: 
       0x00 | 0x05, 0x24, 0x06, 0x02, 0x02


     Endpoint 0
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0086  <IN>
        bmAttributes = 0x0003  <INTERRUPT>
        wMaxPacketSize = 0x0010 
        bInterval = 0x0005 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 


    Interface 2 Alt 1
      bLength = 0x0009 
      bDescriptorType = 0x0004 
      bInterfaceNumber = 0x0002 
      bAlternateSetting = 0x0001 
      bNumEndpoints = 0x0003 
      bInterfaceClass = 0x00ff  <Vendor specific>
      bInterfaceSubClass = 0x0003 
      bInterfaceProtocol = 0x0016 
      iInterface = 0x0009  <CDC Network Data>

     Endpoint 0
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0086  <IN>
        bmAttributes = 0x0003  <INTERRUPT>
        wMaxPacketSize = 0x0010 
        bInterval = 0x0005 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 

     Endpoint 1
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0085  <IN>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200 
        bInterval = 0x0000 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 

     Endpoint 2
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0004  <OUT>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200 
        bInterval = 0x0000 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 


    Interface 3
      bLength = 0x0009 
      bDescriptorType = 0x0004 
      bInterfaceNumber = 0x0003 
      bAlternateSetting = 0x0000 
      bNumEndpoints = 0x0002 
      bInterfaceClass = 0x0008  <Mass storage>
      bInterfaceSubClass = 0x0006 
      bInterfaceProtocol = 0x0050 
      iInterface = 0x0004  <Mass Storage>

     Endpoint 0
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0087  <IN>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200 
        bInterval = 0x0000 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 

     Endpoint 1
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0005  <OUT>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200 
        bInterval = 0x0001 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 


    Interface 4
      bLength = 0x0009 
      bDescriptorType = 0x0004 
      bInterfaceNumber = 0x0004 
      bAlternateSetting = 0x0000 
      bNumEndpoints = 0x0002 
      bInterfaceClass = 0x0008  <Mass storage>
      bInterfaceSubClass = 0x0006 
      bInterfaceProtocol = 0x0050 
      iInterface = 0x0004  <Mass Storage>

     Endpoint 0
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0088  <IN>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200 
        bInterval = 0x0000 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000 

     Endpoint 1
        bLength = 0x0007 
        bDescriptorType = 0x0005 
        bEndpointAddress = 0x0006  <OUT>
        bmAttributes = 0x0002  <BULK>
        wMaxPacketSize = 0x0200 
        bInterval = 0x0001 
        bRefresh = 0x0000 
        bSynchAddress = 0x0000
```

It seems I'm missing the magic word needed to get this working....Maybe it is usb_modeswitch but am not sure..


----------



## balanga (May 18, 2017)

Phishfry said:


> Umm yea you already said that here
> https://forums.freebsd.org/threads/60541/#post-348512
> 
> Did you look at the pfSense page?
> ...



I have searched through the pfSense forums and there are a number of posts about 4G/LTE modems, but I haven't found a definitive 'beginners guide'. A number of posts deal with getting `ppp` working, which isn't something I'm looking for. There is a lot of info, but much of it is over my head.


----------



## Phishfry (May 18, 2017)

From your posts it looks like 2 `u3g` ports are showing.
Have you tried using cu? You might need to guess which port to use by checking both.
Can you use an AT terminal OK? ATZ AT

first try:
`cu -l /dev/cuaU0.1`

then if nothing try:
`cu -l /dev/cuaU0.0`

I would use your Windows "Mobile Partner" app to find your firmware version..
21.xx or 22.xx

The connections will be different types.

Modeswitching may not be needed. Notice the bConfigurationValue of 1


----------



## Phishfry (May 18, 2017)

Beginners guide do not exist for mobile broadband.
This is an advanced user task. Especially Huawei modules.



balanga said:


> idProduct = 0x1506


So this is where you start researching. The modem landed in FreeBSD in 2012.

This post has your exact instructions needed. Module has same exact idProduct
https://forum.pfsense.org/index.php?topic=105842.0

From your AT command prompt.
AT^SETPORT="FF;10,12"

Notice from the above post that they are using ATI to show the firmware version of the modem.


----------



## Phishfry (May 18, 2017)

balanga said:


> A number of posts deal with getting  ppp working, which isn't something I'm looking for.


Well ppp is needed on FreeBSD for most broadband modems and is also not easy to setup.
Hint. I have posted my ppp.conf for ATT here on the forum and all you need to change is usb port and use your carrier's APN.

I would suggest you read the manual on `cu`. Its easy to startup but not intuitive on the exit keystrokes needed IMHO.


----------



## balanga (May 18, 2017)

Phishfry said:


> From your posts it looks like 2 `u3g` ports are showing.
> Have you tried using cu? You might need to guess which port to use by checking both.
> Can you use an AT terminal OK? ATZ AT
> 
> ...





> Connected


 !!!!!!



> I would use your Windows "Mobile Partner" app to find your firmware version..
> 21.xx or 22.xx
> 
> The connections will be different types.
> ...



`ATI` results in:

```
Manufacturer:  huawei
Model:   E3372
Revision:  21.180.01.00.00
IMEI:    866119027727057
+GCAP:  +CGSM, +DS, +ES

OK
```

It seems as though progress is being made, albeit at a snails pace...


----------



## balanga (May 18, 2017)

Phishfry said:


> From your posts it looks like 2 `u3g` ports are showing.
> Have you tried using cu? You might need to guess which port to use by checking both.
> Can you use an AT terminal OK? ATZ AT



I haven't used Hayes commands for over 20 years since I ran a BBS , and can hardly remember anything...

After issuing:-

`cu -l /dev/cuaU0.1`

I find I'm stuck and can't get back to the command prompt. I thought `ATH0` might work but it didn't.


----------



## SirDice (May 18, 2017)

```
~^D or ~.
             Drop the connection and exit.  Only the connection is dropped -
             the login session is not terminated.
```
From cu(1)


----------



## balanga (May 18, 2017)

Thanks for that.
*
~.  *worked but '~' took some finding... /etc/rc.conf  contained 
	
	



```
keymap='uk.cp850'
```
 but it seemed like a US keyboard layout. (This was on pfSense so I don't know if keymap is defined elsewhere in that environment.)


----------



## Phishfry (May 18, 2017)

What does `AT^SETPORT=?` show.


----------



## balanga (May 18, 2017)

```
ERROR
```


----------



## Phishfry (May 19, 2017)

I am somewhat confused as to which port is the AT command port. That pfSense post shows both cuaU0.0 from one guy and cuaU0.1 from the other user.
From my Sierra experience I can tell you there is more than one AT command port. One is the actual management port the other a more limited AT command prompt. So building on that I would retry cuaU0.0 and make sure there is no AT command console located there. Possibly you are using a limited AT command port with cuaU0.1

The other thing would do is make sure the firmware is up to date for the device.
Use your 'Mobile Partner' app which has firmware update feature.

Also try this command to reset to factory settings
AT&F


----------



## Phishfry (May 19, 2017)

Looks like some OEM's add a lock on it that needs a passcode to unlock managment features. That maybe why it shows ERROR.

This will show if enabled: AT^CARDLOCK=?


----------



## balanga (May 19, 2017)

Phishfry said:


> What does `AT^SETPORT=?` show.


 I blindly followed your instruction yesterday, but I think that should have been `AT^SETPORT?` - no '='....
This returned:


```
AT^SETPORT:A1,A2;12,1,16,A1,A2
```

It seems like I'm going on a Magical Mystery Tour with all this....


----------



## balanga (May 19, 2017)

Phishfry said:


> I am somewhat confused as to which port is the AT command port. That pfSense post shows both cuaU0.0 from one guy and cuaU0.1 from the other user.
> From my Sierra experience I can tell you there is more than one AT command port. One is the actual management port the other a more limited AT command prompt. So building on that I would retry cuaU0.0 and make sure there is no AT command console located there. Possibly you are using a limited AT command port with cuaU0.1



`ls -ls /dev` shows this, if it sheds any light:-

```
0 crw-rw----  1 uucp  dialer    0xa7 May 18 08:46 cuaU0.0
0 crw-rw----  1 uucp  dialer    0xa8 May 18 08:46 cuaU0.0.init
0 crw-rw----  1 uucp  dialer    0xa9 May 18 08:46 cuaU0.0.lock
0 crw-rw----  1 uucp  dialer    0xad May 18 08:46 cuaU0.1
0 crw-rw----  1 uucp  dialer    0xaf May 18 08:46 cuaU0.1.init
0 crw-rw----  1 uucp  dialer    0xb0 May 18 08:46 cuaU0.1.lock
0 crw-rw----  1 uucp  dialer    0x2e Apr 27 12:10 cuau0
0 crw-rw----  1 uucp  dialer    0x2f Apr 27 12:10 cuau0.init
0 crw-rw----  1 uucp  dialer    0x30 Apr 27 12:10 cuau0.lock
0 crw-rw----  1 uucp  dialer    0x34 Apr 27 12:10 cuau1
0 crw-rw----  1 uucp  dialer    0x35 Apr 27 12:10 cuau1.init
0 crw-rw----  1 uucp  dialer    0x36 Apr 27 12:10 cuau1.lock
0 crw-rw----  1 uucp  dialer    0x3a Apr 27 12:10 cuau2
0 crw-rw----  1 uucp  dialer    0x3b Apr 27 12:10 cuau2.init
0 crw-rw----  1 uucp  dialer    0x3c Apr 27 12:10 cuau2.lock
0 crw-rw----  1 uucp  dialer    0x40 Apr 27 12:10 cuau3
0 crw-rw----  1 uucp  dialer    0x41 Apr 27 12:10 cuau3.init
0 crw-rw----  1 uucp  dialer    0x42 Apr 27 12:10 cuau3.lock
```


----------

