Are you planning to put your Raspberry Pi in some cool system that operates outside on the field – maybe a drone?? Or are you on a trip where you don’t have access to a monitor, extra keyboard and mouse?

Sometimes it would be great to have access to the Raspberry Pi without having to connect it to the WiFi and without the need of a Monitor, an additional keyboard and a mouse, which is sometimes referred to as “going headless”.

This post shows you how to prepare your Raspberry Pi before going on the trip, so you can use a simple Ethernet cable to log onto your Raspberry Pi.

Preparing the Raspberry Pi

To have a safe copy to come back to, make a copy of your interfaces file with:

sudo cp /etc/network/interfaces /etc/network/interfaces.orig

Before going headless with the Raspberry Pi use a Monitor, keyboard and mouse or the method described in the post “Raspberry Pi Zero Setup with no Monitor” using your router to change on the Raspberry Pi the content of the file /etc/network/interfaces to the following:

 	

auto lo eth0 wlan0
iface lo inet loopback
iface eth0 inet static
   address 192.168.1.111
   netmask 255.255.255.0
   gateway 10.1.1.1
        
allow-hotplug wlan0
# Choice 1: If you want to use for your WiFi a static address use this (note: pay attention that no other device has the same address):
iface wlan0 inet static
   address 192.168.1.222
   netmask 255.255.255.0
   gateway 10.1.1.1

# Put your router name and password in the following file:
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

# Choice 2: if you want to have the WiFi address set automatically to e.g. avoid conflicts with other devices, then uncomment (remove one # per line) in the following and add a # before each line of choice 1:
#Iface wlan0 inet dhcp
## Put your router name and password in the following file:
#wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

#iface default inet dhcp

To connect to your Raspberry using an Ethernet tether you will have to take a note of the eth0 address that you chose in the above “address” line of the /etc/network/interfaces file (here e.g 192.168.1.111).

This was the part you have to do on the Raspberry Pi side do be ready to connect to it headless. Short and simple.

Preparing your PC or Laptop

Preparing your Laptop on the other end is relatively simple too:

    [table id=7 column_widths=”50%|50%”/]

That was it. You should have now a wired LAN (Ethernet) connection between your Laptop and your Pi. You should be able to log into the Pi using for example PuTTy and do there almost anything. You should also be able to exchange between Pi and Laptop files using for example FileZilla.

With this you have a system that is very independent from the outside world. The downside though is that the Pi has no connection to the internet and so it is not possible to install anything on the Pi.

The method shown in the next post is similar to this but allows the Pi to connect to the internet using the Laptop’s internet access.

As usual please let me know your questions and thoughts. I am looking forward to hearing from you.