31

I have the following problem: I have a server with a rather dynamic network configuration and need to configure routes on it with the IF parameter:

route add  ... mask ... ... if ?

Is there a reliable way, manual and or programmatical, to get that interface number if I know just about everything else about that adaptor?

AndreasT
  • 877

4 Answers4

44

You can see that info also when you run the route print command. It's the first thing displayed. The index is the first column

===========================================================================
Interface List
 13... ......Bluetooth Device (Personal Area Network)
 10... ......Intel(R) 82566MM Gigabit Network Connection
 11... ......Intel(R) Wireless WiFi Link 4965AG
 17... ......VMware Virtual Ethernet Adapter for VMnet1
 18. . ......VMware Virtual Ethernet Adapter for VMnet8
Rex
  • 7,945
23

The following command displays the list of interfaces:

netsh int ipv4 show interfaces

Admin
  • 241
13

Since you know everything else about the adaptor, and since you are using Server 2008, you can (and should) just add your routes with netsh using the interface name:

netsh int ipv4 add route <remote netid>/<remote netmask> <interface name> <next hop>

Use of the route command is generally deprecated in 2008+.

phoebus
  • 8,430
5

You can using PowerShell:

Get-WMIObject Win32_networkadapter | Select-Object Name, AdapterType, InterfaceIndex | Format-List
cuonglm
  • 2,416