dhcpcd

Network interface routing priority on a Raspberry Pi

52Pi Raspberry Pi Compute Module 4 Router Board

As I start using Raspberry Pis for more and more network routing activities—especially as the Compute Module 4 routers based on Debian, OpenWRT, and VyOS have started appearing—I've been struggling with one particular problem: how can I set routing priorities for network interfaces?

Now, this is a bit of a loaded question. You could dive right into routing tables and start adding and deleting routes from the kernel. You could mess with subnets, modify firewalls, and futz with iptables.

But in my case, my need was simple: I wanted to test the speed of a specific interface, either from one computer to another, or over the Internet (e.g. via speedtest-cli).

The problem is, even if you try limiting an application to a specific IP address (each network interface has its own), the Linux kernel will choose whatever network route it deems the best.

Setting a Static IP address with Raspbian Jessie Lite on the Raspberry Pi

In the midst of my work upgrading the Raspberry Pi Dramble to Raspbian Jessie Lite, I noticed one of the basic components of the architecture—static IP addresses for all the Raspberry Pis—was not working correctly anymore. My Ansible playbooks configured the /etc/network/interfaces file correctly, so it would define a static IP address for the eth0 interface (the built-in Ethernet port on the Pi):

auto lo

iface lo inet loopback

iface eth0 inet static
  address 10.0.1.60
  netmask 255.255.255.0
  gateway 10.0.1.1
  dns-nameservers 8.8.8.8 8.8.4.4

allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

In the past, with Raspbian Wheezy, everything worked fine, and the Pi would (after a reboot) use the static IP address 10.0.1.60.