WiFi and LAN network cable simultaneously - Internet access

Diese Seite gibt es auch in Deutsch

What actually happens when WiFi and the network cable are connected at the same time? The routing table provides the answer to this question. By adjusting the routing or the metric in the TCP/IP settings of the adapters, the desired behavior can be set. If you want to see the settings noted here in action, you can do so in a short video.

Aim of this article

Configuring Internet access
with more than one network adapter
e.g. WiFi and LAN

Effort

Reading time: approx. 7 Minutes

Prerequisite

a little network basic knowledge
and a Windows computer
For example, access to the LAN can be via network cable, and access to the Internet via WiFi or a mobile data stick.

 

Change access: Metric

Each network adapter has a "metric" in its TCP/IP settings. In case of equal entries in the routing table, as an example two adapters with a possible internet connection, the adapter with the lower metric is used for access to the internet. To influence which adapter is used for access, the metric for each adapter can be set to a specific value in the network connection settings of "Automatic metric".

Searching for "View network connections"  , leads us directly to the adapter overview:

"Control Panel > Network and Sharing Centre"

The setting is done by right-clicking on the respective adapter: "Properties", "Internet Protocol, Version 4 (TCP /IPv4)", "Advanced", "IP Settings":

For example, if the Ethernet adapter (network cable) is set to a fixed value of 30 and the WiFi adapter is set to 10, the call to the Internet would take place via the WiFi adapter and the access to the subnet of the Ethernet adapter via its cable.

In Detail

In the following example, the computer uses a wired network card (Ethernet) with the IP address: 192.168.0.10 and a WiFi card with the IP address 192.168.1.169.

Information about the IP addresses and the network adapters can be read out with the command ipconfig /all.

To start, I just connect the Ethernet network cable:

Ethernet only

The routing table can be displayed using the "route print" command at the command prompt.

My LAN connection shows the following routing entries:

C:\Users\LiBe>route print

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0     192.168.0.1      192.168.0.10     20
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    331
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    331
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    331
      192.168.0.0    255.255.255.0         On-link      192.168.0.10    281
    192.168.0.10   255.255.255.255         On-link      192.168.0.10    281
    192.168.0.255  255.255.255.255         On-link      192.168.0.10    281
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    331
        224.0.0.0        240.0.0.0         On-link      192.168.1.10    281
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    331
  255.255.255.255  255.255.255.255         On-link      192.168.0.10    281
===========================================================================
Persistent Routes:
  None

The first line is interesting:

0.0.0.0 means all destinations not explicitly in the routing table are forwarded to the gateway.

More precisely it means:

The network adapter with IP: 192.168.0.10 forwards requests for addresses that do not match any range in the table to the gateway: 192.168.0.1. So the gateway is used if the called address is in an unknown network range. The gateway, here with the address 192.168.0.1, is the address of the router; an address in an unknown network area is an address that is not located in a specified local LAN, in this case on the Internet.

WiFi only

When I unplug the network cable and connect to the WiFi, the routing table looks like this:

So again "route print" in the command prompt:

C:\Users\LiBe>route print

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0      192.168.1.2    192.168.1.169     25
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    331
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    331
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    331
      192.168.1.0    255.255.255.0         On-link     192.168.1.169    281
    192.168.1.169  255.255.255.255         On-link     192.168.1.169    281
    192.168.1.255  255.255.255.255         On-link     192.168.1.169    281
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    331
        224.0.0.0        240.0.0.0         On-link     192.168.1.169    281
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    331
  255.255.255.255  255.255.255.255         On-link     192.168.1.169    281
===========================================================================
Persistent Routes:
  None

My WiFi router has the IP: 192.168.1.2, the WiFi adapter has the address 192.168.1.169. Again, all requests that are in a network that is not listed are routed to the Internet via the entry 0.0.0.0. It will be exciting if I now additionally reconnect the network cable:

Ethernet and WiFi

C:\Users\LiBe>route print

