Route ethernet traffic through wifi

This guide will set up the pi as a router that will forward all traffic received on the ethernet interface through an existing wifi connection.

A running wifi connection is required, the pi must be connected to it.

Setting static ethernet address

First, we need to set the pi so it has a static address on the ethernet network.

You must not modify /etc/network/interfaces directly. This used to work, but the latest versions of the pi's dhcp client will ignore these modifications and set up a different address.

# Settings for ethernet interface
interface eth0
    #Setting static ip address:
    static ip_address={ip address}/{netmask}

DHCP server on ethernet interface

The dhcp server will provide computers who connect on the ethernet interface with addresses.

subnet 10.5.5.0 netmask 255.255.255.0 {
  range 10.5.5.20 10.5.5.30;
  option routers 10.5.5.1;
  option broadcast-address 10.5.5.255;
}

Forward ethernet traffic through existing connection

We set up a network. It would be nice if the pi could act as a gateway so that packets received on the network could be forwarded to the internet.

Reset the pi to a pre-routing state

If you want to reset all we did, so that your pi won't be a router anymore, follow these steps.