USB tethering (from Android) to GhostBSD?

Help with setting up network cards, including WiFi cards.
numericalanalysis
Posts: 6
Joined: Fri Jul 10, 2015 8:30 am

USB tethering (from Android) to GhostBSD?

Post by numericalanalysis »

Hello,
Has someone managed to connect an Android phone as a modem USB? ("tethering")

(Because some issues with GhostBSD I am meanwhile on PC-BSD, where I tried many options (kldload if_cdce or if_rndis) but with no results. I would reinstall GhostBSD in place of an old Windows, but I am now wondering if it will not be too difficult to manage internet connection, because I often use the 3G connection from my mobile phone.)

All idea would be welcome. Thank you.
User avatar
bsdkeith
Posts: 129
Joined: Wed Jun 12, 2013 3:36 pm
Location: Surrey/Hants Border, England

Re: USB tethering (from Android) to GhostBSD?

Post by bsdkeith »

Maybe these threads on the FreeBSD Forum can help.
https://forums.freebsd.org/search/50059 ... ing&o=date
Linux user since 1999; & now a BSD user.
tankist02
Posts: 15
Joined: Wed Sep 04, 2013 5:46 pm

Re: USB tethering (from Android) to GhostBSD?

Post by tankist02 »

Last time I tried to connect my Nexus 7 to FreeBSD 10 STABLE it didn't work - device was not recognized. BTW modern Android uses MTP protocol to connect via USB cable.
numericalanalysis
Posts: 6
Joined: Fri Jul 10, 2015 8:30 am

Re: USB tethering (from Android) to GhostBSD?

Post by numericalanalysis »

Thank you for replies ;)

@bsdkeith: Yes I have read these threads but I have not found something that works (I am a novice, too)... :roll:
@tankist02: Maybe, but my Android is old (Gingerbread) and I read on Wikipedia that only since version 3.1 it uses MTP.
seancox
Posts: 1
Joined: Wed Dec 06, 2017 4:53 am

Re: USB tethering (from Android) to GhostBSD?

Post by seancox »

still have not found something that works
_____________
192.168.0.1
wb7odyfred
Posts: 207
Joined: Sat Nov 12, 2016 5:44 pm

Re: USB tethering (from Android) to GhostBSD?

Post by wb7odyfred »

USB Tethering with Android, Here is a good article with explicit instructions:
https://www.adminbyaccident.com/freebsd ... -usb-port/

urndis -- USB Remote NDIS Ethernet device

Short Steps:

Code: Select all

ifconfig
kldstat
kldload if_urndis            # load kernel module  if_urndis
kldstat | grep if_urndis   # check if it loaded 
ifconfig ue0 up
dhclient ue0
ping -c 3 8.8.4.4
ping -c 3 ghostbsd.org
ping -c 3 he.net
netstat -r
sockstat -4
kldstat check what kernel modules are already loaded
kldload kernel module if_urndis.ko
Grep for "if_urndis" in kernel modules list to see if it loaded
## Do we need to create to execute or is automatic "ifconfig wlan0 create wlandev ue0"
turn on network device ue0 if ue0 up
fill IP values with dhclient ue0
See if we connected to Internet and can ping other IP values

Ping a DNS number 192.168.1.1 or google 8.8.4.4 or ghostbsd.org or he.net Hurricane Electric dot NET
Network Statistics routing
Socket Statistics IP4

Other helpful commands:

Code: Select all

killall dhclient
killall dhcpcd
service netif restart
service network restart
ifconfig ue0 up
dhcpcd ue0
I think dhclient is better suited than dhcpcd for networking. YMMV
I don't believe the ifconfig ue0 create wlandev urndis0 is needed at all. Should delete.





More networking examples to bring up a device and test network:
https://forums.ghostbsd.org/viewtopic.php?f=64&t=526 Edimax EW-7811un USB nano dongle wifi setup
https://forums.ghostbsd.org/viewtopic.php?f=64&t=570 RTL8188CE pci wifi card
https://cyber.dabamos.de/unix/tethering/ USB Tethering example for FreeBSD with Android
Add the kernel module to /etc/rc.conf in order to load the driver while booting:

kld_list+="if_urndis"

Connect the Android phone to the Laptop using a USB cable. Make sure that WiFi and USB tethering are enabled on the phone. A new network interface ue0 will be created once the device is connected:
FreeBSD manuals:
https://www.freebsd.org/doc/en_US.ISO88 ... ering.html USB Tethering
https://www.freebsd.org/cgi/man.cgi?que ... ease-ports URNDIS

http://netbsd.2816.n7.nabble.com/USB-te ... ml#a402727
tl;dr - just enable dhcpcd in rc.conf without any specific interface

You can treat it as a normal non wired network interface and either
run 'dhcpcd urndis0' or just have dhcpcd running and let it pick it up
automatically.
If you have wifi and urndis0 both active dhcpcd will prefer the
"wired" one (urndis0), which is typically the behaviour you want.

I've been tethering NetBSD from android phones seemingly ~forever and
its been a life saver. Sometimes I find a public wifi that my NetBSD
laptop does not like, and I can just connect to it on my phone, then
USB tether to the laptop (which also charges :)

David
wb7odyfred
Posts: 207
Joined: Sat Nov 12, 2016 5:44 pm

Re: USB tethering (from Android) to GhostBSD?

Post by wb7odyfred »

wb7odyfred wrote: Sat Apr 04, 2020 5:21 pm USB Tethering with Android, Here is a good article with explicit instructions:
https://www.adminbyaccident.com/freebsd ... -usb-port/

