1

I've added a few static routes, for the most part the following has worked fine:

route add 123.123.123.123 mask 255.255.255.255 100.100.100.100 metric 10 -p

However, one URL resolves to more that one IP address / it isn't static. Is there any way to change the command above to include an entire octet, i.e. 123.123.123.*

If not, can I make a static route based on the host name? So anything matching example.com would use the route?

I know, from a networking / purist perspective that routing tables don't really relate to host names / DNS - but M$'s documentation seems to indicate that 'feature' is present (rightly or wrongly):

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sag_tcpip_pro_addstaticroute.mspx?mfr=true

Michael
  • 325
  • 5
  • 13
  • Can anyone explain the downvote? I don't understand what is wrong with my question? – Michael Aug 17 '11 at 10:14
  • You might want to read up on how subnetting works. http://serverfault.com/questions/49765 – quux Aug 17 '11 at 10:51
  • 3
    The downvote isn't very nice. You should explain to the OP why he is wrong instead of just punishing him. – Antoine Benkemoun Aug 17 '11 at 12:23
  • I believe the correct URL is http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/sag_tcpip_pro_addstaticroute.mspx?mfr=true or http://technet.microsoft.com/en-us/library/cc757323(v=WS.10).aspx also similar question at http://serverfault.com/questions/144582/static-route-toward-a-dns-address-it-is-possible – zacharydl Dec 16 '14 at 20:06

2 Answers2

4

You can "wildcard" IP addresses by just changing the netmask:

route add 192.0.2.0 mask 255.255.255.0 <router>

There's no way to route to a hostname, because names are handled at a higher level of the network stack.

womble
  • 96,255
  • 29
  • 175
  • 230
  • 1
    Microsoft's docs (the link in the question) states: "Destination - Specifies either an IP address or host name for the network or host."? – Michael Aug 17 '11 at 10:13
  • @Mikaveli Yeah, by changing the netmask, you're specifying the route for the network. – MDMarra Aug 17 '11 at 11:56
  • 1
    @MarkM My point was that the M$ doc says you can specify a host name, but womble's answer says you can't. – Michael Aug 17 '11 at 12:39
  • I never said you couldn't *specify* a hostname, just that you can't *route* to one. If you specify a hostname, then it gets resolved to an IP address, and when that address changes (as you state it will), then the route will be out-of-date and your routing will fail. – womble Aug 17 '11 at 21:49
1

It sounds like you're trying to solve a problem that you are having in a different manner than you really should. What problem are you actually trying to solve? routes have nothing do with names, you can't really mix the two. The names are looked up at the time the route is entered and translated to an IP address at that time.

Aaron
  • 2,968
  • 1
  • 23
  • 36
  • After lookup, the remote server's IP address often changes - so a single static route isn't suitable. – Michael Aug 17 '11 at 11:19
  • So, then, you're trying to solve a different problem. - what problem is that? It sounds like you need to look into an application proxy of some sort. – Aaron Aug 17 '11 at 11:24
  • I'm trying to test an app (not mine) in an environment with a proxy - the app doesn't support them. All the other remote calls work with this approach because their IP addresses remain static. If there's a better approach to doing a 'quick test', I'd be grateful of any suggestion. :) – Michael Aug 17 '11 at 12:26