3 years ago

Share internet to the Raspberry Pi Zero

Use one Raspberry Pi to share its internet with a Pi Zero through the GPIO ports, using Point-to-Point Protocol

Point-to-Point Protocol (PPP) is how everyone used to access the internet, back in the days of dial-up. You can use it with your Pi Zero to piggyback on the internet connection of another Pi which is already online. This saves the single micro-USB data connector to use with something else, if you don’t want to hook up a USB hub and need to connect more than just a WiFi dongle.

You’ll need…

  • A Raspberry Pi A, B, A+, B+ or 2
  • A Raspberry Pi Zero
  • 2× SD cards, both with a fresh install of Raspbian Jessie
  • 2× male-to-female jumper cables
  • A blob of Blu-Tack or plasticine

The full article can be found in The MagPi 41 and was written by Dave Honess

For the following steps, the host Raspberry Pi needs to have internet access. First, enable IPv4 forwarding by going into the terminal and using:

Find the line net.ipv4.ip_forward=1 and remove the # symbol at the start of the line. Save and exit using CTRL+X and then pressing Y. Now run this command to reload the config:

Next install the ppp package:

The plan is to use the UART GPIO pins to link the host Pi to the Zero. We need to use physical GPIO pin numbers 8 and 10; these pins are otherwise known as TXD (transmit) and RXD (receive).

By default, there is a login prompt running on the UART, so we first need to disable it:

You should see this:

Remove console=ttyAMA0,115200, then save and exit. For the speed of the data link to be acceptable, we need to speed up the UART internal clock:

Append init_uart_clock=16000000 to the
bottom of the file, then save and exit. Then we need to disable the login prompt service that runs
on the UART:

Reboot the Pi. We now need to create an options file that will configure the PPP service when it starts:

Copy the following lines into the file:

Save and exit. The two IP addresses need to be available on your LAN, and should be different to the one allocated to the host Pi’s Ethernet adaptor. Next, create a config file that tells the PPP service to start automatically on boot:

Copy the lines below into the file:

Now run the following commands to enable the service:

Shut down the Raspberry Pi.

On the Zero

It’s a good idea to change the host name on the Zero in order to avoid confusion when you’re SSHed into it:

Change raspberrypi to zero, then:

Do the same again: raspberrypi to zero. Save and exit. Next, install the ppp package:

As with the host Raspberry Pi, you’ll need to disable the login prompt in the same way as before. When you get to creating an options file, use this:

Next, we need to preconfigure a DNS server, otherwise the Zero will not be able to perform DNS queries.

Find the line #name_servers= and insert the line name_servers= below it. Save and exit.

Now run the following commands to enable the service:

Shut down the Pi Zero.

Put it all together

Connect the UART ‘pins’ of the Pi Zero as shown in the main image on the opposite page. Use a blob of Blu-Tack or plasticine to wedge the male ends of the jumper cables so that they’re in contact with the metal holes on the Zero; remember, it’s physical GPIO pin numbers 8 and 10.

Boot up both the host Pi and the Zero. The following command can be used to monitor the status
of the PPP service:

This will give you the log file of the PPP service.

The following line indicates that the connection has been established (the pid number for you will be different):

If you have any issues or see error messages, you can restart the PPP service using this command:

You should now be able to SSH into the Zero using this command: