-1

Background / Setup:

  • OS - Raspbian Stretch lite
  • Board - Raspberry Pi Zero (no WiFi / no Ethernet)
  • Ethernet Adapter - USB to Ethernet adapter

The way I have got it working:

  • After writing the Raspbian image to a SD card, I create an empty file "ssh" in \boot (from windows) in order to enable sshd at boot
  • Startup the Raspberry Pi using the new SD card and Ethernet adapter plugged in
  • I run nmap from another Linux box to scan open ssh ports on devices on my network and find IP of the new system
  • log into new system
  • edit /etc/network/interfaces file (below)
source-directory /etc/network/interfaces.d

allow-hotplug eth0
auto eth0
iface eth0 inet static
    address 192.168.25.27
    netmask 255.255.255.0
    gateway 192.168.25.4
    dns-nameservers 8.8.8.8
    hwaddress 00:e0:4c:53:44:27
  • Reboot and ssh into the specified IP

Using the setup above, all works fine. I don't want to use DHCP.

Question:

I would like to know if there is some way to configure my USB Ethernet adapter from /boot (FAT partition) --> before booting <-- and logging into the system. I have tried to use ip=xx.xx.xx.xx in cmdline.txt but it doesn't work for me. I also have to setup a MAC address for my Ethernet adapter.

  • 1
    Can't you use the serial console? – Kong Chun Ho Jan 10 '18 at 5:24
  • yes I used the serial console using the physical pins. but I don't want to going forward if there is a way to do it without soldering header pins. – Chetan Bhargava Jan 10 '18 at 7:43
  • You don't need to solder any pins, just three jumper wires and one USB<->Serial Module (aka FTDI Breakout). – Kong Chun Ho Jan 10 '18 at 7:53
  • If you have access to your router, set the static IP using MAC address mapping from the router instead of from RPi. – hcheung Jan 10 '18 at 14:19
  • I have emphasized on "before booting" in my question – Chetan Bhargava Jan 12 '18 at 8:12
1

Yes, there are several ways.

  1. Serial console

Connect Tx/Rx and GND pins to your Pi's serial console pin and your USB<->UART board. Make sure your USB<->UART module uses 3V3 logic level to prevent damage to the Pi.

  1. USB Gadget Ethernet

As you mentioned you are using RPi Zero, one of the two USB ports obviously work as power, but the another one work as an OTG, which means your Pi Zero can be a USB host (connecting mouse to it, etc), or a USB device (emulating as an ethernet adapter) using the same port. You can add modules-load=dwc2,g_ether to your cmdline.txt, then connect the Pi to your computer through a micro USB cable. Your Pi Zero will now act as an ethernet device, you can connect to it via SSH at raspberrypi.local and perform your required configurations. If your Pi Zero need access to the internet, you can even enable Internet Connection Sharing (Windows), PC Sharing Connections (Ubuntu), etc.

  1. Directly edit the /etc/network/interfaces on a Linux machine

This is the most straightforward way, just mount the raspbian partition on your Linux machine and modify your required files.

  • My question is about how to add Ethernet parameters using /boot – Chetan Bhargava Jan 10 '18 at 18:34
  • Why it has to be modifying /boot? What's wrong with the suggested solution to try to solve your issue? Can you provide the model name and the kernel module name for the USB <-> Ethernet adapter? – Kong Chun Ho Jan 12 '18 at 6:43
  • Chun, I wish to setup eth0 before boot. As stated in my question, I already have a way to setup eth0 AFTER boot, my quest is here to setup eth0 BEFORE boot. Hope I made it clear. – Chetan Bhargava Jan 12 '18 at 8:07
  • I have emphasized on "before booting" in my question – Chetan Bhargava Jan 12 '18 at 8:12
  • Your answer unfortunately doesn't answer my question as I want to configure eth0 before powering on my Pi. I hope you get it. – Chetan Bhargava Jan 12 '18 at 8:14
0

If you have the access of your router, you can set up static IP from your router instead of from RPi. All you need is the MAC address of the USB Ethernet port.

  • I need to hard code my MAC as well – Chetan Bhargava Jan 10 '18 at 18:35
  • I have emphasized on "before booting" in my question – Chetan Bhargava Jan 12 '18 at 8:12
  • The USB ethernet adapter that I have has a generic MAC address, therefore I need to explicitly set my own MAC before boot. Any pointers? – Chetan Bhargava Jan 12 '18 at 8:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.