Internet access via 4G Dongle using RNDIS

A few years ago, I remember having a hard time getting a 4G Dongle (Huawei E3372) to work accessing the Internet, but recently stumbled on it and thought I'd try again.

I was suprised how straight forward it was to get going under OpenWrt using rndis. Now I'm trying to do the same on FreeBSD, but am unsure of how to use RNDIS.

kldstat shows if_urndis.ko, so what else do I need to make the USB dongle access the Internet?
 
The urndis driver loaded automatically after connecting dongle to computer?
What ifconfig shows?

I haven't any 4G/3G dongle.
 
When I plug in the dongle it shows up in usbconfig() like so:
ugen0.2: <HUAWEIMOBILE HUAWEIMOBILE> at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON (2mA

lsusb() shows:
Bus /dev/usb Device /dev/ugen0.2: ID 12d1:1506 Huawei Technologies Co., Ltd. Modem/Networkcard

ifconfig ue2
Code:
ue2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=80000<LINKSTATE>
        ether 2a:9d:3c:cf:94:01
        inet 0.0.0.0 netmask 0xff000000 broadcast 255.255.255.255
        media: Ethernet autoselect
        status: no carrier
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL

kldstat:
Code:
 1  108 0xffffffff80200000  1f3e2d0 kernel
 2    1 0xffffffff82140000     bec8 autofs.ko
 3    1 0xffffffff82320000   1808b8 i915kms.ko
 4    1 0xffffffff824a1000    72bd8 drm.ko
 5    1 0xffffffff82514000     22b0 iic.ko
 6    2 0xffffffff82517000     30fc linuxkpi_gplv2.ko
 7    3 0xffffffff8251b000     62d8 dmabuf.ko
 8    1 0xffffffff82522000    11cd8 fusefs.ko
 9    1 0xffffffff82534000     3378 acpi_wmi.ko
10    1 0xffffffff82538000     3250 ichsmb.ko
11    1 0xffffffff8253c000     2180 smbus.ko
12    1 0xffffffff8253f000     4cfc geom_uzip.ko
13    1 0xffffffff82544000     3340 uhid.ko
14    1 0xffffffff82548000     4350 ums.ko
15    1 0xffffffff8254d000     3380 usbhid.ko
16    1 0xffffffff82551000     31f8 hidbus.ko
17    1 0xffffffff82555000     3480 umodem.ko
18    1 0xffffffff82559000     4d90 ucom.ko
19    1 0xffffffff8255e000     4640 if_cdce.ko
20    3 0xffffffff82563000     3178 uether.ko
21    1 0xffffffff82567000     8500 if_ure.ko
22    1 0xffffffff82570000     4d00 ng_ubt.ko
23    6 0xffffffff82575000     aac8 netgraph.ko
24    2 0xffffffff82580000     a238 ng_hci.ko
25    4 0xffffffff8258b000     25a8 ng_bluetooth.ko
26    1 0xffffffff8258e000     e250 ng_l2cap.ko
27    1 0xffffffff8259d000    1bee8 ng_btsocket.ko
28    1 0xffffffff825b9000     39c0 ng_socket.ko
29    1 0xffffffff825bd000     2138 msdosfs_iconv.ko
30    1 0xffffffff825c0000     4798 libiconv.ko
31    1 0xffffffff825c5000    1ae78 ext2fs.ko
32    1 0xffffffff825e0000     3380 if_urndis.

dhclient ue2 :
Code:
DHCPDISCOVER on ue2 to 255.255.255.255 port 67 interval 3
DHCPDISCOVER on ue2 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on ue2 to 255.255.255.255 port 67 interval 10
DHCPDISCOVER on ue2 to 255.255.255.255 port 67 interval 11
DHCPDISCOVER on ue2 to 255.255.255.255 port 67 interval 12
DHCPDISCOVER on ue2 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on ue2 to 255.255.255.255 port 67 interval 10
No DHCPOFFERS received.
No working leases in persistent database - sleeping.

It connects OK when I use it in OpenWrt.

Anyone know what could be missing?
 
do you have a serial connection to the modem also ?
you can use cu + AT commands to check network status and stuff
 
I have this if this is what you mean:-

Code:
crw-rw----  1 uucp  dialer  0x1e5 Feb  3 20:47 /dev/cuaU0
crw-rw----  1 uucp  dialer  0x1e6 Feb  3 20:47 /dev/cuaU0.init
crw-rw----  1 uucp  dialer  0x1e7 Feb  3 20:47 /dev/cuaU0.lock
crw-rw----  1 uucp  dialer  0x1eb Feb  3 20:47 /dev/cuaU1
crw-rw----  1 uucp  dialer  0x1ec Feb  3 20:47 /dev/cuaU1.init
crw-rw----  1 uucp  dialer  0x1ed Feb  3 20:47 /dev/cuaU1.lock
crw-rw----  1 uucp  dialer  0x1f1 Feb  3 20:47 /dev/cuaU2
crw-rw----  1 uucp  dialer  0x1f2 Feb  3 20:47 /dev/cuaU2.init
crw-rw----  1 uucp  dialer  0x1f3 Feb  3 20:47 /dev/cuaU2.lock
crw-rw----  1 uucp  dialer   0x37 Feb  3 20:47 /dev/cuau2
crw-rw----  1 uucp  dialer   0x38 Feb  3 20:47 /dev/cuau2.init
crw-rw----  1 uucp  dialer   0x39 Feb  3 20:47 /dev/cuau2.lock
 
I tried to use USB tethering via my phone and got an IP addressed established

Code:
ue2: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 02:0b:36:32:3b:65
        inet 192.168.42.131 netmask 0xffffff00 broadcast 192.168.42.255
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

How do I access the Internet using this interface?

Is it just a matter of setting defaultrouter?
 
I use this dongle to send notifications to my phone via sms. This is how I use.

When connected to the server run this script:

As you can see you need usb_modeswitch.

Code:
#!/bin/sh

/usr/local/sbin/usb_modeswitch -v 0x12d1 -p 0x1f01 -c /usr/local/share/usb_modeswitch/12d1:1f01

sleep 5

ifconfig ue0 inet 192.168.8.10/24
#dhclient ue0
#dhclient -b ue0

sleep 3

setfib 1 route add -net 192.168.8.0/24 -iface ue0
setfib 1 route add default 192.168.8.1

sleep 2

/usr/local/bin/notifyme "4G Dongle Attached"

Code:
root@server420:/home/user # cat /usr/local/bin/notifyme

#!/usr/local/bin/bash
exec 3>&1 4>&2
trap 'exec 2>&4 1>&3' 0 1 2 3
exec 1>>/var/log/log.out 2>&1
# Everything below will go to the file 'log.out':

sh /usr/local/bin/sms2.sh sms 00611234567890 "$*" &

Code:
root@server420:/home/user # cat /usr/local/bin/sms2.sh

#!/bin/sh


sleep $(jot -r 1  5 25)




MODEM_IP="192.168.8.1"
/usr/local/bin/curl -s -X GET "http://$MODEM_IP/api/webserver/SesTokInfo" > /tmp/ses_tok.xml
/bin/chmod 777 /tmp/ses_tok.xml
COOKIE=`grep "SesInfo" /tmp/ses_tok.xml | cut -b 58-185`
TOKEN=`grep "TokInfo" /tmp/ses_tok.xml | cut -b 205-236`

if [ "$1" = "stop" ]; then
/usr/local/bin/curl -s -X POST -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-type: text/xml" -d "<response><dataswitch>0</dataswitch></response>" http://$MODEM_IP/api/dialup/mobile-dataswitch > /dev/null 2>&1

elif [ "$1" = "start" ]; then
/usr/local/bin/curl -s -X POST -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-type: text/xml" -d "<response><dataswitch>1</dataswitch></response>" http://$MODEM_IP/api/dialup/mobile-dataswitch > /dev/null 2>&1

elif [ "$1" = "status" ]; then
/usr/local/bin/curl -s -X POST -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-type: text/xml" -d "1" http://$MODEM_IP/api/device/mode > /dev/null 2>&1



elif [ "$1" = "restart" ]; then
/usr/local/bin/curl -s -X POST -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-type: text/xml" -d "<?xml version="1.0" encoding="UTF-8"?><request><Control>1</Control></request>" http://$MODEM_IP/api/device/control > /dev/null 2>&1

elif [ "$1" = "sms" ]; then
/usr/local/bin/curl -v http://$MODEM_IP/api/sms/send-sms -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8"  --data "<?xml version='1.0' encoding='UTF-8'?><request><Index>-1</Index><Phones><Phone>$2</Phone></Phones><Sca></Sca><Content>$3</Content><Length>160</Length><Reserved>1</Reserved><Date>-1</Date></request>"

elif [ "$1" = "read" ]; then
curl -s -X POST "http://$MODEM_IP/api/sms/sms-list" -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: text/xml" -d "<request><PageIndex>1</PageIndex><ReadCount>10</ReadCount><BoxType>1</BoxType><SortType>0</SortType><Ascending>0</Ascending><UnreadPreferred>1</UnreadPreferred></request>" > /tmp/modem_status.xml
message=$(grep -r -E 'Phone|Content' /tmp/modem_status.xml | sed -e 's/<[^>]*>//g' | sed -e 's/^[ \t]*/------\n/g')
echo "$message\n------"

elif [ "$1" = "rssi" ]; then
curl -s -X GET "http://$MODEM_IP/api/device/information" -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: text/xml" > modem_status.xml
curl -s -X GET "http://$MODEM_IP/api/device/signal" -H "Cookie: $COOKIE" -H "__RequestVerificationToken: $TOKEN" -H "Content-Type: text/xml" >> modem_status.xml
wmode=$(cat modem_status.xml | grep workmode | sed -e 's/<[^>]*>//g')
rssi=$(cat modem_status.xml | grep rssi | sed -e 's/<[^>]*>//g')
echo "mode: $wmode"
echo "signal: $rssi"

fi
 
I remember I had the no-carrier status until I run the first script in my reply above.

I think starting FreeBSD 14 the modem switches mode auto, but still needed to run the above script. I didn't have time to modify any part of the above scripts as it just works anyway.
 
I remember I had the no-carrier status until I run the first script in my reply above.

I think starting FreeBSD 14 the modem switches mode auto, but still needed to run the above script. I didn't have time to modify any part of the above scripts as it just works anyway.
You may have needed to run modeswitch to modify your dongle. Apparently there are two versions, hilink and stick.

I was told on another forum that I didn't need to run modeswitch and I managed to access the Internet without doing so.

I'd be interested to know which mode your dongle is in. Mine is defined as a modem/networkcard rather than as a storage device.
 
Back
Top