Static route for one device

I come with a bit of a weird question.

I have two networks, A and B. Both of them have a Pi Hole which controls the DNS of the network.
There is one device C in network A which I sometimes want to connect network B. There is no possibility of installing VPN on C.
The Pi Hole in network A is the DHCP server of network A. Network B has a static IP address.

Is there any smart way of solving this?
I thought about some sort of static route. Is that a valid option?

Or is my setup doomed?

If want to push a static route to a single DHCP client, you can tag that client based on its MAC address.
And configure particular DHCP options to be advertised for this tag.
The DHCP option that you can use for this is below one:

pi@ph5b:~ $ pihole-FTL -- --help dhcp
Known DHCP options:
[..]
121 classless-static-route

My client laptop WiFi NIC has got below MAC:

dehakkelaar@laptop:~$ ip -br link
[..]
wlp16s0          UP             00:1f:3c:XX:XX:XX <BROADCAST,MULTICAST,UP,LOWER_UP>

IP's:

dehakkelaar@laptop:~$ ip -br -4 address show wlp16s0
wlp16s0          UP             10.0.0.112/24

And below routes:

dehakkelaar@laptop:~$ ip -4 route
default via 10.0.0.1 dev wlp16s0 proto dhcp metric 600
10.0.0.0/24 dev wlp16s0 proto kernel scope link src 10.0.0.112 metric 600

For the tagging and configuring routes, I can create below new config file on the Pi-hole host.
In below example I am advertising a route to the 192.168.1.0/24 network via router 10.0.0.254.
Notice I also have to push the default route/gateway 0.0.0.0/0,10.0.0.1 !
Also notice the MAC is in capital letters!

pi@ph5b:~ $ sudo nano /etc/dnsmasq.d/99-my-settings.conf
# Special route for laptop
dhcp-host=00:1F:3C:XX:XX:XX,set:specialroute
dhcp-option=tag:specialroute,option:classless-static-route,0.0.0.0/0,10.0.0.1,192.168.1.0/24,10.0.0.254

Check syntax:

pi@ph5b:~ $ pihole-FTL --test
dnsmasq: syntax check OK.

And below to apply:

pi@ph5b:~ $ sudo service pihole-FTL reload
pi@ph5b:~ $

Now if I go back to the laptop client and renew its DHCP lease, I can see the extra route:

dehakkelaar@laptop:~$ ip -4 route
default via 10.0.0.1 dev wlp16s0 proto dhcp metric 600
10.0.0.0/24 dev wlp16s0 proto kernel scope link src 10.0.0.112 metric 600
192.168.1.0/24 via 10.0.0.254 dev wlp16s0 proto dhcp metric 600

You can push all sorts of DHCP options to these tagged clients this way.
But not all DHCP options are always honored/applied!

EDIT: Ow you can checkout below for reference:

https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

You have not provided enough details to answer that (e.g. if one of your networks was in Sydney and the other in Capetown, then @deHakkelaar's suggestions would not help you at all).

Furthermore, your request is about routing.

As Pi-hole is not involved in routing, you should also consider to consult other forums specialising in networking/routing.

If 10.0.0.254 in above example were a VPN endpoint/router, then yes you can tell your clients to take that route to Capetown :wink:

I agree about the lack of info too.

@DORpapst, what I showed with my example is all that Pi-hole can do concerning routes and nothing more!

Hey,
Sorry for the late response, I have been a bit too busy lately.
Yeah, you are in fact right, this is more about routing, not the Pi hole. But I was in fact asking the question for pi hole, because the Pi Hole is the only thing on my Pis altering internet information, so I thought there might be some interference anyway.

The distance is about 1.000km between two places in Europe

What we are curious about is how do you intend to connect to that other network?
Via Internet or do you have some other means like for example a lease line?

If via Internet, I dont know of any other way than via VPN or similar.

EDIT: Ow and the private addresses that your devices are using cant be routed via Internet!
Only throught a VPN tunnel.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.