4

I am trying to automate logging into the routers setup config page, and if I can get the default gateway IP I want to be sure that I will be able to use that ip to login to the routers config page (of course assuming router has config page and I have user/pass etc). I am wanting to know that forth purposes I described it will always work, as I am unsure of the definition of the default gateway IP as compared to the IP of the connected router.

All references to IPs I've made are of course internal IPs and I am not talking about internet IPs.

Flimzy
  • 2,454
  • 18
  • 26
user55887
  • 151
  • 1
  • 2
  • 7

3 Answers3

10

The "default gateway" is simply the IP of the next hop for traffic that is not explicitly routed anywhere else. This will, almost certainly, be an IP address on an interface of a local router. However, it may not be an address on which you can manage the router.

If this is for a "home-type network", the inside IP (your default gateway) and the management address will probably be one and the same, but in a "large/corporate-type network" I wouldn't be so sure.

Vatine
  • 5,440
  • 25
  • 24
  • How do I get the management address either in code or using the registry? I know I can always see when I right click on the router item inside windows network link, and it has management page address ip listed, so where is this information stored so i can retrieve it in code? Thank. – user55887 Oct 01 '10 at 15:14
  • 1
    Unless you store your router's management address yourself, it's simply not there to retrieve. But, as I said, the only time it's likely to differ is when you have a network with tens, hundreds or maybe thousands of routers. – Vatine Oct 02 '10 at 09:15
  • In other words, if you haven't payed over $1000-2000 for the router, there's little chance you even can have management IP and local IP different. – Hubert Kario Oct 02 '10 at 13:17
  • Well, I suspect I can make that happen on my 50 quid Zyxel, but I have absolutely no need for it. – Vatine Oct 03 '10 at 08:19
  • this sounds encouraging, at least for most cases its good news. – user55887 Oct 13 '10 at 01:34
1

I'm going to hit you with the big "Depends": on some networks, the default gateway maybe a Layer 3 switch; you may also find that the default gateway (typically the LAN IP) is not the same interface that the management console/Web GUI listens on.

If you're talking about SOHO/SMB "flat" networks, then yes, the majority of the time the default gateway will also be the router's IP.

gravyface
  • 13,957
  • 19
  • 68
  • 100
  • How do I get the management address either in code or using the registry? I know I can always see when I right click on the router item inside windows network link, and it has management page address ip listed, so where is this information stored so i can retrieve it in code? Thank. – user55887 Oct 01 '10 at 15:16
  • The only Windows product I know that _kinda_ does this is Small Business Server during the network setup wizard, but even that's hit or miss: I've had plenty of firewall/routers that it doesn't detect properly. Long story short: don't waste your time trying to do this programmatically unless you have complete control over the environment that you're implementing this code in. – gravyface Oct 01 '10 at 15:27
  • check this out .... described what im thinking perfectly... http://stackoverflow.com/questions/3839189/how-to-get-router-name-ip-as-shown-in-windows-network-tab-in-code – user55887 Oct 01 '10 at 15:38
  • basically, the information is there, must be a way to retreive it... i have complete control of the environment... + admin rights :) – user55887 Oct 01 '10 at 15:39
  • gravyface was thinking about the whole network, not just your computer. And looking for management interfaces in different places than default gateway is highly heuristic. I highly doubt that Windows can detect routers not being default gateways. – Hubert Kario Oct 02 '10 at 13:21
1

To get the default gateway parse the output of the "route print -4" command.

dbasnett
  • 683
  • 5
  • 11