Raspberry Pi with Multiple IP's / Subnets

The Raspberry Pi's wired network card can be assigned multiple static IP addresses, which allows the Pi to manage multiple subnets.

 

Here is a guide to setting a static IP address on the Pi:

In essence,

Open the network configuration document into the leafpad text editor by typing "sudo leafpad /etc/network/interfaces" into the Pi's terminal. When setting a static IP, the block that looks like

iface eth0 inet dhcp

ends up being replaced by (for example)

iface eth0 inet static
	address 192.168.5.10
	netmask 255.255.255.0
	gateway 192.168.5.1

 

With the addition of a few extra lines, this basic block can be expanded into multiple static IP's. (https://wiki.debian.org/NetworkConfiguration#Multiple_IP_addresses_on_one_Interface). The eth0 connection gets "aliased": eth0:0, eth0:1, etc.

auto eth0
allow-hotplug eth0
iface eth0 inet static
	address 192.168.5.10
	netmask 255.255.255.0
	gateway 192.168.5.1

auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
	address 192.168.2.10
	netmask 255.255.255.0
	gateway 192.168.2.1

auto eth0:1
allow-hotplug eth0:1
iface eth0 inet static
	address 192.168.8.10
	netmask 255.255.255.0
	gateway 192.168.8.1