This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem using DNAT/SNAT and Masquerading

We are using a windows based mail server with two domains that should be linked to two static IPs.

So, we assigned to local IPs (10.10.5.1 - Domain A & 10.10.5.2 Domain B) the mail server.  According to the logs, the mail server properly binds each domain to the corresponding IP.

In addition, we have applied the following configuration to the Sophos UTM:

1. Masquerading
One rule per domain using the following settings:
Network: Domain A / Domain B
Interface: External (WAN)
Use address: Address 1 / Address 2

2. DNAT
One rule per domain using the following settings:
Rule type: DNAT
Matching condition
For traffic from: Any
Using service: IMAP, SMTP, etc.
Going to: External WAN - Address 1 / Address 2
Action
Change the destination to: Domain A / Domain B

3. SNAT
One rule per domain using the following settings:
Rule type: SNAT
Matching condition
For traffic from: Domain A / Domain B
Using service: Any
Going to: Any
Action
Change the source to: External WAN - Address 1 / Address 2


Now, our expectation is that all mail for Domain A is using Address 1 and all mail for Domain B is using Address 2.

Sadly, it only work properly for Domain A.  Domain B appears to bypass these rules and is using the External WAN address instead.  I confirmed this by sending an email to another and validating the header information.

I am guessing that we are missing something here, but I cannot figure out what.

Any suggestions on what could be wrong with our rules?

Thank you!


This thread was automatically locked due to age.
  • Hi, are you using the smtp proxy?

    Barry
  • No, we don't have a license for it and we are not planning on using it.
  • OK... the only other thing I can think of is a mistake in your configuration.

    Try disabling the Masquerading rule and see what happens; my guess is that traffic from B will be dropped.

    Post screenshots of all the relevant settings if you'd like us to check them.

    Barry
  • Ok.  Here are the requested screenshots.

    It appears that masquerading isn't being used for sending emails.  The results did not change when I disabled the two rules.

    What I don't understand is why it would work for one domain and no the other.  I mean the rules used for both domains are matching except on the domain name and the WAN address used.

    Need to put the last screenshot into a separate post since there is a limit of 5.
  • Here is the missing SNAT screen.

    I think I somehow need to validate that the mail server is doing the right thing.  I mean the log shows the correct address being used for the second domain, but I guess I should confirm this to be true.
  • I activated some extra logging on the NAT rules and it seems that the problem is with the mail server.  Apparently, it no longer properly binds to the assigned IP addresses.

    So, I need to fix that problem, but according to the SPF test it doesn't even use the NAT rules assigned to the other IP.  It instead triggers no rule at all and goes straight to the external WAN.

    I guess that means I have a problem with the rules above and the mail server... [:(]
  • The problem is solved! [[:)]]

    I found that there is a setting in the mail server that allowed it to fail back to the primary IP.  This appeared to have caused the original issue.

    Since I started playing around with the settings in Astaro assuming that I made a mistake there, I failed to notice that I forgot to change everything back after fixing the mail server.

    The rules shown in the screenshots above work just fine.  Thank you! [[:)]]