internet over USB for BBB rev c1

Hi i want to share my laptops internet to beaglebone black over usb.
i had done all the necessary sharing steps from my windows networking pannel and read all the articles of doing the same online.
i have booted the eMMC with the Latest image from https://forum.beagleboard.org/tag/latest-images .
i am getting the following result.

debian@beaglebone:~$ echo “nameserver 8.8.8.8”>>/etc/resolv.conf
-bash: /etc/resolv.conf: Permission denied
debian@beaglebone:~$ sudo /sbin/route add default gw 192.168.7.1
SIOCADDRT: File exists
debian@beaglebone:~$ ifconfig
eth0: flags=-28669<UP,BROADCAST,MULTICAST,DYNAMIC> mtu 1500
ether 30:e2:83:e0:6b:f4 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 55

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 11258 bytes 755188 (737.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 11258 bytes 755188 (737.4 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

usb0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.7.2 netmask 255.255.255.252 broadcast 192.168.7.3
inet6 fe80::32e2:83ff:fee0:6bf6 prefixlen 64 scopeid 0x20
ether 30:e2:83:e0:6b:f6 txqueuelen 1000 (Ethernet)
RX packets 3378 bytes 460942 (450.1 KiB)
RX errors 0 dropped 8 overruns 0 frame 0
TX packets 1866 bytes 366153 (357.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

usb1: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.6.2 netmask 255.255.255.0 broadcast 192.168.6.255
ether 30:e2:83:e0:6b:fa txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

i also tried command: sudo nano /etc/network/interfaces

and added these:

iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.252
network 192.168.7.0
gateway 192.168.7.1
dns-nameservers 8.8.8.8
post-up route add default gw 192.168.7.1
but nothing happened .
what should be the next steps in order to gain the assess of internet

It is much easier to use ethernet, that works without all the headaches.

Also, your subnet mask might be too restrictive. Unless you have to limit traffic, 255.255.255.0 is a good starting point.

On your target

$ ip route

See what is going on.

if you are using connman (likely), you might have a conflict with the interfaces file.
try to see if connman is running:
debian@bbb42:~$ ps -ef | grep connman
root 1035 1 0 Feb27 ? 00:00:00 /usr/sbin/connmand -n --nodnsproxy
debian 3645 26949 0 11:36 pts/0 00:00:00 grep connman
debian@bbb42:~$

you didn’t mention if you could ping in one or both directions, please check that

I’m trusting that you have set up your windows machine to forward packets (outside my sphere of knowledge)

you show that you TRIED to update /etc/resolv.conf … FAIL (and also would get clobbered by connman).

show output of
debian@bbb42:~$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.11.1 0.0.0.0 UG 0 0 0 eth0
192.168.6.0 0.0.0.0 255.255.255.252 U 0 0 0 usb1
192.168.7.0 0.0.0.0 255.255.255.252 U 0 0 0 usb0
192.168.11.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.11.1 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
207.58.129.219 192.168.11.1 255.255.255.255 UGH 0 0 0 eth0
debian@bbb42:~$

netmask if fine for point to point link.

good luck
gomer

hi gomer

yes i am using connman and the connman is running fine

debian@beaglebone:~$ systemctl status connman.services
Unit connman.services.service could not be found.
debian@beaglebone:~$ systemctl status connman.service
● connman.service - Connection service
Loaded: loaded (/lib/systemd/system/connman.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2020-04-06 18:23:59 UTC; 9min ago
Main PID: 772 (connmand)
Tasks: 1 (limit: 1027)
Memory: 5.5M
CGroup: /system.slice/connman.service
└─772 /usr/sbin/connmand -n --nodnsproxy

Apr 06 18:25:43 beaglebone connmand[772]: Ignoring interface usb0 (filtered)
Apr 06 18:25:55 beaglebone connmand[772]: usb0 {add} address 192.168.7.2/24 label usb0 family 2
Apr 06 18:25:55 beaglebone connmand[772]: usb0 {add} route 192.168.7.0 gw 0.0.0.0 scope 253
Apr 06 18:25:55 beaglebone connmand[772]: usb0 {add} route 0.0.0.0 gw 0.0.0.0 scope 0
Apr 06 18:26:05 beaglebone connmand[772]: usb1 {add} address 192.168.6.2/24 label usb1 family 2
Apr 06 18:26:05 beaglebone connmand[772]: usb1 {update} flags 4099
Apr 06 18:26:05 beaglebone connmand[772]: usb1 {newlink} index 6 address 30:E2:83:E0:6B:FA mtu 1500
Apr 06 18:26:05 beaglebone connmand[772]: usb1 {newlink} index 6 operstate 2
Apr 06 18:26:05 beaglebone connmand[772]: Ignoring interface usb1 (filtered)
Apr 06 18:26:05 beaglebone connmand[772]: usb1 {add} route 192.168.6.0 gw 0.0.0.0 scope 253
and i can also communicate both ways as my beagle can ping the laptop and laptop can ping BBB

i have also configured the adapter settings and set up my wifi to share internet to BBB and set BBB to 192.168.7.1 and subnet mask appeared automatically as 255.255.255.0

some internet manual suggested me to add
auto usb0
iface usb0 inet dhcp
gateway 192.168.7.1

to /etc/network/interfaces.
under primary interfaces , but the strange part was usb0 was not mentioned earlier. will it effect in any matter?

my /etc/network/interfaces reads as:

This file describes the network interfaces available on your system
and how to activate them. For more information, see interfaces(5).
The loopback network interface
auto lo
iface lo inet loopback

The primary network interface
#auto eth0
#iface eth0 inet dhcp

Example to keep MAC address between reboots
#hwaddress ether DE:AD:BE:EF:CA:FE
auto usb0
iface usb0 inet dhcp
gateway 192.168.7.1
##connman: ethX static config
#connmanctl services
#Using the appropriate ethernet service, tell connman to setup a static IP address for that service:
#sudo connmanctl config --ipv4 manual <ip_addr> --nameservers <dns_server>

##connman: WiFi

#connmanctl
#connmanctl> tether wifi off
#connmanctl> enable wifi
#connmanctl> scan wifi
#connmanctl> services
#connmanctl> agent on
#connmanctl> connect wifi_*_managed_psk
#connmanctl> quit

just cant connect internet via usb

If the BBB USB end is 192.168.72 and the Windows end is 192.168.7.1 and you can ping 192.168.7.1 from the BBB then the your BBB is probably setup correctly.

You need to check that the default gateway on the BBB is 192.168.7.1, and you will need something in resolv.conf for DNS.

If you can’t ping 8.8.8.8 from the BBB and your default gateway is set correctly then the issue is with Windows ICS. So many people seem to have problems with it.

Don’t know if this would help https://paulbupejr.com/beaglebone-black-internet-over-usb/

perhaps you missed my request for the output of ‘route -n’…

also, if you want to use usb for internet access, why are you messing with wifi in connman?

you didn’t report what image you are using… the output of ‘cat /etc/dogtag’ would be helpful, as would the output of ‘uname -a’

connman is not your friend in this configuration, it will interfere more often than it assists… I THINK that the ‘gadget’ for usb 192.168.7.1 is automatically put in your /etc/network/interfaces file…

most important is the output from ‘route -n’…

secondarily, that you configured your laptop to forward packets.

good luck
gomer

sorry … i misread and misunderstood about wifi… i see now that they are comments.

here is a snip from my interfaces file for the gadget:

Ethernet/RNDIS gadget (g_ether)

Used by: /opt/scripts/boot/autoconfigure_usb0.sh

iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.252
network 192.168.7.0
gateway 192.168.7.1

you can see that it is NOT set up as dhcp, but as static (which is correct)

I’ve done what you are trying to do, but only with Ubuntu (laptop)… unable to assist with windows.

gomer

hi
the link you shared mentions that /etc/networks/interfaces must contain
#Ethernet/RNDIS gadget(g_ether)
#Used by: /opt/scripts/boot/autoconfigure_usb0.sh
iface usb0 inet static
address: 192.168.7.2
netmask: 255.255.255.252
network:192.168.7.0
gateway:192.168.7.1
dns-nameservers: 8.8.8.8
post-up route add default gw 192.168.7.1

but my /etc/networks/interfaces does not contain any of these . the contents are ;

#This file describes the network interfaces available on your system
#and how to activate them. For more information, see interfaces(5).

#The loopback network interface
auto lo
iface lo inet loopback

#The primary network interface
#auto eth0
#iface eth0 inet dhcp

#Example to keep MAC address between reboots
#hwaddress ether DE:AD:BE:EF:CA:FE
##connman: ethX static config
#connmanctl services
#Using the appropriate ethernet service, tell connman to setup a static IP addr$
#sudo connmanctl config --ipv4 manual <ip_addr> -$
##connman: WiFi

#connmanctl
#connmanctl> tether wifi off
#connmanctl> enable wifi
#connmanctl> scan wifi
#connmanctl> services
#connmanctl> agent on
#connmanctl> connect wifi_*_managed_psk
#connmanctl> quit

so modifying it didn’t do me any good i think i am somewhere near but yet far and also my resolv.conf just contains ‘nameserver 8.8.8.8’ i had tried modifying that to but it shows access denied to modify resolv.conf

my route-n looks like this
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 usb0
192.168.6.0 0.0.0.0 255.255.255.0 U 0 0 0 usb1
192.168.7.0 0.0.0.0 255.255.255.0 U 0 0 0 usb0
it seems to be fine i guess .
the main problem is that despite of having the contact both sides i am unable to share the internet .
i have set the windows wifi to


the Ethernet3 is the connection i receive when i connect the beagle bone black.

The trouble with pretty much all articles on the internet is that they become out of date.

The link was mainly for the section on configuring Windows ICS. However it has been many years since I actually had to use Windows, so I wouldn’t know if they were correct.

As far as the BBB is confirmed you need to make sure of a few things.
Run a recent version. Grab an image from here:

https://rcn-ee.com/rootfs/bb.org/testing/

Then make sure these are set correctly.
The IP address of the USB interface
The IP routing
The DNS server.

Regardless of what any articles say, if these are set then you need to do nothing with your BBB. If you are running a recent image these are probably going to be set.

Check first before trying to change anything.

If you have SSH’d into the BBB via the USB cable, then the IP addresses will be fine and you just need to check routing.

To check IP address in a console on the BBB.

debian@BeagleBone:~$ ip -br addr
lo               UNKNOWN        127.0.0.1/8 ::1/128 
eth0             DOWN           
usb0             UP             192.168.7.2/24 fe80::1eba:8cff:fea0:c59b/64 
usb1             UP             192.168.6.2/24 fe80::1eba:8cff:fea0:c59d/64 
can0             DOWN           
can1             DOWN 

USB0 should be set as shown.

The IP addresses for the USB connections are set in

/etc/systemd/network/usb0.network and /etc/systemd/network/usb1.network

But you shouldn’t need to change these.

To check routing.

debian@BeagleBone:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.7.1     0.0.0.0         UG    0      0        0 usb0
192.168.6.0     0.0.0.0         255.255.255.0   U     0      0        0 usb1
192.168.7.0     0.0.0.0         255.255.255.0   U     0      0        0 usb0

Interestingly on my BBB running Debian 11.5 XFCE from 01/11/2022 the default gateway was not set. This may have been something I changed as I always use ethernet on the BBB, but I don’t remember doing so. I usually run the minimal version, and only installed that to test something out.

You can set the default if not set by running:

debian@BeagleBone:~$ sudo route add default gw 192.168.7.1 usb0

You should be able to have this done automatically though.

You need to configure a DNS server for looking up IP address. Unless you are using a vary old system, do not edit /etc/resolv.conf as this is very often automatically generated and any changes you make will get overwritten.

If using systemd, which if you are running an up to date image you should be, you can edit /etc/systemd/resolved.conf

You will see a commented out line #DNS=
Change the line to DNS=8.8.8.8 or another IP of your choice.

If you can ping 192.168.7.1 from the BBB, then everything so far is correct.
I would be surprised if this fails.

If you can’t ping 8.8.8.8 then Windows ICS is not working correctly.

If you have any AV/firewalls configured on Windows, including the built in stuff, check to make sure they are not blocking access.

Beyond that I suggest googling for Windows ICS not working.

Hi

My routing looks like this i donnt know why my usb1 is down and does it make any difference debian@beaglebone:~$ ip -br addr
lo UNKNOWN 127.0.0.1/8 ::1/128
can0 DOWN
can1 DOWN
eth0 DOWN
usb0 UP 192.168.7.2/24 fe80::32e2:83ff:fee0:6bf6/64
usb1 DOWN 192.168.6.2/24

However when i enter /etc/systemd/network/usb1.network is shows no such file or Directory

The default gateway is set and but as soon as i open /etc/resolv.conf an error occurs

[ Error reading lock file /etc/.resolv.conf.swp: Not enough data read ]

i tried opening this via root and via sudo but nothing happened.

Although i was able to open and edit /etc/systemd/resolved.conf and edited the DNS to 8.8.8.8 but still cant ping 8.8.8.8.

My laptop’s firewall is off for the smooth connection but still cant get the internet

You don’t need DNS configured to ping 8.8.8.8 or any IP address for that matter.

If it is failing then the issue is downstream of the BBB, almost certainly Windows.

What is the output of route -n ? You haven’t shown this.

What version of the OS are you running on the BBB ?

debian@BeagleBone:~$ cat /etc/dogtag
BeagleBoard.org Debian Bullseye Minimal Image 2023-03-01

I just update mine to the latest version. The default route is still not set, so not something I changed.