Networks Set IE to use Specific Gateway

Discussion in 'Tech Support' started by Pookie, 17 Mar 2016.

  1. Pookie

    Pookie Illegitimi non carborundum

    Joined:
    4 May 2010
    Posts:
    3,491
    Likes Received:
    129
    Bit of a weird one but hopefully someone can help. I have 2 network adapters in my work PC (just installed the second to acomplish this). My first Ethernet port goes out through our fibre line which is on 192.168.0.1.

    We have another gateway on .192.168.0.2 that has a static IP address. We use an online database that only accepts the connection from our static IP so when ever I need to log into the system I have to change my gateway each time :sigh:

    Is there a way I can set Internet explorer to use 192.168.0.2 and have all my other traffic go through 192.168.0.1?
     
  2. Gareth Halfacree

    Gareth Halfacree WIIGII! Lover of bit-tech Administrator Super Moderator Moderator

    Joined:
    4 Dec 2007
    Posts:
    14,900
    Likes Received:
    3,672
    You need to specify a route. Normally, everything that leaves your network goes through a default route - which means it'd head out through 192.168.0.1; what you need to do is specify a route that says "if the destination is SiteThatNeedsaStaticIP then route via 192.168.0.2 instead of the default."

    Thankfully, that's a piece of... pie.

    route -p ADD destination MASK netmask gateway

    So, step one: find out the IP address (or, more accurately, network subnet) of the site you're wanting to access via your secondary gateway. Let's say, for the sake of argument, it's 169.254.1.0-255 (yes, that's a link local address - the real IP will be publicly-routable). Then all you have to do is:

    route -p ADD 169.254.1.0 MASK 255.255.255.0 192.168.0.2

    Et voila: every time you try to access a machine on the 169.254.1.0/24 subnet, the traffic goes via your secondary gateway instead of your default route. Ta-da!

    Oh, and as an aside: as both of your gateways are on the same network, there's absolutely no reason to have a second network card in your machine. You can achieve the above with only one network card without difficulty.
     
    Last edited: 17 Mar 2016
  3. Pookie

    Pookie Illegitimi non carborundum

    Joined:
    4 May 2010
    Posts:
    3,491
    Likes Received:
    129
    Thanks Gareth. you make it sound sound so easy, but where do I add the route? In the command prompt?
     
  4. Gareth Halfacree

    Gareth Halfacree WIIGII! Lover of bit-tech Administrator Super Moderator Moderator

    Joined:
    4 Dec 2007
    Posts:
    14,900
    Likes Received:
    3,672
    Yup. If you want it to remain after a reboot, just stick a batch file in... well, wherever Windows keeps its startup stuff these days.

    EDIT: Wait, according to this you need route -p add, not just route add. So, my example would be:

    route -p ADD 169.254.1.0 MASK 255.255.255.0 192.168.0.2

    EDIT AGAIN: The former network engineer in me would like to point out that the right way of doing this is to connect Gateway2 to the WAN side of Gateway1, rather than have both on the internal network. That way, Gateway1 can take care of "if the destination is SiteThatNeedsaStaticIP then route via Gateway2 instead of the default" and you don't need to mess around with the routing tables on every machine on the local network. Not to say that the above won't work, of course.
     
    Last edited: 17 Mar 2016
  5. Pookie

    Pookie Illegitimi non carborundum

    Joined:
    4 May 2010
    Posts:
    3,491
    Likes Received:
    129
    Thanks Gareth, I have run the commmand as route Add 123.456.789.123 192.168.0.2 and it accepted the command, but still no joy. Must I have the mask? If so how do I find it out?

    EDIT: just tried with the -p and still no joy :(
     
  6. Gareth Halfacree

    Gareth Halfacree WIIGII! Lover of bit-tech Administrator Super Moderator Moderator

    Joined:
    4 Dec 2007
    Posts:
    14,900
    Likes Received:
    3,672
    It's Windows, so quite probably. If you're routing to a single IP then the netmask would be 255.255.255.255. Note that this will only work if the website has but a single IP; if it's running on more than one server, then the route will only change for the IP you specify.

    Easy way to test: after adding the route, type:

    tracert 123.456.789.123

    The output will show you each hop in the chain, the first of which will be the gateway you left via. If you see "192.168.0.2," then everything's good and IE may be breaking something. If you see "192.168.0.1" then something's wrong and your traffic is going via the default gateway.
     
  7. Pookie

    Pookie Illegitimi non carborundum

    Joined:
    4 May 2010
    Posts:
    3,491
    Likes Received:
    129
    I feel stupid, I was using the wrong IP address :wallbash::wallbash::wallbash::wallbash: Its now working a treat :clap::clap::clap::clap:

    I will make a batch file and lob it in my start up folder so I dont need to do it every morning. Thanks so much Gareth I really appreciate it :thumb:
     
  8. Gareth Halfacree

    Gareth Halfacree WIIGII! Lover of bit-tech Administrator Super Moderator Moderator

    Joined:
    4 Dec 2007
    Posts:
    14,900
    Likes Received:
    3,672
    Hah! Yeah, that'd do it!

    Glad it's up and running, and glad I could help!
     
  9. Pookie

    Pookie Illegitimi non carborundum

    Joined:
    4 May 2010
    Posts:
    3,491
    Likes Received:
    129
    Everyday for the last year I have had to change my gateway 5-6 times a day to get into the database to get customer details so you can image how tedious and annoying this was :sigh:

    I use Citrix Go To Assist and always have multiple support sessions going so thats why I need the fibre line (Virgin business 150mbps) and cant use the ADSL line with the static IP all the time .
     
  10. Atomic

    Atomic Gerwaff

    Joined:
    6 May 2002
    Posts:
    9,646
    Likes Received:
    94
    Just add /p on the end and of the command you are using to create a static route that will persist between reboots :)

    eg:
    Code:
    route add 169.254.1.0 MASK 255.255.255.0 192.168.0.2 /p
    You can run route print (from command prompt) to view the routes and you will see that the new route is now persistent as it will be listed as highlighted below:

    [​IMG]
    (shamelessly stolen screenshot!)
     
    Last edited: 17 Mar 2016
  11. Gareth Halfacree

    Gareth Halfacree WIIGII! Lover of bit-tech Administrator Super Moderator Moderator

    Joined:
    4 Dec 2007
    Posts:
    14,900
    Likes Received:
    3,672
    There you go - even easier!
     
  12. Atomic

    Atomic Gerwaff

    Joined:
    6 May 2002
    Posts:
    9,646
    Likes Received:
    94
    You were so close earlier, it's not a nix command so I'll let you off ;)
     
  13. Gareth Halfacree

    Gareth Halfacree WIIGII! Lover of bit-tech Administrator Super Moderator Moderator

    Joined:
    4 Dec 2007
    Posts:
    14,900
    Likes Received:
    3,672
    We were lucky I remembered the old 8.3 restriction that means traceroute is tracert on Windows, frankly!
     

Share This Page