Wired and wireless connections: make Windows prefer Ethernet when connecting to a specific other computer in the network?

6,458

Solution 1

I believe I found a solution. I was thinking, and what I want is to basically subvert Windows' hostname lookup, since it is righfully looking up computers on the wireless network first (it has the lower metric after all, since it has an internet connection). Then I remembered there's a file exactly for that: the lmhosts file.

Adding a map from the notebook's hostname to it's wired IP works exactly as I want: Windows first tries to reach it through Ethernet, but falls back to NetBIOS/DNS lookup if it's not accessible, and then finds the wireless IP. I thought hostname caching might be a problem, but apparently the lmhosts file is looked up even before the cache.

TL;DR: Adding the wired IP of the notebook to the lmhosts.sam (at %windir%\system32\drivers\etc) file works flawlessly. Thanks for all the helpful answers!

Solution 2

It looks like you haven't configured wired interfaces. You need to assign an IP address to each connected interface. Take a look at how to assign a static IP address.

For example, use the IP address 192.168.13.1 and netmask 255.255.255.0 on your desktop and the IP address 192.168.13.2 with netmask 255.255.255.0 on the laptop.

After that you can reach the laptop's shares from the desktop using the address \\192.168.13.2 . On the desktop put that address in the Windows Explorer Address bar or in Run... window (Win+R).

Solution 3

From what I can tell the wireless tromps the wired when it comes to connecting without control in the windows systems. This is based on the "metric" (priority) set for that network item.

If everything else is working correctally ,and you could normally connect to either of them , Disabling the wireless connection in Network stuff , will disable the wireless (duh). The working and correct wired connection will immediataly be used instead. (re-enabling wireless the system will start using wireless again) the inner workings of that are beyond me, it just does.

I can hop from wired to wireless in the push of a shortcut button in my windows XP system, by device disable methods. I use the tool "devcon" (device connect), put it in a script to shut the devices on and off at will, and at a whim for testing. (talk about secure, it is off)

Anybody want to learn it, I could show you, I use most simplistic methods (dolt) as possible so I can debug, alter, and control, so this shouldnt be That hard.

This is a XP script for One device, my Nic Card itself, which I had previously Identified by its cryptic junk that the system shows me when doing a Devcon "find".

Simple switch, check to see if it is running or not, toggle it, tell me what happend.


echo OFF
cls

C:\Desk\batch\DEVCON.exe >"%USERPROFILE%\Local Settings\Temp\Rescheck" status *811A1043*
FIND /I /C "RUNNING" "%USERPROFILE%\Local Settings\Temp\Rescheck"
IF %ERRORLEVEL% GTR 0 GOTO NOTRUN

start /B "beeps" C:\Desk\batch\wav.exe C:\WINDOWS\Media\AppSounds\netdetecto.wav
ECHO  driver is probably running disable it
C:\Desk\batch\DEVCON.exe disable *811A1043*

exit

:NOTRUN
echo driver is probably not running enable it
start /B "beeps" C:\Desk\batch\wav.exe C:\WINDOWS\Media\AppSounds\netdetectc.wav
C:\Desk\batch\DEVCON.exe enable *811A1043*

exit

That wasnt so bad was it :-) of course it could be done in 1/3rd that, but it has to keep me informed.

Break it down

run the command Devcon.exe. > send the output to some temp wherever. do a status . * Wildcard * some aspect of the device ID simply partial ID of device.

Check the simple text file FIND. look for the text running /I /C "RUNNING". in the temp

If the above fails because running is not found IF %ERRORLEVEL% GTR 0. Then go to the tag GOTO NOTRUN

If it goes to that tag :NOTRUN then enable the device DEVCON.exe ENABLE wildcarded Device numbers


Go to the Device manager in your system to see hardware names, and even IDs on some systems.

The simplest way to see device ID things from devcons perspective, is to do a devcon.exe /find and to simply start applying your wildcards * now to reduce the list.

To make things easy, dont even bother with Full ID or hwid , it will only cause frustration, use the wildcards, just get enough ID so it is different, test that manually using /find, test using /enable ,with the wildcards.

Devcon DL http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q311272 (now in both 32bit and 64 bit 78K zip file)

Share:
6,458

Related videos on Youtube

danielkza
Author by

danielkza

Updated on September 18, 2022

Comments

  • danielkza
    danielkza over 1 year

    I have a desktop connected to the internet and to my home network through Wi-Fi, and a laptop connected to said desktop through an Ethernet cable. But Windows seems to only reach the laptop through Wi-Fi: I want to transfer files through the wired connection instead.

    Setting up Internet Connection Sharing and disconnecting the laptop from Wi-Fi altogether doesn't seem like the most elegant solution to me. I also thought about going to the hosts file and setting up the IP address manually, but that would make the laptop completely unavailable if it's not wired, which happens quite often unfortunately.

    Is there any way for me to tell Windows to use the wired connection for a particular host if possible, and fallback to any other route it finds otherwise?

    • ta.speot.is
      ta.speot.is over 12 years
      You could try changing the interface metrics on the machine, whether this helps when being connected to, I don't know. windowsreference.com/windows-2000/…
    • danielkza
      danielkza over 12 years
      Changing the metrics would force Windows to use the wired connection for everything, including internet access which it does not have, since the desktop is connected to my router through Wi-Fi.
  • danielkza
    danielkza over 12 years
    That's exactly what I dont want. I can reach the computer through the IP perfectly, but I want the hostname to point to the wired interface's IP instead of the wireless'. I have many services configured through the hostname (ssh, rsync, synergy, etc) and I'd rather not mess with them all if possible.
  • danielkza
    danielkza over 12 years
    I don't want to disable Wi-Fi: I acccess the Internet through it. I just want Windows to see it can reach the notebook by Ethernet and use it instead of Wi-Fi. Disabling Wi-Fi is not an option :(
  • Psycogeek
    Psycogeek over 12 years
    Ahh, so you want Both at the same time? To be able to transfer files around between computers with the wired, and get your web stuff via the Wireless? That is completely different. the system is not normally capable of that because of the 2 IPs thing (xp did not allow easy 2 seperate IPs). There is a method that is used by servers , and a program for users if I can find it again.
  • Psycogeek
    Psycogeek over 12 years
    we normally use a USB lap-link type item for this type of 2nd connection, because it is simple as can be, secure being local, and fast being usb (now Gig-lan can be faster). It connects via USB to both computers, then has buffers in a Box on the wires, a sort of direct connect, and far less net junk for me (lazy me)
  • Psycogeek
    Psycogeek over 12 years
    I might need this someday, can you give example of USE with this method? and can you have simeltanious I/O ?
  • danielkza
    danielkza over 12 years
    Well, that's the whole content of my lmhosts.sam file: 192.168.2.2 danielkza-note. What happens now is that when I try to reach daniel-note, it will go to the notebooks wired IP (192.168.2.2) if the cable is connected, or to the wireless IP (192.168.1.101) otherwise. It's plain host name aliasing, so I don't get what you ask by simultaneous I/O.
  • Psycogeek
    Psycogeek over 12 years
    Now that you have it set up, what kinds of things can you do on the computer with both connections, Like can you Surf the web, and transfer files? Have open files via the other computer, and download? just any example of how you use both. Nevermind, I see FALLBACK now in the question .