Two Network Interfaces - One for LAN and One For Internet

I am using 2 connections on my Windows 10 PC. One is for accessing my LAN and other is for internet.

Long story short: What I need is that I prioritize my Internet connection (4G USB stick) for accessing web but when I need to access something over that other LAN (multiple subnets) it is not working.

Basically I need my 4G connection online all the time, and I need to access different subnets over my LAN connection (ethernet port) like I normally do. For instance my PC's subnet over that LAN is 10.79.4.0/24 and I can also access my other subnets 10.79.0.0/24` etc. ... But as soon as I switch to my other internet interface (4G USB stick), only my initial subnet over that first LAN interface is accessible 10.79.4.0/24 and not the other ones.

If my metric is lower on the LAN (which is also internet capable over a different firewall and external IP) everything is fine. But, if I lets say just kill the internet over LAN for test purposes, it switches to the second interface (4G USB stick) which is fine, but I cannot access any local resources other then the subnet which that interface is on.

Basically this is my failover method if priority firewall/internet goes off and I want to access the Windows 10 device over TV or RealVNC and the local resources.

How can I do this? I believe it is achievable somehow. I just do not know how can it be done? I hope I made myself clear...

enter image description here

Interfaces

Primary internet connection and LAN connection

Primary internet connection and LAN connection

Secondary, Failover 4G connection

Secondary, Failover 4G connection

Routing Table

Routing table

Tracert

Tracert

10

1 Answer

I will write an answer to stop bugging you with comments. The environment that you have, from your command outputs looks something like:

Current Environment

Let me split this in two:

Routing Step

First let's summarize how the 4G connection would work while still accessing the local network (as confirmed in the question comments). Windows will prefer the route with the lowest metric, in this case LAN is 291 and 4G is 527.

If you change metrics so that your 4G connection kicks in, you should have routes for all of the internal networks you will want to reach:

route -p add 10.79.0.0 mask 255.255.255.0 10.79.4.1
...
route -p add <SUBNET IP> mask <MASK> 10.79.4.1

Consider that SUBNET IP is the network address (See here).

If you have all 10.x.x.x networks then an easier approach could be to do route -p add 10.0.0.0 mask 255.0.0.0 10.79.4.1. You can do this because your 4G is on 192.168.8.0/24

Failover Step

I don't want to say you can't do it, but to the best of my knowledge I don't think you will be able to handle this with just clever metric configuration. This is because for Windows the gateway is up. Windows will automatically switch to a higher metric (default via 192.168.8.1) only in the case that the lower metric gateway (10.79.4.1) is unreachable. However this is not the case, your next hop is alive, you just lost internet connection.

With what you have, I would take the approach of writing a quick and dirty script to change metrics upon internet failure, something like:

@echo off
echo Checking internet connection...
ping %1 -n 1 -w 1000 > NUL
if errorlevel 1 (GOTO FALLBACK) else (GOTO ALLGOOD)
:FALLBACK
echo Internet Failed
:: YOUR CODE
echo -- Here goes the code to change the routes and metrics when internet fails
::...
exit 0
:ALLGOOD
echo Internet probe was successful
:: MAYBE REVERSE THE METRICS?
exit 0

Store it in a .cmd file and paste the routes as you figured them out on the first step. Maybe create a rollback routine as well in the event it comes back. The condition itself works:

Command execution example

pass the probe IP to test connection as an argument. I would then set it up to run periodically (set intervals depending on your downtime tolerance).

I hope this helps you figure it out.

Cheers,

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like