urndis -- USB Remote NDIS Ethernet device
First turn on phone, connect to computer, enable Hotspot and Tethering, enable Data on phone :D
  1. connect the mobile phone to your computer
  2. activate USB tethering in settings -> Wireless and network -> More Settings -> portable hotspot and tethering -> USB tethering
  3. With the NetworkManager identified the mobile phone as network connection and you are ready to go
Short Steps:

Code: Select all

ifconfig
kldstat
kldload if_urndis            # load kernel module  if_urndis
kldstat | grep if_urndis   # check if it loaded 
ifconfig ue0 up
dhclient ue0
ping -c 3 8.8.4.4
ping -c 3 ghostbsd.org
ping -c 3 he.net
netstat -r
sockstat -4
kldstat check what kernel modules are already loaded
kldload kernel module if_urndis.ko
Grep for "if_urndis" in kernel modules list to see if it loaded
## Do we need to create to execute or is automatic "ifconfig wlan0 create wlandev ue0"
turn on network device ue0 if ue0 up
fill IP values with dhclient ue0
See if we connected to Internet and can ping other IP values

Ping a DNS number 192.168.1.1 or google 8.8.4.4 or ghostbsd.org or he.net Hurricane Electric dot NET
Network Statistics routing
Socket Statistics IP4

Other helpful commands:

Code: Select all

killall dhclient
killall dhcpcd
service netif restart
service network restart
ifconfig ue0 up
dhcpcd ue0
I think dhclient is better suited than dhcpcd for networking. YMMV
I don't believe the ifconfig ue0 create wlandev urndis0 is needed at all. Should delete.





More networking examples to bring up a device and test network:
https://forums.ghostbsd.org/viewtopic.php?f=64&t=526 Edimax EW-7811un USB nano dongle wifi setup
https://forums.ghostbsd.org/viewtopic.php?f=64&t=570 RTL8188CE pci wifi card
https://cyber.dabamos.de/unix/tethering/ USB Tethering example for FreeBSD with Android
Add the kernel module to /etc/rc.conf in order to load the driver while booting:

kld_list+="if_urndis"

Connect the Android phone to the Laptop using a USB cable. Make sure that WiFi and USB tethering are enabled on the phone. A new network interface ue0 will be created once the device is connected:
FreeBSD manuals:
https://www.freebsd.org/doc/en_US.ISO88 ... ering.html USB Tethering
https://www.freebsd.org/cgi/man.cgi?que ... ease-ports URNDIS

http://netbsd.2816.n7.nabble.com/USB-te ... ml#a402727
tl;dr - just enable dhcpcd in rc.conf without any specific interface

You can treat it as a normal non wired network interface and either
run 'dhcpcd urndis0' or just have dhcpcd running and let it pick it up
automatically.
If you have wifi and urndis0 both active dhcpcd will prefer the
"wired" one (urndis0), which is typically the behaviour you want.

I've been tethering NetBSD from android phones seemingly ~forever and
its been a life saver. Sometimes I find a public wifi that my NetBSD
laptop does not like, and I can just connect to it on my phone, then
USB tether to the laptop (which also charges :)

David

iPhone Tethering requires use of ipheth from FreeBSD Handbook settings

Apple® devices use the ipheth(4) driver.
wb7odyfred
Posts: 207
Joined: Sat Nov 12, 2016 5:44 pm

Re: USB tethering (from Android) to GhostBSD?

Post by wb7odyfred »

https://cyber.dabamos.de/unix/tethering/ Using USB Tethering on FreeBSD with Android
Be sure the usb cable supports date transfers and is not JUST A CHARGING cable.
wb7odyfred
Posts: 207
Joined: Sat Nov 12, 2016 5:44 pm

Re: USB tethering (from Android) to GhostBSD?

Post by wb7odyfred »

wb7odyfred wrote: Tue Jun 09, 2020 1:10 am https://cyber.dabamos.de/unix/tethering/ Using USB Tethering on FreeBSD with Android
Be sure the usb cable supports data transfers and is not JUST A CHARGING cable.
zazlox
Posts: 6
Joined: Mon May 22, 2023 5:42 pm

Re: USB tethering (from Android) to GhostBSD?

Post by zazlox »

My go on connecting Samsung J5 android with Ghostbsd.

First you do need to know how to setup usb tethering in your phone. but dont hook it yet.
lets load some module first.

Code: Select all

su -
kldload if_urndis if_cdce if_ipheth
I am pretty sure. you dont need to load if_urndis module. but lets leave there anyway.

now hook your phone with usb tethering option enabled.
You will see something similar to this or a bit close :)

Code: Select all

ugen0.2: <SAMSUNG SAMSUNGAndroid> at usbus0 (disconnected)
umodem0: at uhub0, port 5, addr 6 (disconnected)
umodem0: detached
ugen0.2: <SAMSUNG SAMSUNGAndroid> at usbus0
urndis0 on uhub0
urndis0: <RNDIS Communications Control> on usbus0
ue0: <USB Ethernet> on urndis0
ue0: Ethernet address: 02:51:0a:04:62:64
Now let-s try to connect it :

Code: Select all

sudo dhclient ue0
if all went well . you will see something like this at the end of the output :

Code: Select all

bound to 192.168.XX.XXX -- renewal in 1800 seconds.


even the icon of network will change to two big arrow. it means . you are connected.

Here is a simple script to put all these commands together :

Code: Select all

#!/usr/local/bin/bash
# coding:utf-8

sudo kldload if_urndis if_cdce if_ipheth

sudo dhclient ue0
Just give it X permission and run it like :

Code: Select all

sudo ./usbTethering
name it whatever you want. in my case. its usbTethering.
That's it. Keep it up :)
Post Reply