I can route by IP range by the
route command. But is there any domain based route solution?
Routing is a layer 3 technique that gets your packets where they are supposed to go. Layer 3 information is almost only source IP, dest IP and fragmentation information.
Extra information such as domain name is way beyond layer 3, it's more layer 7 (the application layer). Therefore such information is not meant to be used for routing.
There are specific techniques that use information above layer 3, such as Policy Routing which uses layer 4 information (TCP/UDP ports) to route specific packets. That is as high as it goes as far as I know.
If you have control over that domain name, you could specify as specific IP that will then be routed by your routers in a specific way. If you can't do that, I'm afraid it's not going to be possible as far as I know.
There is no domain based route solution. But you can use this workaround script. It gets the IP of your domain and adds a route. You can add it to the task scheduler to run on windows startup or at any specific intervals and it'll keep adding the route. It doesn't use the -p option so the route added is not permanent.
:: Get IP of Domain name setlocal EnableDelayedExpansion set myServer=your.server.com for /f "tokens=1,2 delims=" %%a IN ('ping -n 1 !myServer!') DO ( if "%%b" NEQ "" set myServerIP=%%b ) echo ip is %myServerIP% route add %myServerIP% mask 255.255.255.255 <gateway ip> EXIT
Hope this helps!