Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm trying to write a script and the interface column does not display the interface!

C:\>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 ff 27 13 f6 5b ...... TAP-Win32 Adapter V9
0x3 ...08 00 27 53 00 bb ...... AMD PCNET Family PCI Ethernet Adapter - Packet
cheduler Miniport
===========================================================================
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0         10.0.2.2       10.0.2.15       20

I need a way to find out what interface (as in 0x1, 0x2, 0x3) that route is using. Kind of like how in *nix route will give you:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use **Iface**
192.168.0.0     *               255.255.255.0   U     202    0        0 **eth0**
default         192.168.0.1     0.0.0.0         UG    202    0        0 **eth0**

Also, no where in 'route print' does it say default, my script just assumes the first line with 0.0.0.0 0.0.0.0 in it contains the default gw in the third column, is this a safe assumption?

share|improve this question
    
"is this a safe assumption?" Might not be. The format is right, but you might have multiple default routes. (In that case I think the route with the lowest metric is used.) –  Mikel Dec 20 '10 at 22:47

1 Answer 1

Use the commands

netsh interface ipv4 show route

to see the list of routes, and

netsh interface ipv4 show interface

to see the list of interfaces.

The route 0.0.0.0/0 always is the default route and points to the default gateway.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.