# Redirect mail traffic

**URL:** <https://community.f5.com/t/redirect-mail-traffic/50847>\
**Category:** Technical Forums\
**Tags:** irules, big-ip, application-delivery\
**Created:** [May 27, 2020, 8:41pm UTC](https://community.f5.com/t/redirect-mail-traffic/50847 "2020-05-27T20:41:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris\_Olson](https://avatars.discourse-cdn.com/v4/letter/c/5daacb/32.png) [@Chris\_Olson](https://community.f5.com/u/Chris_Olson)\
**Post date:** [May 27, 2020, 8:41pm UTC](https://community.f5.com/t/redirect-mail-traffic/50847/1 "2020-05-27T20:41:55Z")

</div>

We are moving Data centers. There will be a period of time where we may want to redirect mail traffic. We can used DNS but that takes time to propagate. I have used multiple irules for URL and http traffic but not for mail traffic. I don’t know if F5 has the right operators for SMTP.

Basically, all traffic coming in over 995 and SMTP should be redirected to the new mail server in the new data center. I thought about replacing when http request with when “client\_accepted” then maybe use string parameter but they all use to “http” too. Is there a way to direct all my mail server traffic to the new domain. Obviously, my mail servers already site behind the F5.

ltm rule mail\_redirect {

when CLIENT\_ACCEPTED {

if { [string tolower [HTTP::host]] equals “[mail.olddomain.com](http://mail.olddomain.com)” } {

# redirect to [mail.newdomain.com](http://mail.newdomain.com)

}

---

<div class="post-metadata">

**Author:** ![KeesvandenBos](https://avatars.discourse-cdn.com/v4/letter/k/ecb155/32.png) [@KeesvandenBos](https://community.f5.com/u/KeesvandenBos)\
**Post date:** [June 2, 2020, 1:20pm UTC](https://community.f5.com/t/redirect-mail-traffic/50847/2 "2020-06-02T13:20:32Z")

</div>

I would configure this with MX records.

MX 10 [mail.olddomain.com](http://mail.olddomain.com)

MX 20 [mail.newdomain.com](http://mail.newdomain.com)

Disable the virtual server for [mail.newdomain.com](http://mail.newdomain.com) until the migration.

Mailservers will first try MX 10 to send the email. If it is not responding they will send it to the next MX record in the list.

When you start the migration enable the virtual server for [mail.newdomain.com](http://mail.newdomain.com) and disable the virtual server for [mail.olddomain.com](http://mail.olddomain.com)

Sending mailservers will automatically start sending mail to [mail.newdomain.com](http://mail.newdomain.com).

Cheers,

Kees
