- Edited
Hello there,
I want to share my solution to connect Bela to a Linux computer.
My host computer detected the Bela network adapter when plugged in via USB.
However, it did not automatically get an IP address assigned.
In the past I used sudo dhclient enxbe1aXXXXXXXX
to retrieve an IP adress for the adapter. I needed to do this every time I rebooted bela or my computer.
Setting up DHCP
Here is a solution to automatically setup a DHCP connection on Linux (I'm running Kubuntu 23.04).
sudo nano /etc/netplan/config.yaml
network:
version: 2
renderer: networkd
ethernets:
all:
match:
name: enxbe1a*
dhcp4: true
sudo chmod 600 /etc/netplan/config.yaml
sudo chmod 600 /etc/netplan/01-network-manager-all.yaml
sudo netplan apply
This should set up DHCP automatically once your bela device connects.
Internet Sharing
For sharing the internet connection of the host computer, you can create the following two files:
internetToTargetOnHost.sh
#!/bin/sh
sudo iptables --table nat --append POSTROUTING --out-interface enxXXXXXXXXXXXX -j MASQUERADE
sudo iptables --append FORWARD --in-interface enxbe1aXXXXXXXX -j ACCEPT
sudo iptables --append FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
internetToTargetOnTarget.sh
#!/bin/sh
ip route add default via 192.168.7.1
echo nameserver 8.8.8.8 | tee -a /etc/resolv.conf
Replace enxXXXXXXXXXXXX
with your host interface that connects you to the internet and replace enxbe1aXXXXXXXX
with the bela ethernet device. You can list your ethernet devices with the ip address
command. Run internetToTargetOnHost.sh
on the host computer and internetToTargetOnTarget.sh
on the Bela device.
For further debugging refer to this excellent write up about connecting the beagle bone to the host computer.
But realize that some of the steps only work on older linux systems that do not use netplan
and network-manager
yet.
Greetings, Clemens