Letux Kernel

EthernetGadget

You are looking at an old revision of the page EthernetGadget. This revision was created by Andreas Kemnade.

Table of Content

using Ethernet Gadget to do IP connection and forwarding over USB cable

Ethernet gadget

The Ethernet gadget is a kernel driver on the Letux device to allow to access the Letux device throug IP although it is connected throug an USB cable to some host computer.

Scenarios

  • ssh from host into Letux device
  • ssh from Letux device to the host
  • Internet access from Letux device through the host's WLAN connection
  • Internet access from the host through the Letux device (tethering)

Setup on Letux device

If you use our Debian Rootfs everything is set up. There is an usb0 interface (see ifconfig). The IP address of the device is 192.168.0.202. And DNS is set up.

Setup on a Linux Host

configure network

ifconfig usb0 192.168.0.200 up

share your internet connection

on the device which should share the connection:

translate the local addresses on your outgoing interface:

iptables -t nat -A POSTROUTING -o -j MASQUERADE

enable packet forwarding for all interfaces (check if this might cause security problems in your setup):

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

Setup on Mac OS X (El Capitan)

RNDIS/Gadget Driver

Apple provides a compatible driver but it must be configured:

  1. boot the device
  2. plug in the cable to the Mac
  3. open System Preferences / Networking
  4. an RNDIS/Ethernet Gadget interface appears
  5. select it
  6. choose

    IPv4 configuration: Manual IP Address: 192.168.0.200 Subnet: 255.255.255.0 Router: 192.168.0.200 Apply

Now you should be able to ping.

a) on the device: ping 192.168.0.200 b) on the Mac: ping 192.168.0.202

If that works, you can ssh in both directions. The devices are set up with root enabled, so do:

ssh root@192.168.0.202

IP forwarding

If you want to share the Internet connection of your Mac (e.g. WLAN) to the Letux device (so that you can e.g. apt-get install something), the standard Internet Sharing does not work.

  1. Open Internet Sharing in System Preferences and make sure that Internet Sharing does not try to share the RNDIS/Ethernet Gadget
  2. run these commands (e.g. from a shell script):

    internet=en1 # WLAN vom Mac device=192.168.0.202 # Device connected through USB over RNDIS-driver (local IP 192.168.0.200, remote IP 192.168.0.202) echo "nat log on $internet from $device to any -> ($internet)" | sudo pfctl -N -f - -e sudo sysctl -w net.inet.ip.forwarding=1 sudo sysctl -w net.inet.ip.fw.enable=1

Now your Letux device should be able to ping 8.8.8.8 (google) and apt-get update.

Tehering

means that you enable WWAN on your Letux device and route all internet access of your Mac through that connection.

... to be described ...

Created: 8 years 2 months ago
by Nikolaus Schaller

Updated: 8 years 2 months ago
by Andreas Kemnade

Old Revisions