Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    SMTP port forwarding from internal server

    Scheduled Pinned Locked Moved NAT
    22 Posts 3 Posters 3.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      lex.under.3182 @viragomann
      last edited by

      @viragomann said in SMTP port forwarding from internal server:

      So 80.158.48.35 is the public IP when you go out and you try to forward SMTP mails to it??
      What is the public IP of pfSense?

      I cannot disclose pfsense ip( . but lets say it is 80.158.10.10

      80.158.48.35 is a public IP of several hundred servers without public IP. Lets call it Shared SNAT . and it does not allow SMTP ports including 587

      I try to forward SMTP connections to pfsense private ip 172.28.28.28 then I though it will automatically send that request through 80.158.10.10 to mail server.

      my ifconfig on pfsense

      [2.6.0-RELEASE][root@172.28.28.28]/root: ifconfig
      vtnet0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
              description: WAN
              options=800b8<VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,LINKSTATE>
              ether fa:16:3e:a9:cb12
              inet6 fe80::f816:3eff:fea9:ba12%vtnet0 prefixlen 64 scopeid 0x1
              inet 172.28.28.28 netmask 0xffffff00 broadcast 172.28.28.255
              media: Ethernet 10Gbase-T <full-duplex>
              status: active
              nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
      enc0: flags=0<> metric 0 mtu 1536
              groups: enc
              nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
      lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
              options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
              inet6 ::1 prefixlen 128
              inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
              inet 127.0.0.1 netmask 0xff000000
              groups: lo
              nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
      pflog0: flags=100<PROMISC> metric 0 mtu 33160
              groups: pflog
      pfsync0: flags=0<> metric 0 mtu 1500
              groups: pfsync
      
      V 1 Reply Last reply Reply Quote 0
      • V
        viragomann @lex.under.3182
        last edited by

        @lex-under-3182
        I think, I got it.

        My assumption was, you want to forward mails from any public IP first.
        So you can limit the source in the outbound NAT rule to the clients IP then.

        1 Reply Last reply Reply Quote 1
        • L
          lex.under.3182
          last edited by

          @viragomann @stephenw10

          Ok guys I think the issue somewhere on other end of firewall.
          When I am adding these settings I do see requests in logs but Firewall is blocking it, so the first though I have is to add Pass rule in firewall like this
          https://nimb.ws/WkY0AZ

          Then when I am doing telnet I do see that firewall stops blocking it
          https://nimb.ws/8ClMy0

          And connections times out which is probably means I cannot use 172.28.28.28 as my mail server host in application settings. (

          root@vault-test:~# telnet 172.28.28.28 587
          Trying 172.28.28.28...
          
          telnet: Unable to connect to remote host: Connection timed out
          
          V 1 Reply Last reply Reply Quote 0
          • V
            viragomann @lex.under.3182
            last edited by

            @lex-under-3182
            Strange, the rule should allow the packets.

            Switch to the nowmal log view, so you can see the rule which blocks the traffic.

            L 1 Reply Last reply Reply Quote 0
            • L
              lex.under.3182 @viragomann
              last edited by

              @viragomann Should I use 587 port under translation area?
              https://nimb.ws/NWw75O

              V 1 Reply Last reply Reply Quote 0
              • V
                viragomann @lex.under.3182
                last edited by

                @lex-under-3182
                No, that's the source port. I should be dynamic (any).
                Only the destination port is 587.

                L 1 Reply Last reply Reply Quote 0
                • L
                  lex.under.3182 @viragomann
                  last edited by

                  @viragomann port for source is empty as you can see on last screenshot. For "Translation" should be empty as well? hmm
                  Does not that mean to route any traffic to any port at 172.28.28.28 from 192.168.0.136 to 85.13.135.13:587 ?

                  If I try to connect to 172.28.28.28:80 then it will masquerade it to 85.13.135.13:587 ?

                  V 1 Reply Last reply Reply Quote 0
                  • V
                    viragomann @lex.under.3182
                    last edited by

                    @lex-under-3182
                    The translation port has to be empty. This is the source port in outgoing packets and should be automatically selected by pfSense.

                    1 Reply Last reply Reply Quote 1
                    • stephenw10S
                      stephenw10 Netgate Administrator
                      last edited by

                      Yup, or check the 'static port' box to use the same source port the client is using. Either should work here though.

                      Steve

                      1 Reply Last reply Reply Quote 0
                      • L
                        lex.under.3182
                        last edited by

                        @stephenw10 @viragomann
                        Ok guys, thank you for help, but looks like I am stuck with this... It still does not work. May be it is because of some settings in hoster's NAT for pfsense public IP that I do not control.

                        Although from pfsense I can telnet mail server.

                        /root: telnet 85.13.135.13 587
                        Trying 85.13.135.13...
                        Connected to dd52114.kasserver.com.
                        Escape character is '^]'.
                        220 dd52114.kasserver.com ESMTP
                        

                        From client's server I cannot

                        # telnet 172.28.28.28 587
                        Trying 172.28.28.28...
                        telnet: Unable to connect to remote host: Connection timed out
                        

                        It is possible there are also some other settings in pfsense that I have not enabled and that prevent this from mapping correctly.

                        I cannot ask you for any further help. It is not ethical I think) You spent a lot of time helping me... I will try to remove everything and setup again on sunday but I think the issue will be there and I will have to add the second openVPN for this purpose. Connecting each server to VPN to be able to send emails looks not very stable solution for me but I am pretty sure this should work...

                        In any case if somebody still find an issue in my configs or have another solution then please share.
                        Just to repeat here is my outbound NAT config
                        https://nimb.ws/IRHqbn
                        THis is firewall rule for that NAT
                        https://nimb.ws/VPYBs3
                        System - Advanced - Firewall&NAT
                        https://nimb.ws/O8lYWH

                        By the way did an upgrade of pfsense to 2.6.0-RELEASE like few weeks ago. And also there is no Translation options in System - Advanced - Firewall&NAT menu. But I doubt it could be the cause.

                        V 1 Reply Last reply Reply Quote 0
                        • V
                          viragomann @lex.under.3182
                          last edited by

                          @lex-under-3182
                          Is the port forwarding rule still in place. It is necessary as well.

                          Are the packets still blocked? If so, what's the responsible rule?

                          For troubleshooting run a packets capture on pfSense WAN interface, filter for port 587. So you can clearly see what the packets do.

                          1 Reply Last reply Reply Quote 0
                          • stephenw10S
                            stephenw10 Netgate Administrator
                            last edited by

                            Try to connect from the client. Check the states in pfSense.

                            1 Reply Last reply Reply Quote 0
                            • L
                              lex.under.3182
                              last edited by

                              @stephenw10 @viragomann
                              through VPN it worked fine. Spent 40 mins and issue solved.

                              Just to update. Thanks you guys for help anyway

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post
                              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.