Using "route add" to tell my computer to use a direct ethernet connection instead of wifi?

36,930

Solution 1

Aha, trick question :), it caught me, too.

The Gateway should be set to your IP.

I played with it; if you do a ROUTE PRINT it will list interface numbers at the top of the output, I'm going to call your ethernet interface <ETH>.

The command would then be as follows for the 192.168.0.7 machine (and similar for .6):

ROUTE ADD 192.168.0.0/24 192.168.0.7 IF <ETH>

or

ROUTE ADD 192.168.0.0 MASK 255.255.255.0 192.168.0.7 IF <ETH>

I hope this works for you :)

Solution 2

This isn't a routing issue but a name resolution issue. You are most likely connecting to it by name. depending on what IP is resolved will dictate what connection it uses. If you connect via the IP instead of name it WILL use the right connection.

IE if you try to connect to 192.168.0.7 from the other PC it will use the ethernet connection because this network is directly accessible via that interface. So either connected by IP or modify your host file to resolve the PC name to the IP on the ethernet address.

Share:
36,930

Related videos on Youtube

Supercereal
Author by

Supercereal

Updated on September 17, 2022

Comments

  • Supercereal
    Supercereal over 1 year

    2 PCs are involved. Both are connected to the internet via Wifi on the same router. I can ping to/from each other and share folders flawlessly, but I'd like to be able to set a direct Ethernet link between them to speed up file transfers AND keep the Wifi connections (no gateway).

    So I plugged my RJ45 cable, and set up the connection. It works, but the PCs are only using this connection if one of them if disconnected from the Wifi.

    PC1 local address is 192.168.0.7 on its ethernet interface, and 192.168.1.21 on the wifi one.

    PC2 local address is 192.168.0.6 on its ethernet interface, and 192.168.1.22 on the wifi one.

    My question is : I'd like to using the route add command to tell PC1 to use the Ethernet interface when it needs to connect with PC2, by specifying "IF 2" at the end of the route add command. How can I do this ? I don't know what to put in the "gateway" parameter of the command, and everything I tried returns "the parameter is incorrect" (i don't know which one).

    ipconfig /all on PC1 :

    Windows IP Configuration
    
    Host Name . . . . . . . . . . . . : Sam-PC    
    Primary Dns Suffix  . . . . . . . :    
    Node Type . . . . . . . . . . . . : Hybrid    
    IP Routing Enabled. . . . . . . . : No    
    WINS Proxy Enabled. . . . . . . . : No
    
    Wireless LAN adapter Wireless Network Connection:
    
    Connection-specific DNS Suffix  . : 
    Description . . . . . . . . . . . : NETGEAR WG111v3 54Mbps Wireless USB 2.0 Adapter    
    Physical Address. . . . . . . . . : 00-22-3F-DA-51-56    
    DHCP Enabled. . . . . . . . . . . : Yes    
    Autoconfiguration Enabled . . . . : Yes    
    Link-local IPv6 Address . . . . . : fe80::1d33:60b:476c:d396%12(Preferred) 
    IPv4 Address. . . . . . . . . . . : 192.168.1.21(Preferred)    
    Subnet Mask . . . . . . . . . . . : 255.255.255.0  
    Lease Obtained. . . . . . . . . . : vendredi 27 novembre 2009 15:38:48    
    Lease Expires . . . . . . . . . . : dimanche 29 novembre 2009 07:33:04    
    Default Gateway . . . . . . . . . : 192.168.1.1    
    DHCP Server . . . . . . . . . . . : 192.168.1.1    
    DHCPv6 IAID . . . . . . . . . . . : 301998655    
    DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-12-7E-58-EA-00-1A-4D-59-B2-71 
    DNS Servers . . . . . . . . . . . : 192.168.1.1    
    NetBIOS over Tcpip. . . . . . . . : Enabled
    
    Ethernet adapter Local Area Connection:
    
    Connection-specific DNS Suffix  . : 
    Description . . . . . . . . . . . : Realtek PCIe GBE Family Controller    
    Physical Address. . . . . . . . . : 00-1A-4D-59-B2-71    
    DHCP Enabled. . . . . . . . . . . : No    
    Autoconfiguration Enabled . . . . : Yes    
    Link-local IPv6 Address . . . . . : fe80::f598:c3a0:df8d:706e%11(Preferred) 
    IPv4 Address. . . . . . . . . . . : 192.168.0.7(Preferred)    
    Subnet Mask . . . . . . . . . . . : 255.255.255.0  
    Default Gateway . . . . . . . . . :    
    DHCPv6 IAID . . . . . . . . . . . : 234887757    
    DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-12-7E-58-EA-00-1A-4D-59-B2-71 
    DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
                                        fec0:0:0:ffff::2%1
                                        fec0:0:0:ffff::3%1    
    NetBIOS over Tcpip. . . . . . . . : Enabled
    
  • user1984103
    user1984103 almost 13 years
    Unless the computers are acting as routers themselves, the 192.168.0.* subnet will not actually have any gateways, and this will do nothing except break internet access on the computers when they start trying to route traffic over the ethernet link that should be going to the gateway (which is over the wireless link).
  • Tyler Szabo
    Tyler Szabo almost 13 years
    Hey Darth, I just double checked and my directions are accurate. I think the misunderstanding is in how the route add command treats a gateway that is also the same as the IP address of the interface. If you perform the add as I show it will create a route that displays as "On-link" indicating that the subnet is accessible directly over ethernet (and does not need routing). Try this short test: ping 8.8.8.8 (google DNS), add 8.8.8.0/24 as I show, look at the routing table, ping it (see the ICMP failure from local IF), delete it.
  • user1984103
    user1984103 almost 13 years
    Ah, my bad. I misread "gateway" as "default gateway". You are correct!