Home > Exchange, Microsoft, Windows > Internal Exchange via two Internet connections

Internal Exchange via two Internet connections

At one of my customer I had following request. They have Exchange server inside their network. They have two Internet connections. All mail communication goes via primary Internet connection. Second Internet connection is used for Internet browsing.

Internal IP network is First Internet connection is called primary and there is default gateway at Second Internet connection is called backup Internet connection and it’s default dateway is Exchange server has IP address and it had default gateway MX records are registered to public IP address of primary Internet connection. Problem is when primary line goes down. E-mail communication stops completely – e-mails don’t come and don’t leave company.

To solve this problem we need to make two changes:

  • Change MX records for Internet domain
  • Change routing for internal Exchange server

First step is simple. We had to add aditional MX record for Internet DNS zone for this company. We added another MX record with lower priority, which means with higher priority number 🙂

Second step was little bit more script. I had to write script to check every 30 seconds if Internet connetion is down. If so, change default gateway route to backup one. I scheduled following script to run on system startup on Exchange server:

@Echo Off


%SystemRoot%\\System32\\ping.exe -n 1 -w 30000 >NUL

%SystemRoot%\\System32\\ping.exe -n 1 | find /i “bytes=” || goto FailedPing

goto Loop1


echo FAILED PRIMARY NET TO VIA %time% >>ping_test.log

%SystemRoot%\\System32\\route.exe delete mask

%SystemRoot%\\System32\\route.exe add mask

goto Loop1

I think this script is self explanatory and it’s working. This script doesn’t handle failback situation, but you can make it work 🙂

Update1:This is not really good idea to ping something just once. When you lose ping reply for some reason, server will change default gateway which is not what’s wanted.

Categories: Exchange, Microsoft, Windows Tags: ,