Random Musings

Sporadic thoughts on tech, economics, business, finance and trading

I have one Ethernet port on my machine connected to 192.168.1.0 and a wireless adapter connected to 192.168.8.0. I want it to use the wireless adapter when trying to connect to resources on the latter network and the ethernet adapter when I try and access resources on 192.168.1.0.

,

To configure your PC to use the appropriate network adapter for each network (wired for 192.168.1.0 and wireless for 192.168.8.0), you can adjust the routing table to ensure traffic for each subnet goes through the correct interface.


Steps to Configure the Routing Table in Windows

1. Identify the Network Interfaces

  • Open Command Prompt with Administrator privileges:
    • Press Win + S, type cmd, right-click “Command Prompt,” and select “Run as Administrator.”
  • Type the following to display the list of network interfaces: ipconfig Note the IPv4 address, Subnet Mask, and Default Gateway for both the Ethernet and Wireless adapters.

2. Check the Current Routing Table

  • Use the route print command to view your PC’s routing table: route print This shows all routes and their priorities.

3. Add Specific Routes

You need to define routes for each subnet to ensure traffic is sent through the correct interface.

  • Route for 192.168.1.0 via Ethernet: Assuming the Ethernet adapter’s IP is 192.168.1.100 and its gateway is 192.168.1.1: route add 192.168.1.0 mask 255.255.255.0 192.168.1.1 metric 1 if <Ethernet_Interface_Index> Replace <Ethernet_Interface_Index> with the interface number for your Ethernet adapter. You can find it in the output of route print.
  • Route for 192.168.8.0 via Wireless: Assuming the Wireless adapter’s IP is 192.168.8.100 and its gateway is 192.168.8.1: route add 192.168.8.0 mask 255.255.255.0 192.168.8.1 metric 1 if <Wireless_Interface_Index> Replace <Wireless_Interface_Index> with the interface number for your Wireless adapter.

4. Make Routes Persistent

By default, the above commands are temporary and will reset after a reboot. To make them permanent, add the -p flag:

route -p add <destination> mask <subnet_mask> <gateway> metric 1 if <interface_index>

Example for Your Setup

  1. Assume:
    • Ethernet: IP = 192.168.1.100, Gateway = 192.168.1.1, Interface Index = 3
    • Wireless: IP = 192.168.8.100, Gateway = 192.168.8.1, Interface Index = 11
  2. Run these commands: route -p add 192.168.1.0 mask 255.255.255.0 192.168.1.1 metric 1 if 3 route -p add 192.168.8.0 mask 255.255.255.0 192.168.8.1 metric 1 if 11

5. Verify Configuration

  • Run route print again to confirm the new routes are added.
  • Test connectivity to resources on both networks to ensure traffic is routing correctly.

This setup will now prioritize the Ethernet adapter for the 192.168.1.0 network and the Wireless adapter for the 192.168.8.0 network.