Connect to Internet without WiFi dongle

Hi,

The PB2 manual is missing some details how to connect PB2 to Internet via USB cable connection. So here is a quick guide.
Prerequisites:

  • PB2 with Linux installed.
  • “Host“ machine which PB2 connected to
  • Gateway (a router which shares Internet to host machine)

On PB2:

  • configure default gateway sudo ip route add default via 192.168.7.1 dev usb0 (running pb2-internet.sh is not needed)
  • configure DNS. For example, if system is Debian Linux, edit /etc/systemd/resolved.conf and uncomment/add line DNS=8.8.8.8 (or any DNS IP you like)

On host machine:

  • turn on IP forwarding. On Windows set registry key HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\IPEnableRouter to 1 and reboot; On Linux run command sudo sysctl -w net.ipv4.ip_forward=1

On gateway router:

  • determine host machine IP; make this IP address static if DHCP is using
  • add static route to 192.168.7.0/24 via host machine IP

That’s it

Thanks Maxim.

Have you tried bb-imager-rs with the pocket Beagle? On my Beagle Black I was able to shelve my internet connection scripts and playbook (that both copy in a new usb0.network), by simply ticking the “Enable DHCP” option in the configuration when flashing the latest Debian image. Then I just need to unshare and reshare the internet connection in Windows, the first time I’ve booted up.

Ayush has been doing a fantastic job.

I’m so glad that actually works for someone! We enabled it to try it, and most users said it didn’t work… Not sure if fully make it workable on every board.

Regards,

1 Like

Cheers - I’ll keep that in mind. Suffice to say you’ve been doing a fantastic job too yourself.

I just double checked, and I’m pretty sure it does work. I flashed an SD card without that option, and there was no network access (even after the waiting the minute or so). Out of interest, does “Enable USB DHCP” do anything else, other than replace:

/etc/systemd/network/usb0.network

[Match]
Name=usb0

[Link]
RequiredForOnline=no

[Network]
DHCP=no
Address=192.168.7.2/24
DHCPServer=on

[DHCPServer]
EmitDNS=no
EmitRouter=no
EmitTimezone=no
MaxLeaseTimeSec=20min
PoolSize=1

with ?:
/etc/systemd/network/usb0.network

[Match]
Name=usb0

[Link]
RequiredForOnline=no

[Network]
DHCP=ipv4

This was the BBB Debian 13 v6.18.x LTS Dec 2027 image (Trixie).

Exactly, that’s all it does…

cp: Making sure you're not a bot!

system("cp /etc/bbb.io/templates/usb0-DHCP.network /etc/systemd/network/usb0.network");

So even on older images, that’s all you have to change..

Regards,

1 Like

Hi James

Yes, I have tried bb-Imager by Ayush v. 0.0.17 to write image (PB2 Debian 13 v6.12 IoT) with USB DHCP option turned ON. Unfortunately I didn’t manage to make network over USB working (at all, not only Internet access). The PB2 board can’t get IP from Windows machine.

max@PocketBeagle2:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute
       valid_lft forever preferred_lft forever
2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 6e:4d:8e:cc:9e:ec brd ff:ff:ff:ff:ff:ff
3: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 04:47:07:2d:9f:ee brd ff:ff:ff:ff:ff:ff
    inet6 fe80::647:7ff:fe2d:9fee/64 scope link proto kernel_ll
       valid_lft forever preferred_lft forever

max@PocketBeagle2:~$ journalctl | grep -Ei 'dhcp|dhclient|NetworkManager'
Dec 02 16:52:05 PocketBeagle2 bbbio-set-sysconf[764]: USB: Enable DHCP for USB
Dec 02 16:52:05 PocketBeagle2 bbbio-set-sysconf[765]: USB: Enable DHCP for USB

On Windows:

Connection-specific DNS Suffix: 
Description: UsbNcm Host Device
Physical Address: ‎04-47-07-2D-9F-ED
DHCP Enabled: Yes
Autoconfiguration IPv4 Address: 169.254.41.18
IPv4 Subnet Mask: 255.255.0.0
IPv4 Default Gateway: 
IPv4 DNS Server: 
IPv4 WINS Server: 
NetBIOS over Tcpip Enabled: Yes
Link-local IPv6 Address: fe80::3a57:c00e:f28f:b0e6%35
IPv6 Default Gateway: 
IPv6 DNS Servers: fec0:0:0:ffff::1%1, fec0:0:0:ffff::2%1, fec0:0:0:ffff::3%1

Turning option “Internet Connection Sharing“ on takes no effect.

If you have any advise please share.

Meanwhile, with USB DHCP off, it works as usual (assign static IP 172.16.7.2 to the board)

Regards,
Maxim

try:

sudo cp /etc/bbb.io/templates/usb0-DHCP.network /etc/systemd/network/usb0.network

Regards,

Hi Robert

No, the same result (no IP).

Seems DHCP client on PB2 is not running by default even if option USB DHCP is on

max@PocketBeagle2:~$ sudo dhcpcd -T usb0
dhcpcd-10.1.0 starting
DUID 00:01:00:01:30:c1:e2:33:04:47:07:2d:9f:ee
[ 89.214535] 8021q: 802.1Q VLAN Support v1.8
usb0: IAID 07:2d:9f:ee
usb0: soliciting an IPv6 router
usb0: soliciting a DHCP lease
usb0: probing for an IPv4LL address
usb0: using IPv4LL address 169.254.108.137
interface=‘usb0’
pid=‘672’
protocol=‘ipv4ll’
reason=‘TEST’
ifcarrier=‘up’
ifflags=‘69699’
ifmetric=‘1003’
ifmtu=‘1500’
ifwireless=‘0’
new_broadcast_address=‘169.254.255.255’
new_ip_address=‘169.254.108.137’
new_network_number=‘169.254.0.0’
new_subnet_cidr=‘16’
new_subnet_mask=‘255.255.0.0’
dhcpcd exited
max@PocketBeagle2:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host noprefixroute
valid_lft forever preferred_lft forever
2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 6e:4d:8e:cc:9e:ec brd ff:ff:ff:ff:ff:ff
3: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 04:47:07:2d:9f:ee brd ff:ff:ff:ff:ff:ff
inet 169.254.108.137/16 brd 169.254.255.255 scope global noprefixroute usb0
valid_lft forever preferred_lft forever
inet6 fe80::647:7ff:fe2d:9fee/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever

After command dhcpcd -T usb0 IP address is assigned, but there are no DHCP options like default routing and gateway, so network is still not available.

And it’s not clear how to figure out which IP Windows assign to PB2 without debug serial console.

Hi Maxim. Sorry to hear that. Other than noting that it can take 2 or 3 minutes before I can ping something in the wild from the Beagle, after turning on Internet Connection Sharing on my main wifi connection in Windows, I’ve got no further ideas unfortunately. I’m on Windows 11