IPv4 Route Table
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0      192.168.1.2    192.168.1.169     25
          0.0.0.0          0.0.0.0      192.168.0.1     192.168.0.10     20
        127.0.0.0        255.0.0.0         On-link         127.0.0.1    331
        127.0.0.1  255.255.255.255         On-link         127.0.0.1    331
  127.255.255.255  255.255.255.255         On-link         127.0.0.1    331
      192.168.0.0    255.255.255.0         On-link      192.168.0.10    281
     192.168.0.10  255.255.255.255         On-link      192.168.0.10    281
    192.168.0.255  255.255.255.255         On-link      192.168.0.10    281
      192.168.1.0    255.255.255.0         On-link     192.168.1.169    281
    192.168.1.169  255.255.255.255         On-link     192.168.1.169    281
    192.168.1.255  255.255.255.255         On-link     192.168.1.169    281
        224.0.0.0        240.0.0.0         On-link         127.0.0.1    331
        224.0.0.0        240.0.0.0         On-link      192.168.0.10    281
        224.0.0.0        240.0.0.0         On-link     192.168.0.169    281
  255.255.255.255  255.255.255.255         On-link         127.0.0.1    331  
  255.255.255.255  255.255.255.255         On-link      192.168.0.10    281
  255.255.255.255  255.255.255.255         On-link     192.168.1.169    281
===========================================================================
Persistent Routes:
  None

Now it becomes problematic: In the table there are two identical entries (0.0.0.0) for the connection to the Internet.  

In this case the computer tries to use the entry with the smaller metric first, so in our case the Ethernet cable (adapter with the address: 192.168.0.10).

For devices in the 192.168.1.x network, according to the entry:

192.168.1.0  255.255.255.0  On-Link  192.168.1.169 

the network adapter with the IP: 192.168.1.169 is used, i.e. our WiFi adapter.

For devices in the network 192.168.0.x is used according to the entry:

192.168.0.0  255.255.255.0  On-Link  192.168.0.10 

the network adapter with the IP: 192.168.0.10 is used. 

Customize metrics

If I use a higher metric for the network adapter than for the WiFi adapter, WiFi is used by default.

The setting is transferred to the routing table:

The metric could also be set from the command prompt:

route change 0.0.0.0 MASK 0.0.0.0 192.168.0.1 metric 1

with route change 0.0.0.0 MASK 0.0.0.0 192.168.0.1 metric 1 -p the setting remains even after a connect and disconnect, or after a reboot.

If the IP address is assigned by a DHCP server, this can specify the metric:

Option "Default Router Metric Base", see https://technet.microsoft.com/en-us/library/cc977349.aspx;

The default values are described on this page: https://support.microsoft.com/en-us/help/299540/an-explanation-of-the-automatic-metric-feature-for-ipv4-routes

Advanced: Customize routing table

In order to edit the routing table, we need to start it as administrator: 

with the command: route delete 0.0.0 mask 0.0.0 192.168.0.1 we can specifically delete the connection to the Internet for the Ethernet connection (network cable).

C:\Windows\system32>route delete 0.0.0.0 mask 0.0.0.0 192.168.0.1
 OK!

C:\Windows\system32>

The computer is still connected to the local LAN, 

Requests to the Internet go via the WiFi adapter: 192.168.1.169

Requests to the local LAN of the Ethernet adapter via the network cable: 192.168.0.10

Additional routes can be entered with the "route add" command. The changes to the routing table are lost again after the PC is restarted. For permanent changes the parameter "-p" can be used.

Video

I recreated the behavior of changing the metric in the following video:

positive Bewertung({{pro_count}})
Rate Post:
{{percentage}} % positive
negative Bewertung({{con_count}})

THANK YOU for your review!

Updated: 2022-05-10 von Bernhard 🔔


Top articles in this section


Ping with Port | cmd vs. PowerShell: Test-Netconnection
As is well known, the tool ping can be used to test the access to a certain network device and its response time. Not all devices will respond to a ping, but they may respond to a particular Tcp-Port if a particular network service is provided through it. Windows PowerShell allows you to test a specific port using Windows board tools. The psping tool can also measure the response time to a specific port.

OpenWRT hardware recommendation - available devices 2022
OpenWRT provides a uniform and up-to-date software for different network devices like routers or access points and delivers countless additional setting options, software packages and functions. This makes it possible to combine new and old devices from different manufacturers and, among other things, to use low-cost hardware in a common WiFi, see: Setting up a home network: Extending LAN and WLAN | Improving.

List all IP addresses in the network even if the firewall is enabled
If you want to get a quick overview of all active devices in a network, you can do this with network discovery, commands in the command prompt, in PowerShell or with special IP scanners. The PowerShell commands presented at the beginning of this post give a quick overview of all devices on the local network and may make special programs for scanning the network unnecessary. If you would like to see the commands in action, you can do so in my YouTube video. For expanding your own network, see als...

Questions / Comments


By continuing to browse the site, you agree to our use of cookies. More Details