1

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.

abe
  • 111
  • 2

3 Answers3

1

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)

Ron
  • 11
  • 1
  • If I’m understanding you this switches between the networks for all apps is that right? – abe Jun 05 '20 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 192.168.1.37, 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 05 '20 at 21:17
1

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 0.0.0.0. Assuming your WiFi adapter gets assigned 192.168.1.5 and Ethernet gets 192.168.2.10, you need your mail server to listen on 192.168.1.5 and the homebridge (whatever that is) to listen on 192.168.2.10. 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.

Dmitry Grigoryev
  • 27,928
  • 6
  • 53
  • 144
0

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
nogateway

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.

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • 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 06 '20 at 08:28