Menu

#15 FindGateway routine is based on a false assumption

accepted
nobody
None
defect
Irrelevant
medium
2025-04-12
2015-06-02
Zangune
No

Up to version [0.16] the FindGateway routine assumes the gateway value is the first occurrence after 0.0.0.0 in route output. This works (as far as I know), but it is not true that always the one listed is the default gateway.
More than this arz should show the default gateway only.
This is in the output of the ROUTE PRINT command (edit) in Windows XP (Windows 7 is similar):

C:\Documents and Settings\Zangune>ROUTE PRINT
===========================================================================
Elenco interfacce
0x1 ........................... MS TCP Loopback interface
0x2 ...00 13 d4 62 6f c8 ...... NIC Fast Ethernet PCI Realtek RTL8139 Family - V
irtualBox Bridged Networking Driver Miniport
0x3 ...08 00 27 00 74 39 ...... VirtualBox Host-Only Ethernet Adapter
===========================================================================
===========================================================================
Route attive:
Indirizzo rete             Mask             Gateway       Interfac.  Metric
          0.0.0.0          0.0.0.0      192.168.2.1     192.168.2.2       20
        127.0.0.0        255.0.0.0        127.0.0.1       127.0.0.1       1
      192.168.2.0    255.255.255.0      192.168.2.2     192.168.2.2       20
      192.168.2.2  255.255.255.255        127.0.0.1       127.0.0.1       20
    192.168.2.255  255.255.255.255      192.168.2.2     192.168.2.2       20
     192.168.56.0    255.255.255.0     192.168.56.1    192.168.56.1       20
     192.168.56.1  255.255.255.255        127.0.0.1       127.0.0.1       20
   192.168.56.255  255.255.255.255     192.168.56.1    192.168.56.1       20
        224.0.0.0        240.0.0.0      192.168.2.2     192.168.2.2       20
        224.0.0.0        240.0.0.0     192.168.56.1    192.168.56.1       20
  255.255.255.255  255.255.255.255      192.168.2.2     192.168.2.2       1
  255.255.255.255  255.255.255.255     192.168.56.1    192.168.56.1       1
Gateway predefinito:       192.168.2.1
===========================================================================
Route permanenti:
  Nessuno

so the default gateway is clearly showed at bottom.

Related

Code: 0.16

Discussion

  • Zangune

    Zangune - 2015-06-06

    Fixed in [0.17], new FindGateway routine:

    FOR /F "TOKENS=3" %%G IN ('
        ROUTE PRINT
            ^|FINDSTR ":"
                ^|FINDSTR ".*\."'
    ) DO (
        SET Gateway=%%G
    )
    
     

    Related

    Code: 0.17


    Last edit: Zangune 2025-05-26
  • Zangune

    Zangune - 2015-06-06
    • assigned_to: Zangune
     
  • Zangune

    Zangune - 2015-06-26
    • status: closed --> open
     

    Last edit: Zangune 2015-10-18
  • Zangune

    Zangune - 2015-06-26

    Bad user "feedback":

    [12:59:17] <fifthyfifthyxoxoxox> computer=FILO windows 7 64
    bit ip=192.168.1.2 mac=70:f1:a1:93:87:fe,40:61:86:f5:02:78,
    70:f1:a1:93:87:ff tcp=50000 udp=40000 router= http://
    
    [13:10:03] <ambrosia> computer=LEON-PC windows 7 32 bit
    ip=192.168.0.104 mac=00:24:2b:82:1f:82,00:1f:16:6f:38:41
    tcp=17560 udp=35100 router= http://
    


    no gateway address.

     
  • Zangune

    Zangune - 2015-06-26

    At least in Windows 8.1 the ROUTE PRINT output is completely different from a Windows XP one.

     

    Last edit: Zangune 2015-10-18
  • Zangune

    Zangune - 2015-06-26

    I will do a regression and use old code for now.
    It seems the false assumption is valid for the vast majority of users as I didn't find anyone with a different gateway for now.

     

    Last edit: Zangune 2015-10-18
  • Zangune

    Zangune - 2015-06-26
    • status: open --> pending
     
  • Zangune

    Zangune - 2015-10-19

    Indeed, Windows version is relevant, but I still don't know starting from which version Windows ROUTE PRINT output changed. Probably, Windows 8 or Windows 8.1.

     

    Last edit: Zangune 2023-12-29
  • Zangune

    Zangune - 2015-10-20
    • Status: pending --> accepted
     
  • Zangune

    Zangune - 2025-04-12
    • assigned_to: Zangune --> nobody
     

Anonymous
Anonymous

Add attachments
Cancel