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 10.0.0.0/24. First Internet connection is called primary and there is default gateway at 10.0.0.1/24. Second Internet connection is called backup Internet connection and it’s default dateway is 10.0.0.2/24. Exchange server has IP address 10.0.0.21/24 and it had default gateway 10.0.0.1/24. 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
:Loop1
%SystemRoot%\\System32\\ping.exe 1.1.1.1 -n 1 -w 30000 >NUL
%SystemRoot%\\System32\\ping.exe 8.8.8.8 -n 1 | find /i “bytes=” || goto FailedPing
goto Loop1
:FailedPing
echo FAILED PRIMARY NET TO VIA 10.0.0.1 %time% >>ping_test.log
%SystemRoot%\\System32\\route.exe delete 0.0.0.0 mask 0.0.0.0 10.0.0.1
%SystemRoot%\\System32\\route.exe add 0.0.0.0 mask 0.0.0.0 10.0.0.2
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.
Recent Comments