I have two routers one is secured with VPN the other is not. I have a Raspberry Pi 4 I am running Vanilla Raspbian

I would like internet traffic to run through the VPN secured router using WIFI then I would like to host my Homebridge server and other servers via ethernet on the none secured network for local usage.

I can setup static IPs but I can't seem to figure out to to say use this internet connection.

How do you route traffic for each application?

Edit:------Adding clarity

I have a mail server and a homebridge server on the Pi. I would like the mail server to run on the wifi and Hombridge to run on the ethernet.

3 Answers 3


you probably need to set the interface that goes to your internet connection as the default route (or route of last resort), and enable ip forwarding on the your pi/rspian/linux. The other interface would be the gateway to a subnet where all the other stuff lives.

use /sbin/sysctl -w net.ipv4.ip_forward=1 to enable it temporary or:

add net.ipv4.ip_forward = 1

to /usr/lib/sysctl.d/50-default.conf (that's how it works on rhel/centos, raspian is probably very similar if also systemd).

and then /sbin/sysctl -p or reboot

(that is how it works in rhel/centos, or any systemd linux)

  • If I’m understanding you this switches between the networks for all apps is that right?
    – abe
    Jun 5, 2020 at 19:26
  • well, if your clients can all reach the multi-homed server, yes. for example. you would setup 3 virtual servers/interfaces. lets say, 38 and 39 that way you'd have your 3 "front ends". the multihomed server then takes care of the incoming traffic itself, or redirects it to where it needs to be. from the "outside" you would just see 3 hosts.
    – Ron
    Jun 5, 2020 at 21:17

Make the VPN router your default gateway (perhaps it already is), and then configure the the services to listen only on the right IP address instead of Assuming your WiFi adapter gets assigned and Ethernet gets, you need your mail server to listen on and the homebridge (whatever that is) to listen on Check out the documentation of both servers to figure out how to do it, typically there are configuration parameters called Listen, Bind, ListenAddress, BindAddress or something similar.


Your question is imprecise and lacking detail.

To answer the first part of your Question you can setup Raspberry Pi OS to use WiFi for default routing.

Firstly setup your network, without Ethernet connected, THEN add

interface eth0

to the /etc/dhcpcd.conf

See Prevent dhcpcd from configuring a gateway on an interface in How to set up networking/WiFi

There is insufficient information to explain how to setup EtherNet as it is unclear what you are trying to achieve; you may want to use a static IP address, setup as an Access Point and/or install a DHCP server for the Ethernet interface.

When you have finished you should run ip r to show routing. There should only be a single default for the WiFi interface.

  • Apologies for the lack of clarity I have update the question and added: I have a mail server and a homebridge server on the Pi. I would like the mail server to run on the wifi and Hombridge to run on the ethernet.
    – abe
    Jun 6, 2020 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.