Jump to content

homemade ethernet gadgets


Recommended Posts

Looking at Mubix's and sammyk's work with quick creds and posion tap, and of course playing with the bunny got my wheels turning and i decided i wanted to play around building my own pi zero into a custom ethernet gadget.  

I recently bought a few pi zero W's (with wifi) and am trying to get passed stage 1 of my project, i.e. getting the pi to be recognized as an ethernet adapter when plugged in to a pc or mac.  i followed adafruits tutorial: https://learn.adafruit.com/turning-your-raspberry-pi-zero-into-a-usb-gadget/ethernet-gadget but it doesn't seem to work. 

Has anyone else tried this?  can you point me to some tutorial gold!

I know i am reinventing the wheel here, but for me i just want to learn buy trying to build my own from scratch..  

FYI loving the bunny

 

Link to post
Share on other sites

this one worked for me the down side is there is no dhcp server by default so although it does seem to work you need to wait a long time after plugging it in. To install a dhcp apt-get install isc-dhcp-server then set a static ip for the usb0 interface, and configure your /etc/dhcp/dhcpd.conf & /etc/default/isc-dhcp-server

if you need more details on configs just let me know. 

Link to post
Share on other sites

It's the same as adafruits tutorial..  mind you my pizero is a pi zero W (built in wifi)  don't know if that is interfering, but it's shouldn't.. could you share the changes to DHCPD.conf and isc- DHCP-server

 

 

Link to post
Share on other sites

Sure,

I have only ever done this with a zero w.

of course the ip range is just what I selected randomly you can adjust them as need be just keep in mind if you set it to something on the same network as your wifi or the clients network you will have issues.

first install dhcp

apt-get install isc-dhcp-server
 

set the dhcp option

/etc/dhcp/dhcpd.conf

ddns-update-style none;
authoritative;
log-facility local7;

subnet 10.99.140.0 netmask 255.255.255.0 {
range 10.99.140.10 10.99.140.100;
option routers 10.99.140.1;
option broadcast-address 10.99.140.255;
default-lease-time 600;
max-lease-time 7200;
option domain-name "local";
}

 

tell the dhcp server to apply to the usb0 interface

/etc/default/isc-dhcp-server

DHCPD_CONF=/etc/dhcp/dhcpd.conf
DHCPD_PID=/var/run/dhcpd.pid
INTERFACES="usb0"

 

set the usb0 interface to have a static ip

 

/etc/network/interfaces

add

auto usb0
# or allow-hotplug usb0
iface usb0 inet static
    address 10.99.140.1
    netmask 255.255.255.0
    network 10.99.140.0
    broadcast 10.99.140.255
#    gateway 10.99.140.1
    


   then

sudo service isc-dhcp-server restart
 

if theres any issues with your config files it will give you two commands you can run for more info.

after plugging the pi in again it may take a moment before the dhcp server comes up (pi boots much slower than bashbunny) and hands an ip to your client so give it a moment my system gets a self assigned ip then the pi gives it one but you may have to renew the ip if it does not get one quickly enough.

this should have you up and running. it will not get internet over usb with these setting, for my use i wanted internet over wifi and pi access over usb... or cellphone access over wifi and computer access over usb....

let me know if this works for you!

Edited by jjd
Link to post
Share on other sites

Im going to play around with this tomorrow afternoon.. thank you so much.. we can investigate later about decreasing boot time. Im just trying to understand the bones..  can you speak a bit to what the thought process of picking ip range.. 

Link to post
Share on other sites

It doesn't matter if its W or not, all the pi zero tutorials will work with all 3 versions of the zero

Edited by b0N3z
Link to post
Share on other sites
On 3/25/2017 at 7:10 PM, Onus said:

Im going to play around with this tomorrow afternoon.. thank you so much.. we can investigate later about decreasing boot time. Im just trying to understand the bones..  can you speak a bit to what the thought process of picking ip range.. 

you will have issues if you pick an ip range that the client or pi connect to on wireless so i just picked one I'm not likely to run into

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...