How to hook an Ethernet over USB connection up to the host-Network

arch-linuxinterfacelinux-networkingnetworkingusb

I have a single board computer that I want to hook up to my lan/internet connection. The SBC doesn't have an Ethernet port, only a an embedded wireless chip which currently isn't working. But it does have USB and I figured that it should be possible to connect it via ethernet over USB to my workstation and then do some kind of bridging/forwarding. I'm using a Beagle Bone Black Wireless and (currently) Arch Linux ARM am33x for the "client". Workstation is Fedora 23. The ethernet over USB is working, i can SSH into the SBC. However I didn't manage to get from the SBC to my local network or Internet.

A list of things I already tried:

Exhibit a:

This allows me to SSH into the client.

Configuration/Commands on the Client:

modprobe g_ether

netctl configuration:

Description='USB ethernet connection'

Interface=usb0

Connection=ethernet

IP=static

Address=('192.168.7.2/24')

DNS=('8.8.8.8')

#Gateway=('192.168.1.1')

## For IPv6 autoconfiguration

IP6=stateless

Configuration on the workstation:

ifconfig enp0s29u1u2 192.168.7.1

Exhibit b:

I tired this to connect the two interfaces (enp0s29u1u2 is the Eth over usb side interface and enp6s0 faces my local network and also the internet); the following code is executed on the Workstation.
I found this here: Routing between two networks on linux?

echo 1 >> /proc/sys/net/ipv4/ip_forward
iptables -A INPUT -i lo -j ACCEPT
iptables -A INPUT -i enp0s29u1u2 -j ACCEPT
iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A POSTROUTING -o enp6s0 -j MASQUERADE
iptables --append FORWARD -i enp6s0 -o enp0s29u1u2 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables --append FORWARD -i enp0s29u1u2 -o enp6s0 -j ACCEPT       

First I left the IP addresses as they were 192.168.1.0/24 for the Lan and 192.168.7.0/24 for the Ethernet over USB network. But I couldn't reach my gateway or anything beneath my workstation. I also tried to give the Beagle Bone an 192.168.1.* address which also didn't help. I'm probably missing something here. Routing maybe?

Exhibit c:

I also tried to set up a bridge between the interfaces.

Netctl config on beaglebone was set to something like this:

Description='USB ethernet connection'

Interface=usb0

Connection=ethernet

IP=static

Address=('192.168.1.210/24')

DNS=('8.8.8.8')

Gateway=('192.168.1.1')

## For IPv6 autoconfiguration

IP6=stateless

Commands(Workstation):

brctl addbr br0
brctl addif br0 enp6s0 enp0s29u1u2
ifconfig br0 192.168.1.202 (or some random free address)

I had to do route add default gw 192.168.1.1 in order to regain Internet access on my workstation. I also did it on the beaglebone, but it also didn't
work out. I'm not sure but as im understanding the network bridge it should behave like i just hooked up the device to an ethernet switch(i.e. the members of the network can communicate as if the bridge wasn't there; but it apparently needs a seperate ip so i'm a bit confused, please give me a hint).

Core Question:

Is there some manual routing required to integrate the Beaglebone in the lan and get internet access or something else maybe? Thank you for any hints! Hackarounds are also apprectiated as i'm looking for a temporal solution.

Best Answer

You have echo 1 >> /proc/sys/net/ipv4/ip_forward

But it should be echo 1 > /proc/sys/net/ipv4/ip_forward

Gateway is commented out #Gateway=('192.168.1.1') in one of your options.

You would need to do ip route add default via 192.168.1.1 on the single board computer so it knows where to send internet traffic. (Where 192.168.1.1 is the IP of the device with ip_forward turned on.)