Skip to content
Go to file
Cannot retrieve contributors at this time
426 lines (143 sloc) 8.48 KB

#Recipe Card#

022 : LAN Mode

<th bgcolor=black><font color=white>Recipe Files</th>

<th bgcolor=black><font color=white>Ingredients</th>

          <i><b><a href="">(flavour)_root.txt</a></i></b><p>


<td><i><b><a href=""></a></i></b></td>


  <i><b>Tested: Raspbian</i></b>


WARNING: This recipe also requires the following recipe(s) to be setup on the SD-Card:



#USB Device Mode - LAN#

The Raspberry Pi Model A and Raspberry Pi Zero have the ability to be setup as USB devices (since they are wired directly to the Broadcom processor). This recipe sets up the Raspberry Pi as a Virtual USB LAN Device.

This recipe is based on the hard work of Andrew Mulholland (@gbaman1), DaveB (PiForums) and LadyAda (AdaFruit).

The Adafruit guide ( explains the process.

More information is also available at:

Modules included:

  • Serial (g_serial)

  • Ethernet (g_ether)

  • Mass storage (g_mass_storage)

  • MIDI (g_midi)

  • Audio (g_audio)

  • Mass storage and Serial (g_acm_ms)

  • Ethernet and Serial (g_cdc)

  • Multi (g_multi) Allows you to configure 2 from Ethernet, Mass storage and Serial

##020-usb-device-module recipe##

The general process is as follows:

  1. Get PiZeroCombined.tar.gz module (


  1. Uncompress the kernel module (tar xvzfC $modulesource /tmp/).

  2. Copy boot partition files:

    sudo cp -R /tmp/PiZeroCombined/fat32/* /boot/

  3. Copy module files to root partition:

    sudo cp -R /tmp/PiZeroCombined/ext4/libboot/modules/lib/* /lib/

  4. Remove extracted files:

    sudo rm /tmp/$modulefolder -Rf

##022-usb-lan-mode recipe##

  1. Update the module (Add g_ether to etc/modules).

  2. Add the following to /etc/network/interfaces:

  3. allow-hotplug usb0

iface usb0 inet static






On restart the Raspberry Pi should be detected (by the connected computer) as a Ethernet device.

On the host machine, setup the ethernet connection with the following manual settings:

  • IP Address:

  • Subnet Mask:

  • Default Gateway:

  • No DNS.

###Using network hostnames###

Alternatively (instead of putting a fixed IP) install Bonjour on Windows (already included on Apple Mac) which will allow us to use the Raspberry Pi hostname raspberry.local.

On Pi you may need (probably already installed):

sudo apt-get install avahi-daemon

For MAC support you may also need:

sudo apt-get install netatalk

On Windows either install iTunes (which includes it) or Bonjour Print Services for Windows 2.0.2 (

###Sharing the host computer internet connection###

Connect the Raspberry Pi and

On the host PC, enable ICS (Internet Connection Sharing), as follows:

On windows, this is achieved via the Control Panel > Network and Internet > Network Connections window.

  • Right click on the network adaptor from which you normally connect to the internet (i.e. Wifi) and select properties.

  • Enable Internet Connection Sharing on the Sharing tab.

  • Select the Ethernet device EthernetX which matches the one listed as USB Ethernet/RNDIS Gadget in the device manager.

  • Take note of the IP address suggested, but don't accept it yet (if it does not match the current IP of the Raspberry Pi)! i.e. Suggested IP address:

Connect to the Raspberry Pi via Putty using the previously configured IP address (

  • You must set the Raspberry Pi's IP address to match the first three numbers, by editing /etc/network/interfaces (this version of the file is available _SETTINGS/022-usb-lan-mode/internet folder):

  • Reboot the Raspberry Pi using sudo reboot

  • Finally, enable ICS and accept the suggested IP address.

  • You should now be able to connect using the newly set address for the Raspberry Pi via Putty.

You may also need to ensure that the Ethernet device EthernetX (which matches the one listed as USB Ethernet/RNDIS Gadget in the device manager) has the following settings:

This ensures the USB Ethernet adaptor which has the ICS linked to it has the same IP address group as the Raspberry Pi's fixed address.

##How to use##


The ingredient files should be placed in the following location on the NOOBS RECOVERY partition:


This recipe uses the following files:



You can download all the ingredient files, and extracted directly to the NOOBS SD-Card (ensuring you remove the ZIP file's name from the directory - the files should be extracted to pi-kitchen/022-usb-lan-mode).

##The Recipe Files##

Each recipe will use one file for each of the partitions it installs to - boot, root and data).

You will need to suitably rename or copy the content of each of the following files into your recipe files (i.e. RaspbianPiKitchen_root.txt) and place them in your os folder in the NOOBS partition (i.e. os/Raspbian).

For more information see the Pi-Kitchen: Creating Flavours guide.



#Recipe: 022-usb-lan-mode

#- Replace the /etc/modules file

../../pi-kitchen/022-usb-lan-mode/etc/modules /etc/

#- Replace the /etc/network/interfaces file

#Default (non-internet connection sharing setting)

../../pi-kitchen/022-usb-lan-mode/etc/network/interfaces /etc/network

#Internet Connection Sharing settings (ensure this is suitable for your setup if ICS required)

../../pi-kitchen/_SETTINGS/022-usb-lan-mode/internet/interfaces /etc/network

Enjoy baking your Raspberry Pi SD-Card fresh from the Pi-Kitchen.

You can’t perform that action at this time.